- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | List of all members
qi::ApplicationSession Class Reference

`#include <applicationsession.hpp>`

## Classes
class | Config

## Public Types
enum | Option { Option_None = 0, Option_NoAutoExit = 1 }

## Public Member Functions
| ApplicationSession (int &argc, char **&argv, int opt=0, const Url &defaultUrl=SessionConfig::defaultConnectUrl())
| Constructors of the class. More...
| ApplicationSession (const std::string &name, int &argc, char **&argv, int opt=0, const Url &defaultUrl=SessionConfig::defaultConnectUrl())
| ApplicationSession (int &argc, char **&argv, const Config &defaultConfig)
virtual | ~ApplicationSession ()
SessionPtr | session () const
const Config & | config () const
Url | url () const
Url | listenUrl () const
std::vector< Url > | allListenUrl () const
void | start ()
void | startSession ()
void | run ()
bool | standAlone ()
std::string | helpText () const
Public Member Functions inherited from qi::Application
| Application (int &argc, char **&argv, const std::string &name="", const std::string &path="")
| Application constructor. Must be the first thing called by main(). More...
| Application (const std::string &name, int &argc, char **&argv)
| Application constructor. Must be the first thing called by main(). More...
| ~Application ()
| Application destructor. It executes atExit() callbacks. More...
| Application (const Application &)=delete
Application & | operator= (const Application &)=delete

## Additional Inherited Members
Static Public Member Functions inherited from qi::Application
static void | run ()
| Wait until the end of the program. More...
static void | stop ()
| Stop the application. Call all atStop handlers. More...
static const std::vector < std::string > & | arguments ()
| Get arguments of the program as an std::vector of std::string. More...
static int | argc ()
| Get argument counter of the program. More...
static const char ** | argv ()
| Get string arguments of the program (including program name). More...
static void | setName (const std::string &name)
| Set application name. More...
static std::string | name ()
| Get application name. More...
static void | setArguments (int argc, char **argv)
| Set arguments of the program with argc as argument counter and argv as argument values. More...
static void | setArguments (const std::vector< std::string > &arguments)
| Set arguments ot the program as an std::vector of std::string. More...
static void * | loadModule (const std::string &name, int flags=-1)
| Load a module into the current process. More...
static void | unloadModule (void *handle)
| Unload a module from the current process. More...
static bool | terminated ()
| Check whether the Application instance is terminated or not. More...
static bool | initialized ()
| Check whether the Application instance was initialized or not. More...
static const char * | program ()
| Return the current program full path according to argv[0]. More...
static const char * | realProgram ()
| Return the current program full path. More...
static const char * | _suggestedSdkPath ()
| Return the SDK path given through –qi-sdk-prefix or QI_SDK_PREFIX. More...
static bool | atEnter (std::function< void()> func)
| Register a function to be executed at Application creation. More...
static bool | atExit (std::function< void()> func)
| Register a function to be executed at Application destruction. More...
static bool | atRun (std::function< void()> func)
| Register a function to be executed when run() is called. The functions are executed sequentially at the beginning of run(). More...
static bool | atStop (std::function< void()> func)
| Register a function to be executed when stop() is called. The functions are executed sequentially before run() returns. More...
static bool | atSignal (std::function< void(int)> func, int signal)
| Register a function to be executed when a signal occurs. More...
static boost::program_options::options_description & | options ()
| Get the registered global program options. More...
static std::string | helpText ()

## Detailed Description

ApplicationSession is an application with an embedded session. The constructor has to be the first method called of the class to initialize the class. Be careful with the scope of the object, once the destructor is called, the session is destroyed as well.

Definition at line 26 of file applicationsession.hpp.

## Member Enumeration Documentation

enum qi::ApplicationSession::Option

By default, ApplicationSession will automatically call qi::Application::stop() when the session is over. If you want a different behaviour you have to call the constructor with the desired option below.

Ex: qi::ApplicationSession app(argc, argv, qi::ApplicationSession::Option_NoAutoExit)

Enumerator
Option_None | No option, this is the default behavior.
Option_NoAutoExit | With this option the application won't stop once the session is disconnected.

Definition at line 35 of file applicationsession.hpp.

## Constructor & Destructor Documentation

qi::ApplicationSession::ApplicationSession | ( | int & | argc,
|  | char **& | argv,
|  | int | opt = `0`,
|  | const Url & | defaultUrl = `SessionConfig::defaultConnectUrl()`
| ) |  |

Constructors of the class.

The session owned by the object can have two different modes: either standard or standalone.

To make an application session standalone, you need to specify the "--qi-standalone" option on the command line arguments or set the option in the configuration passed at the application construction.

A standard session must connect to a service directory, and therefore needs a URL to connect to. This URL is chosen from available values (the ones that have been specified) according to the following order:

- First the URL that was specified as "--qi-url <url>" in the command line arguments.
- Then the URL specified in the "QI_URL" environment variable.
- Finally the URL passed directly or as a member of the configuration to the constructor.

A standalone session cannot connect to a service directory but must instead listen on some URLs. A standard session can also listen, but will only do if the "--qi-listen-url" is given in the command line arguments or if a service is registered on it. In both cases, the URLs to listen on are chosen from available values (the ones that have been specified) according to the following order:

- First the URLs that were specified as "--qi-listen-url <urls>" in the command line arguments.
- Then the URLs specified in the "QI_LISTEN_URL" environment variable.
- Then the URLs in the configuration passed to the constructor.
- Finally the hardcoded default listen URL.

Both the "--qi-listen-url" command line argument and the "QI_LISTEN_URL" environment variable follow the same format "url1;url2;...", allowing the user to specify multiple values.

Parameters

  argc | The number of arguments.
  argv | The array containing all the arguments given to the program.
  opt | Either ApplicationSession::Option_None or ApplicationSession::Option_NoAutoExit. The default behavior of ApplicationSession is to call stop() once the session gets disconnected.

See Also
  qi::ApplicationSession::Option

Parameters

  defaultUrl | The default url used if no –qi-url was found in the command line arguments and no suitable QI_URL environment variable was defined.

qi::ApplicationSession::ApplicationSession | ( | const std::string & | name,
|  | int & | argc,
|  | char **& | argv,
|  | int | opt = `0`,
|  | const Url & | defaultUrl = `SessionConfig::defaultConnectUrl()`
| ) |  |

qi::ApplicationSession::ApplicationSession | ( | int & | argc,
|  | char **& | argv,
|  | const Config & | defaultConfig
| ) |  |

virtual qi::ApplicationSession::~ApplicationSession | ( |  | ) |
| virtual

## Member Function Documentation

std::vector<Url> qi::ApplicationSession::allListenUrl | ( |  | ) | const

Returns
  All the URLs used by ApplicationSession to listen on.

See Also
  qi::ApplicationSession::ApplicationSession for parsing information.

const Config& qi::ApplicationSession::config | ( |  | ) | const

std::string qi::ApplicationSession::helpText | ( |  | ) | const

Returns
  A concatenation of the ApplicationSession's –help with the Application's –help texts.

Url qi::ApplicationSession::listenUrl | ( |  | ) | const

Returns
  The first URL used by ApplicationSession to listen on.

See Also
  qi::ApplicationSession::ApplicationSession for parsing information.

void qi::ApplicationSession::run | ( |  | ) |

Runs the application and automatically calls start() if it hasn't been done yet.

SessionPtr qi::ApplicationSession::session | ( |  | ) | const

Returns
  The embedded session used by ApplicationSession.

bool qi::ApplicationSession::standAlone | ( |  | ) |

Returns whether the ApplicationSession runs in standalone mode.

void qi::ApplicationSession::start | ( |  | ) |

Establishes the session's connection and moreover starts listening if –qi-listen-url was given.

Deprecated:
  since 2.5, use startSession instead

void qi::ApplicationSession::startSession | ( |  | ) |

Establishes the session's connection and moreover starts listening if –qi-listen-url was given.

Url qi::ApplicationSession::url | ( |  | ) | const

Returns
  The URL used by ApplicationSession to connect to a service directory.

See Also
  qi::ApplicationSession::ApplicationSession for parsing information.

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

- /home/opennao/work/release-2.8/sdk/libqi/qi/applicationsession.hpp