Unity Scopes API
Registry.h
1 /*
2  * Copyright (C) 2013 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Michi Henning <michi.henning@canonical.com>
17  */
18 
19 #pragma once
20 
21 #include <core/signal.h>
22 #include <unity/scopes/Object.h>
23 #include <unity/scopes/RegistryProxyFwd.h>
24 #include <unity/scopes/Scope.h>
25 #include <unity/scopes/ScopeMetadata.h>
26 
27 #include <map>
28 
29 namespace unity
30 {
31 
32 namespace scopes
33 {
34 
35 namespace internal
36 {
37 class RegistryImpl;
38 }
39 
43 typedef std::map<std::string, ScopeMetadata> MetadataMap;
44 
51 class Registry : public virtual Object
52 {
53 public:
55  virtual ~Registry();
57 
64  virtual ScopeMetadata get_metadata(std::string const& scope_id) = 0;
65 
70  virtual MetadataMap list() = 0;
71 
77  virtual MetadataMap list_if(std::function<bool(ScopeMetadata const& item)> predicate) = 0;
78 
85  virtual bool is_scope_running(std::string const& scope_id) = 0;
86 
93  virtual core::ScopedConnection set_scope_state_callback(std::string const& scope_id, std::function<void(bool is_running)> callback) = 0;
94 
103  virtual core::ScopedConnection set_list_update_callback(std::function<void()> callback) = 0;
104 
105 protected:
107  Registry();
109 };
110 
111 } // namespace scopes
112 
113 } // namespace unity
virtual core::ScopedConnection set_scope_state_callback(std::string const &scope_id, std::function< void(bool is_running)> callback)=0
Assigns a callback method to be executed when a scope's running state (started / stopped) changes...
virtual core::ScopedConnection set_list_update_callback(std::function< void()> callback)=0
Assigns a callback method to be executed when the registry's scope list changes.
virtual MetadataMap list()=0
Returns a map containing the metadata for all scopes.
virtual bool is_scope_running(std::string const &scope_id)=0
Returns whether a scope is currently running or not.
Holds scope attributes such as name, description, icon etc.
Definition: ScopeMetadata.h:51
virtual MetadataMap list_if(std::function< bool(ScopeMetadata const &item)> predicate)=0
Returns a map containing only those scopes for which predicate returns true.
Top-level namespace for all things Unity-related.
Definition: Version.h:49
White pages service for available scopes.
Definition: Registry.h:51
Definition: ActionMetadata.h:31
virtual ScopeMetadata get_metadata(std::string const &scope_id)=0
Returns the metadata for the scope with the given ID.
The root base class for all proxies.
Definition: Object.h:34
std::map< std::string, ScopeMetadata > MetadataMap
Map for scope ID and metadata pairs.
Definition: Registry.h:43