OSVR-Core
Public Types | Public Member Functions | List of all members
osvr::server::ConfigureServer Class Reference

A class used for step-by-step construction and configuration of a server. More...

#include <ConfigureServer.h>

Inheritance diagram for osvr::server::ConfigureServer:

Public Types

typedef std::vector< std::string > SuccessList
 Container for plugin/driver names.
 
typedef std::pair< std::string, std::string > ErrorPair
 Error information with attribution: .first field is plugin/driver name, .second field is exception text.
 
typedef std::vector< ErrorPairErrorList
 Container for plugin/driver names and error messages.
 

Public Member Functions

OSVR_SERVER_EXPORT ConfigureServer ()
 Constructor.
 
OSVR_SERVER_EXPORT ~ConfigureServer ()
 Destructor. More...
 
OSVR_SERVER_EXPORT void loadConfig (std::string const &json)
 Loads and parses the provided json. More...
 
OSVR_SERVER_EXPORT void loadConfig (std::istream &json)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
OSVR_SERVER_EXPORT ServerPtr constructServer ()
 Creates a server, choosing the factory method according to the passed JSON configuration. More...
 
OSVR_SERVER_EXPORT bool loadPlugins ()
 Loads the plugins contained in an array with key plugins in the configuration. More...
 
OSVR_SERVER_EXPORT bool instantiateDrivers ()
 Configures and instantiates the drivers as specified. More...
 
OSVR_SERVER_EXPORT bool processRoutes ()
 
OSVR_SERVER_EXPORT bool processAliases ()
 
OSVR_SERVER_EXPORT bool processExternalDevices ()
 Process any external devices in the config. More...
 
OSVR_SERVER_EXPORT bool processDisplay ()
 Process a display element in the config. More...
 
OSVR_SERVER_EXPORT bool processRenderManagerParameters ()
 Process a RenderManager config element in the config. More...
 
OSVR_SERVER_EXPORT void loadAutoPlugins ()
 Loads all plugins not marked for manual load.
 
Results of loadPlugins()

Get a reference to the list of plugins successfully loaded by loadPlugins()

OSVR_SERVER_EXPORT SuccessList const & getSuccessfulPlugins () const
 
OSVR_SERVER_EXPORT ErrorList const & getFailedPlugins () const
 Get a reference to the list of plugins loadPlugins() tried but failed to load, along with any exception text. More...
 
Results of instantiateDrivers()

Get a reference to the list of drivers successfully instantiated by instantiateDrivers()

OSVR_SERVER_EXPORT SuccessList const & getSuccessfulInstantiations () const
 
OSVR_SERVER_EXPORT ErrorList const & getFailedInstantiations () const
 Get a reference to the list of drivers instantiateDrivers() tried to instantiate but failed, along with any exception text. More...
 

Detailed Description

A class used for step-by-step construction and configuration of a server.

For full configuration, run each named method, one by one, in the order they're seen in the header. (You only need to run one overload for each name)

Constructor & Destructor Documentation

§ ~ConfigureServer()

osvr::server::ConfigureServer::~ConfigureServer ( )

Destructor.

Must be in implementation file to handle deletion of private data class.

Member Function Documentation

§ constructServer()

ServerPtr osvr::server::ConfigureServer::constructServer ( )

Creates a server, choosing the factory method according to the passed JSON configuration.

It first looks for an object under the server key - if not present, it will assume defaults for below. This object is the context for the below elements.

If interface is defined, it will open a server on that interface (with an empty string meaning all interfaces)

Otherwise, local is assumed to be true. If it is false, it will open on all interfaces.

port defaults to the assigned VRPN port (3883)

Exceptions
std::out_of_rangeif an invalid port (<1) is specified.

Extract data from the JSON structure.

Todo:
Detect/report invalid or contradictory options here.

Construct a server, or a connection then a server, based on the configuration we've extracted.

§ getFailedInstantiations()

ConfigureServer::ErrorList const & osvr::server::ConfigureServer::getFailedInstantiations ( ) const

Get a reference to the list of drivers instantiateDrivers() tried to instantiate but failed, along with any exception text.

§ getFailedPlugins()

ConfigureServer::ErrorList const & osvr::server::ConfigureServer::getFailedPlugins ( ) const

Get a reference to the list of plugins loadPlugins() tried but failed to load, along with any exception text.

§ instantiateDrivers()

bool osvr::server::ConfigureServer::instantiateDrivers ( )

Configures and instantiates the drivers as specified.

Looks for an array with the key of drivers, containing an array of objects. Each object is an instantiation, specifying driver, plugin, and params to pass along. params is typically nested JSON data.

Detailed results of the loading can be retrieved with getSuccessfulInstantiations() and getSuccessfulInstantiations()

Returns
true if and only if all specified driver instances completed successfully.

§ loadConfig() [1/2]

void osvr::server::ConfigureServer::loadConfig ( std::string const &  json)

Loads and parses the provided json.

Exceptions
std::runtime_errorif parsing errors occur. json A string containing json configuration

§ loadConfig() [2/2]

void osvr::server::ConfigureServer::loadConfig ( std::istream &  json)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

json A stream containing json configuration

§ loadPlugins()

bool osvr::server::ConfigureServer::loadPlugins ( )

Loads the plugins contained in an array with key plugins in the configuration.

Detailed results of the loading can be retrieved with getSuccessfulPlugins() and getFailedPlugins()

Returns
true if and only if all specified plugins loaded successfully.

§ processDisplay()

bool osvr::server::ConfigureServer::processDisplay ( )

Process a display element in the config.

Returns
true if one was found and it was successfully loaded.
Todo:
don't style this string!

§ processExternalDevices()

bool osvr::server::ConfigureServer::processExternalDevices ( )

Process any external devices in the config.

Returns
true if any were found and loaded.

§ processRenderManagerParameters()

bool osvr::server::ConfigureServer::processRenderManagerParameters ( )

Process a RenderManager config element in the config.

Returns
true if one was found and it was successfully loaded.
Todo:
don't style this string!

The documentation for this class was generated from the following files: