| 1 |
/* |
| 2 |
* Copyright © 2017 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software: you can redistribute it and/or modify it |
| 5 |
* under the terms of the GNU General Public License version 3, as published |
| 6 |
* by the Free Software Foundation. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, but |
| 9 |
* WITHOUT ANY WARRANTY; without even the implied warranties of |
| 10 |
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 11 |
* PURPOSE. See the GNU General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU General Public License along |
| 14 |
* with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
* |
| 16 |
* Authors: |
| 17 |
* Ted Gould <[email protected]> |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "info-watcher.h" |
| 21 |
#include <glib.h> |
| 22 |
|
| 23 |
namespace lomiri |
| 24 |
{ |
| 25 |
namespace app_launch |
| 26 |
{ |
| 27 |
namespace info_watcher |
| 28 |
{ |
| 29 |
|
| 30 |
Base::Base(const std::shared_ptr<Registry::Impl>& registry) |
| 31 |
: registry_(registry) |
| 32 |
{ |
| 33 |
} |
| 34 |
|
| 35 |
/** Accessor function to the registry that ensures we can still |
| 36 |
get it, which we always should be able to, but in case. */ |
| 37 |
std::shared_ptr<Registry::Impl> Base::getReg() |
| 38 |
{ |
| 39 |
auto reg = registry_.lock(); |
| 40 |
if (G_UNLIKELY(!reg)) |
| 41 |
{ |
| 42 |
throw std::runtime_error{"App Store lost track of the Registry that owns it"}; |
| 43 |
} |
| 44 |
return reg; |
| 45 |
} |
| 46 |
|
| 47 |
} // namespace info_watcher |
| 48 |
} // namespace app_launch |
| 49 |
} // namespace lomiri |