OSVR-Core
ConfigureServer.h
Go to the documentation of this file.
1 
11 // Copyright 2014 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_ConfigureServer_h_GUID_9D9EE94F_8F85_42BE_AFDD_4AA7B0EFA566
26 #define INCLUDED_ConfigureServer_h_GUID_9D9EE94F_8F85_42BE_AFDD_4AA7B0EFA566
27 
28 // Internal Includes
29 #include <osvr/Server/Export.h>
30 #include <osvr/Server/ServerPtr.h>
31 #include <osvr/Util/UniquePtr.h>
32 
33 // Library/third-party includes
34 #include <boost/noncopyable.hpp>
35 
36 // Standard includes
37 #include <string>
38 #include <iosfwd>
39 #include <vector>
40 
41 namespace osvr {
42 namespace server {
44  class ConfigureServerData;
45 
52  class ConfigureServer : boost::noncopyable {
53  public:
55  OSVR_SERVER_EXPORT ConfigureServer();
56 
58  OSVR_SERVER_EXPORT ~ConfigureServer();
59 
63  OSVR_SERVER_EXPORT void loadConfig(std::string const &json);
66  OSVR_SERVER_EXPORT void loadConfig(std::istream &json);
67 
84  OSVR_SERVER_EXPORT ServerPtr constructServer();
85 
87  typedef std::vector<std::string> SuccessList;
88 
91  typedef std::pair<std::string, std::string> ErrorPair;
92 
94  typedef std::vector<ErrorPair> ErrorList;
95 
104  OSVR_SERVER_EXPORT bool loadPlugins();
105 
110  OSVR_SERVER_EXPORT SuccessList const &getSuccessfulPlugins() const;
111 
114  OSVR_SERVER_EXPORT ErrorList const &getFailedPlugins() const;
116 
129  OSVR_SERVER_EXPORT bool instantiateDrivers();
130 
135  OSVR_SERVER_EXPORT SuccessList const &
136  getSuccessfulInstantiations() const;
137 
140  OSVR_SERVER_EXPORT ErrorList const &getFailedInstantiations() const;
142 
143  OSVR_SERVER_EXPORT bool processRoutes();
144  OSVR_SERVER_EXPORT bool processAliases();
145 
148  OSVR_SERVER_EXPORT bool processExternalDevices();
149 
152  OSVR_SERVER_EXPORT bool processDisplay();
153 
156  OSVR_SERVER_EXPORT bool processRenderManagerParameters();
157 
159  OSVR_SERVER_EXPORT void loadAutoPlugins();
160 
161  private:
163  unique_ptr<ConfigureServerData> m_data;
164 
167  ServerPtr m_server;
168 
171  SuccessList m_successfulPlugins;
172  ErrorList m_failedPlugins;
174 
177  SuccessList m_successfulInstances;
178  ErrorList m_failedInstances;
180  };
181 } // namespace server
182 } // namespace osvr
183 
184 #endif // INCLUDED_ConfigureServer_h_GUID_9D9EE94F_8F85_42BE_AFDD_4AA7B0EFA566
OSVR_SERVER_EXPORT ~ConfigureServer()
Destructor.
Definition: ConfigureServer.cpp:92
A class used for step-by-step construction and configuration of a server.
Definition: ConfigureServer.h:52
OSVR_SERVER_EXPORT void loadConfig(std::string const &json)
Loads and parses the provided json.
Definition: ConfigureServer.cpp:94
Header.
OSVR_SERVER_EXPORT ErrorList const & getFailedPlugins() const
Get a reference to the list of plugins loadPlugins() tried but failed to load, along with any excepti...
Definition: ConfigureServer.cpp:207
OSVR_SERVER_EXPORT bool processDisplay()
Process a display element in the config.
Definition: ConfigureServer.cpp:347
OSVR_SERVER_EXPORT bool processRenderManagerParameters()
Process a RenderManager config element in the config.
Definition: ConfigureServer.cpp:375
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
std::vector< std::string > SuccessList
Container for plugin/driver names.
Definition: ConfigureServer.h:87
Header to bring unique_ptr into the osvr namespace.
OSVR_SERVER_EXPORT ServerPtr constructServer()
Creates a server, choosing the factory method according to the passed JSON configuration.
Definition: ConfigureServer.cpp:108
OSVR_SERVER_EXPORT void loadAutoPlugins()
Loads all plugins not marked for manual load.
Definition: ConfigureServer.cpp:402
OSVR_SERVER_EXPORT bool instantiateDrivers()
Configures and instantiates the drivers as specified.
Definition: ConfigureServer.cpp:215
std::vector< ErrorPair > ErrorList
Container for plugin/driver names and error messages.
Definition: ConfigureServer.h:94
OSVR_SERVER_EXPORT ConfigureServer()
Constructor.
Definition: ConfigureServer.cpp:89
std::pair< std::string, std::string > ErrorPair
Error information with attribution: .first field is plugin/driver name, .second field is exception te...
Definition: ConfigureServer.h:91
OSVR_SERVER_EXPORT ErrorList const & getFailedInstantiations() const
Get a reference to the list of drivers instantiateDrivers() tried to instantiate but failed...
Definition: ConfigureServer.cpp:273
OSVR_SERVER_EXPORT bool processExternalDevices()
Process any external devices in the config.
Definition: ConfigureServer.cpp:306
shared_ptr< Server > ServerPtr
How one should hold a Server.
Definition: ServerPtr.h:39
OSVR_SERVER_EXPORT bool loadPlugins()
Loads the plugins contained in an array with key plugins in the configuration.
Definition: ConfigureServer.cpp:175