libqi-api  release-2.5.3-2016-11-18
 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 &url="tcp://127.0.0.1:9559")
 
 ApplicationSession (const std::string &name, int &argc, char **&argv, int opt=0, const Url &url="tcp://127.0.0.1:9559")
 
 ApplicationSession (int &argc, char **&argv, const Config &defaultConfig)
 
virtual ~ApplicationSession ()
 
SessionPtr session ()
 
Url url ()
 
Url listenUrl ()
 
void start ()
 
void startSession ()
 
void run ()
 
- 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...
 

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...
 

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

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 url = "tcp://127.0.0.1:9559" 
)

ApplicationSession will check first if there is a –qi-url given in argv, if not it will take the url in the constructor instead setting its url. If –qi-listen-url is set the session will listen on the provided url.

Parameters
argcThe number of arguments.
argvThe array containing all the arguments given to the program.
optEither 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
urlThe default url used if no –qi-url was found in the options.
listenUrlThe default url used if no –qi-listen-url was found in the options.
qi::ApplicationSession::ApplicationSession ( const std::string &  name,
int &  argc,
char **&  argv,
int  opt = 0,
const Url url = "tcp://127.0.0.1:9559" 
)
qi::ApplicationSession::ApplicationSession ( int &  argc,
char **&  argv,
const Config defaultConfig 
)
virtual qi::ApplicationSession::~ApplicationSession ( )
virtual

Member Function Documentation

Url qi::ApplicationSession::listenUrl ( )
Returns
The url used by ApplicationSession parsed on the command line by –qi-listen-url, otherwise the default url given in the constructor.
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 ( )
Returns
The embedded session used by ApplicationSession.
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 ( )
Returns
The url used by ApplicationSession parsed on the command line by –qi-url if specified, otherwise the default url given in the constructor.
See Also
qi::ApplicationSession::ApplicationSession for parsing information.

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