Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Runtime.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 #ifndef UNITY_SCOPES_RUNTIME_H
20 #define UNITY_SCOPES_RUNTIME_H
21 
22 #include <unity/scopes/ObjectProxyFwd.h>
23 #include <unity/scopes/RegistryProxyFwd.h>
24 #include <unity/util/DefinesPtrs.h>
25 #include <unity/util/NonCopyable.h>
26 
27 #include <string>
28 
29 namespace unity
30 {
31 
32 namespace scopes
33 {
34 
35 class ScopeBase;
36 
37 namespace internal
38 {
39 class RuntimeImpl;
40 }
41 
55 class Runtime
56 {
57 public:
59  NONCOPYABLE(Runtime);
60  UNITY_DEFINES_PTRS(Runtime);
62 
77  // TODO: Update above to state what the default configuration is exactly
78  static UPtr create(std::string const& configfile = "");
79 
80  static UPtr create_scope_runtime(std::string const& scope_id, std::string const& configfile = "");
81 
89  void destroy();
90 
97  RegistryProxy registry() const;
98 
107  void run_scope(ScopeBase *const scope_base, std::string const& scope_ini_file);
108 
109  // TODO: Flesh out documentation for this, especially syntax.
123  ObjectProxy string_to_proxy(std::string const& s) const;
124 
136  std::string proxy_to_string(ObjectProxy const& proxy) const;
137 
144  ~Runtime();
145 
146 private:
147  Runtime(std::string const& scope_id, std::string const& configfile); // Instantiation only via create()
148 
149  std::unique_ptr<internal::RuntimeImpl> p;
150 };
151 
152 } // namespace scopes
153 
154 } // namespace unity
155 
156 #endif
~Runtime()
Destroys a Runtime instance.
void destroy()
Shuts down the run time, reclaiming all associated resources.
Definition: Runtime.cpp:55
Base class for a scope implementation.
Definition: ScopeBase.h:136
ObjectProxy string_to_proxy(std::string const &s) const
Convert a string to a proxy.
Definition: Runtime.cpp:70
static UPtr create(std::string const &configfile="")
Instantiates the scopes run time for a client with the given (optional) configuration file...
Definition: Runtime.cpp:44
The main object for query originators to access the scopes run time.
Definition: Runtime.h:55
void run_scope(ScopeBase *const scope_base, std::string const &scope_ini_file)
Run a scope without going through the scope runner.
Definition: Runtime.cpp:65
std::string proxy_to_string(ObjectProxy const &proxy) const
Converts a proxy to a string.
Definition: Runtime.cpp:75
RegistryProxy registry() const
Returns a proxy to the Registry object.
Definition: Runtime.cpp:60
std::shared_ptr< Registry > RegistryProxy
Convenience type definition.
Definition: RegistryProxyFwd.h:34
std::shared_ptr< Object > ObjectProxy
Convenience type definition for the proxy inheritance root.
Definition: ObjectProxyFwd.h:34