OSVR-Core
Classes | Typedefs | Enumerations | Functions
osvr::server Namespace Reference

Server functionality. More...

Classes

class  ConfigureServer
 A class used for step-by-step construction and configuration of a server. More...
 
class  ConfigureServerData
 
struct  FileLoadAttempt
 
struct  ResolveRefResult
 
class  Server
 Class handling a run-loop with a registration context and connection. More...
 
struct  ServerCreationFailure
 
class  ServerImpl
 Private implementation class for Server. More...
 
class  TemporaryThreadIDChanger
 Class to temporarily (in RAII style) change a thread ID variable to the current thread, then back again when we leave scope. More...
 

Typedefs

typedef void(* ShutdownHandler) ()
 The type of a shutdown handler callback.
 
typedef std::function< void()> MainloopMethod
 A function that can be registered by the server app to run in each mainloop iteration. More...
 
typedef shared_ptr< ServerServerPtr
 How one should hold a Server.
 
typedef weak_ptr< ServerServerWeakPtr
 How one might observe a Server without owning it.
 
using FileLoadAttempts = std::vector< FileLoadAttempt >
 

Enumerations

enum  FileLoadStatus { CouldNotOpenFile, CouldNotParseFile, FileOpenedAndParsed }
 
enum  ValueHandledAs { Filename, String, JsonRefToFile, Other }
 

Functions

OSVR_SERVER_EXPORT std::vector< std::string > getConfigDirectories ()
 Get list of directories to search for config files.
 
OSVR_SERVER_EXPORT std::vector< std::string > getDefaultConfigFilePaths ()
 this returns a vector of default server configuration file paths.
 
OSVR_SERVER_EXPORT std::vector< std::string > getCandidateConfigFilePaths (std::string const &inputFilename)
 given a input filename/path, returns potential full paths from combining relative input paths with potential config file locations. More...
 
const char * getDefaultConfigFilename ()
 
OSVR_SERVER_EXPORT ServerPtr configureServerFromFile (std::string const &configName)
 This uses a file name to attempt to configure the server with that config file. More...
 
OSVR_SERVER_EXPORT ServerPtr configureServerFromString (std::string const &json)
 
OSVR_SERVER_EXPORT ServerPtr configureServerFromFirstFileInList (std::vector< std::string > const &configNames)
 This iterates over a vector that contains a list of potential config files, and uses the first working one to create the server instance. More...
 
void printJsonReferenceResolutionAttempts (ResolveRefResult const &refReturn)
 
void reportErrorInJsonReferenceParsing (const char *description, Json::Value const &input, ResolveRefResult const &refReturn)
 
void debugDumpSearchPath (::osvr::util::log::LoggerPtr log)
 
ServerPtr internalConfigureServerFromFile (std::string const &configName, ::osvr::util::log::LoggerPtr log)
 
ResolveRefResult resolvePossibleRefWithDetails (Json::Value const &input, bool stringAcceptableResult, std::vector< std::string > const &searchPath)
 
Json::Value resolvePossibleRef (Json::Value const &input, bool stringAcceptableResult=false, std::vector< std::string > const &searchPath=getConfigDirectories())
 Given an input that might be a filename, might be a JSON Pointer-style $ref object, and might just directly be an object, return the object desired. More...
 
const char * fileLoadStatusToString (FileLoadStatus status)
 

Detailed Description

Server functionality.

Typedef Documentation

§ MainloopMethod

typedef std::function<void()> osvr::server::MainloopMethod

A function that can be registered by the server app to run in each mainloop iteration.

Function Documentation

§ configureServerFromFile()

ServerPtr osvr::server::configureServerFromFile ( std::string const &  configName)

This uses a file name to attempt to configure the server with that config file.

Pass an empty string to use the default config. This is the basic common code of a server app's setup, ripped out of the main server app to make alternate server-acting apps simpler to develop.

§ configureServerFromFirstFileInList()

ServerPtr osvr::server::configureServerFromFirstFileInList ( std::vector< std::string > const &  configNames)

This iterates over a vector that contains a list of potential config files, and uses the first working one to create the server instance.

§ getCandidateConfigFilePaths()

std::vector< std::string > osvr::server::getCandidateConfigFilePaths ( std::string const &  inputFilename)

given a input filename/path, returns potential full paths from combining relative input paths with potential config file locations.

§ resolvePossibleRef()

Json::Value osvr::server::resolvePossibleRef ( Json::Value const &  input,
bool  stringAcceptableResult = false,
std::vector< std::string > const &  searchPath = getConfigDirectories() 
)

Given an input that might be a filename, might be a JSON Pointer-style $ref object, and might just directly be an object, return the object desired.

If just a string (suggesting it was intended to be a reference), returns null.

Parameters
stringAcceptableResultDetermines whether a string that we can't resolve to a loadable JSON reference should be returned as itself (valid, true), or should be signaled as an error by returning null (false, default)
searchPathOptional list of directories to look for any mentioned files.

This function is the same as "withDetails", just less rich.

§ resolvePossibleRefWithDetails()

ResolveRefResult osvr::server::resolvePossibleRefWithDetails ( Json::Value const &  input,
bool  stringAcceptableResult,
std::vector< std::string > const &  searchPath 
)
Todo:
remove things after the filename in the ref.