OSVR-Core
RegistrationContext.h
Go to the documentation of this file.
1 
12 // Copyright 2014 Sensics, Inc.
13 //
14 // Licensed under the Apache License, Version 2.0 (the "License");
15 // you may not use this file except in compliance with the License.
16 // You may obtain a copy of the License at
17 //
18 // http://www.apache.org/licenses/LICENSE-2.0
19 //
20 // Unless required by applicable law or agreed to in writing, software
21 // distributed under the License is distributed on an "AS IS" BASIS,
22 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 // See the License for the specific language governing permissions and
24 // limitations under the License.
25 
26 #ifndef INCLUDED_RegistrationContext_h_GUID_9FF83E64_B2E1_40B7_E072_929AC0F94A10
27 #define INCLUDED_RegistrationContext_h_GUID_9FF83E64_B2E1_40B7_E072_929AC0F94A10
28 
29 // Internal Includes
31 #include <osvr/Util/SharedPtr.h>
32 #include <osvr/Util/UniquePtr.h>
33 #include <osvr/Util/AnyMap.h>
34 #include <osvr/Util/Log.h>
35 #include <osvr/PluginHost/Export.h>
37 
38 // Library/third-party includes
39 #include <boost/noncopyable.hpp>
40 
41 // Standard includes
42 #include <string>
43 #include <map>
44 
45 namespace osvr {
49 namespace pluginhost {
50 
53  class RegistrationContext : boost::noncopyable {
54  public:
56  OSVR_PLUGINHOST_EXPORT RegistrationContext();
57 
60  OSVR_PLUGINHOST_EXPORT ~RegistrationContext();
61 
65  OSVR_PLUGINHOST_EXPORT void loadPlugin(std::string const &pluginName);
66 
69  OSVR_PLUGINHOST_EXPORT void loadPlugins();
70 
73  OSVR_PLUGINHOST_EXPORT void
75 
77  OSVR_PLUGINHOST_EXPORT void triggerHardwareDetect();
78 
84  OSVR_PLUGINHOST_EXPORT void
85  instantiateDriver(const std::string &pluginName,
86  const std::string &driverName,
87  const std::string &params = std::string()) const;
88 
90  OSVR_PLUGINHOST_EXPORT util::AnyMap &data();
91 
93  OSVR_PLUGINHOST_EXPORT util::AnyMap const &data() const;
95 
96  private:
99  typedef std::map<std::string, PluginRegPtr> PluginRegMap;
100 
101  PluginRegMap m_regMap;
102  util::AnyMap m_data;
103  struct Impl;
105  unique_ptr<Impl> m_impl;
106  util::log::LoggerPtr m_logger;
107  };
108 } // namespace pluginhost
109 } // namespace osvr
110 
111 #endif // INCLUDED_RegistrationContext_h_GUID_9FF83E64_B2E1_40B7_E072_929AC0F94A10
OSVR_PLUGINHOST_EXPORT RegistrationContext()
basic constructor
Definition: RegistrationContext.cpp:66
Class responsible for hosting plugins, along with their registration and destruction.
Definition: RegistrationContext.h:53
OSVR_PLUGINHOST_EXPORT void loadPlugins()
Load all detected plugins except those with a .manualload suffix.
Definition: RegistrationContext.cpp:158
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Header to bring unique_ptr into the osvr namespace.
Header for basic internal log reference.
Header to bring shared_ptr into the osvr namespace.
OSVR_PLUGINHOST_EXPORT ~RegistrationContext()
Destructor responsible for destroying plugins in reverse order.
Definition: RegistrationContext.cpp:70
A data structure storing "any" by name, to reduce coupling.
Definition: AnyMap.h:42
Definition: RegistrationContext.cpp:59
OSVR_PLUGINHOST_EXPORT void adoptPluginRegistrationContext(PluginRegPtr ctx)
Assume ownership of a plugin-specific registration context created and initialized outside of loadPlu...
Definition: RegistrationContext.cpp:210
OSVR_PLUGINHOST_EXPORT util::AnyMap & data()
Access the data storage map.
Definition: RegistrationContext.cpp:236
Header declaring the osvr::util::AnyMap structure.
OSVR_PLUGINHOST_EXPORT void triggerHardwareDetect()
Trigger any registered hardware detect callbacks.
Definition: RegistrationContext.cpp:218
shared_ptr< PluginSpecificRegistrationContextImpl > PluginRegPtr
Pointer with ownership semantics for cleanup of plugins.
Definition: PluginRegPtr.h:33
OSVR_PLUGINHOST_EXPORT void instantiateDriver(const std::string &pluginName, const std::string &driverName, const std::string &params=std::string()) const
Call a driver instantiation callback for the given plugin name and driver name.
Definition: RegistrationContext.cpp:225
Header forward-declaring RegistrationContext.