Debian Codegraph @

liblomiri-app-launch/info-watcher.h

raw
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 #pragma once
21
22 #include "application.h"
23 #include "registry.h"
24
25 #include <core/signal.h>
26 #include <set>
27
28 namespace lomiri
29 {
30 namespace app_launch
31 {
32 namespace info_watcher
33 {
34
35 class Base
36 {
37 public:
38 Base(const std::shared_ptr<Registry::Impl>& registry);
39 virtual ~Base() = default;
40
41 virtual core::Signal<const std::shared_ptr<Application>&>& infoChanged()
42 {
43 return infoChanged_;
44 }
45
46 virtual core::Signal<const std::shared_ptr<Application>&>& appAdded()
47 {
48 return appAdded_;
49 }
50
51 virtual core::Signal<const AppID&>& appRemoved()
52 {
53 return appRemoved_;
54 }
55
56 protected:
57 /** Signal for info changed on an application */
58 core::Signal<const std::shared_ptr<Application>&> infoChanged_;
59 /** Signal for applications added */
60 core::Signal<const std::shared_ptr<Application>&> appAdded_;
61 /** Signal for applications removed */
62 core::Signal<const AppID&> appRemoved_;
63
64 /** Accessor function to the registry that ensures we can still
65 get it, which we always should be able to, but in case. */
66 std::shared_ptr<Registry::Impl> getReg();
67
68 private:
69 /** Pointer to our implementing registry */
70 std::weak_ptr<Registry::Impl> registry_;
71 };
72
73 } // namespace info_watcher
74 } // namespace app_launch
75 } // namespace lomiri