Open Lighting Architecture: Initialization

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Files | Functions
Initialization

## Detailed Description

Functions called during program startup.

Programs using the OLA libraries should call either ServerInit() or AppInit(). There are also extra functions to help with installing signal handlers and daemonizing a process.

Example
  // For client applications
  AppInit(argc, argv);
  // For server applications
  ServerInit(argc, argv, &export_map);
  ola::AppInit
  bool AppInit(int *argc, char *argv[], const string &first_line, const string &description)
  Used to initialize a application. Installs the SEGV handler and initializes the random number generat...
  Definition Init.cpp:221
  ola::ServerInit
  bool ServerInit(int argc, char *argv[], ExportMap *export_map)
  Used to initialize a server.
  Definition Init.cpp:190

## Files
file | Init.cpp
file | Init.h
| Functions called during program startup.

## Functions
bool | ola::ServerInit (int argc, char *argv[], ExportMap *export_map)
| Used to initialize a server.
bool | ola::ServerInit (int *argc, char *argv[], ExportMap *export_map, const std::string &first_line, const std::string &description)
| Used to initialize a server. Installs the SEGV handler, initializes the random number generator and populates the export map. Also sets the help string for the program, parses flags and initialises logging from flags.
bool | ola::AppInit (int *argc, char *argv[], const std::string &first_line, const std::string &description)
| Used to initialize a application. Installs the SEGV handler and initializes the random number generator, sets the help string for the program, parses flags and initialises logging from flags.
bool | ola::NetworkInit ()
| Perform platform-specific initialization of the networking subsystem.
bool | ola::InstallSignal (int signal, void(*fp)(int signo))
| Install a signal handler.
bool | ola::InstallSEGVHandler ()
| Install signal handlers to deal with SIGBUS & SIGSEGV.
void | ola::InitExportMap (int argc, char *argv[], ExportMap *export_map)
| Populate the ExportMap with a couple of basic variables.
void | ola::Daemonise ()
| Run as a daemon.
void | ola::ClockInit ()
| Logs status of clock capabilities.

## Function Documentation

## ◆ AppInit()

bool ola::AppInit | ( | int * | argc,
|  | char * | argv[],
|  | const std::string & | first_line,
|  | const std::string & | description )

Used to initialize a application. Installs the SEGV handler and initializes the random number generator, sets the help string for the program, parses flags and initialises logging from flags.

Parameters

  argc | argument count
  argv | pointer to the argument strings
  first_line | the initial line that is displayed in the help section. This is displayed after argv[0].
  description | a multiline description of the program

Returns
  true on success and false otherwise

Note
  If you are a server then call ServerInit() instead.

See also
  ola::SetHelpString ola::ParseFlags ola::InitLoggingFromFlags

## ◆ Daemonise()

void ola::Daemonise | ( |  | ) |

Run as a daemon.

Daemonize logs messages if it fails, so it's best to initialize the logging system (ola::InitLogging) before calling. However Daemonize() closes all open file descriptors so stdout/stderr will point to /dev/null in the daemon process. Therefore daemons should always use syslog logging.

If we can't daemonize the process is terminated.

See logging.

See also
  Logging

## ◆ InitExportMap()

void ola::InitExportMap | ( | int | argc,
|  | char * | argv[],
|  | ExportMap * | export_map )

Populate the ExportMap with a couple of basic variables.

Parameters

  argc | argument count
  argv | pointer to the argument strings
  export_map | ExportMap to populate

This is called by ServerInit(). It sets the following variables:

- binary: name of the binary.
- cmd-line: command line used to start the binary
- fd-limit: the max number of file descriptors

## ◆ InstallSEGVHandler()

bool ola::InstallSEGVHandler | ( |  | ) |

Install signal handlers to deal with SIGBUS & SIGSEGV.

Returns
  true on success and false otherwise

On receiving a SIGBUS or SIGSEGV a stack trace will be printed.

## ◆ InstallSignal()

bool ola::InstallSignal | ( | int | signal,
|  | void(* | fp )(int signo) )

Install a signal handler.

Parameters

  signal | the signal number to catch
  fp | is a function pointer to the handler

Returns
  true on success and false otherwise

## ◆ NetworkInit()

bool ola::NetworkInit | ( |  | ) |

Perform platform-specific initialization of the networking subsystem.

This method is called by ServerInit() and AppInit(), so you only need to call this yourself if you're not using those.

Returns
  true on success and false otherwise

## ◆ ServerInit() [1/2]

bool ola::ServerInit | ( | int * | argc,
|  | char * | argv[],
|  | ExportMap * | export_map,
|  | const std::string & | first_line,
|  | const std::string & | description )

Used to initialize a server. Installs the SEGV handler, initializes the random number generator and populates the export map. Also sets the help string for the program, parses flags and initialises logging from flags.

Parameters

  argc | argument count
  argv | pointer to argument strings
  export_map | an optional pointer to an ExportMap
  first_line | the initial line that is displayed in the help section. This is displayed after argv[0].
  description | a multiline description of the program

Returns
  true on success and false otherwise

Note
  If you are a client/application then call AppInit() instead.

See also
  ola::SetHelpString ola::ParseFlags ola::InitLoggingFromFlags

## ◆ ServerInit() [2/2]

bool ola::ServerInit | ( | int | argc,
|  | char * | argv[],
|  | ExportMap * | export_map )

Used to initialize a server.

Parameters

  argc | argument count
  argv | pointer to argument strings
  export_map | an optional pointer to an ExportMap

Returns
  true on success and false otherwise

Note
  If you are a client/application then call AppInit() instead.

This does the following:

- installs the SEGV handler
- initializes the random number generator
- sets the thread scheduling options
- populates the export map
- initializes the network stack (Windows only).