|
|
|
|
Documentation |
|
Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages Search
NLNET::IService Class ReferenceBase class for all network services.
More...
#include <service.h>
List of all members.
get methods. These methods provide a way to read internal service variables. |
const std::string & | getServiceShortName () const |
| Returns the current service short name (ie: TS). More...
|
const std::string & | getServiceLongName () const |
| Returns the current service long name (ie: test_serivce). More...
|
const std::string & | getServiceAliasName () const |
| Returns the current service alias name setted by AES. More...
|
std::string | getServiceUnifiedName () const |
| Returns the current service unified name that is alias/short-id or short-id if alias is empty. More...
|
TServiceId | getServiceId () const |
| Returns the service identifier. More...
|
sint | getStatus () const |
| Returns the status. More...
|
const std::vector< std::string > & | getArgs () const |
| Returns arguments of the program pass from the user to the program using parameters (ie: "myprog param1 param2"). More...
|
bool | haveArg (char argName) |
| Returns true if the argument if present in the command line (ie: haveArg('p') will return true if -p is in the command line). More...
|
std::string | getArg (char argName) |
| Returns the parameter linked to an option (ie: getArg('p') will return "toto" if -ptoto is in the command line) It'll thrown an Exception if the argName is not found. More...
|
uint64 | getEntityId (uint8 Type) |
| Returns an uniq id for an entities on this service. More...
|
CCallbackServer * | getServer () |
| Returns a pointer to the CCallbackServer object. More...
|
CCallbackNetBase::TRecordingState | getRecordingState () const |
| Returns the recording state (don't needed if you use layer5). More...
|
IService * | IService::getInstance () |
| Returns the instance of the service to access to methods/variables class. More...
|
variables. These variables can be read/modified by the user. |
void | setStatus (sint status) |
| Sets the status of the service, this status is return to the application. More...
|
void | exit (sint code=0x10) |
| Call this function if you want the service quits next loop. More...
|
void | setUpdateTimeout (NLMISC::TTime timeout) |
| Selects timeout value in seconds for each update. More...
|
NLMISC::CConfigFile | ConfigFile |
variables. These variables are used by the internal system. |
std::vector< std::string > | _Args |
| Array of arguments pass from the command line. More...
|
uint16 | _Port |
| Listening port of this service. More...
|
CCallbackNetBase::TRecordingState | _RecordingState |
| Recording state. More...
|
std::string | _ShortName |
| Current service name sets by the actual service when declaring NLNET_SERVICE_MAIN. More...
|
std::string | _LongName |
std::string | _AliasName |
NLMISC::TTime | _UpdateTimeout |
| Select timeout value in milliseconds between to call of user update(). More...
|
TServiceId | _SId |
| the service id of this sevice. More...
|
sint | _Status |
| the status of this service (the status is give to the at the release time). More...
|
bool | _Initialized |
| true if the service initialisation is passed. More...
|
NLMISC::CEntityId | _NextEntityId |
| This variable is used to generate uniq id for entities on this service. More...
|
std::string | _ConfigDir |
| The directory where the configfile is. More...
|
std::string | _LogDir |
| The directory where the logfiles are. More...
|
std::string | _RunningPath |
| The directory where the service is running. More...
|
std::string | _Version |
TUnifiedCallbackItem * | _CallbackArray |
uint | _CallbackArraySize |
bool | _DontUseNS |
| true if the service don't use the naming service. More...
|
bool | _DontUseAES |
| true if the service don't use the admin executor service. More...
|
bool | _ResetMeasures |
| Require to reset the hierarchical timer. More...
|
IService * | _Instance = NULL |
| Instance of this service (singleton). More...
|
Public Methods |
void | setVersion (const std::string &version) |
|
virtual void | init () |
| Initializes the service (must be called before the first call to update()). More...
|
virtual bool | update () |
| This function is called every "frame" (you must call init() before). It returns false if the service is stopped. More...
|
virtual void | release () |
| Finalization. Release the service. For example, this founction free all allocation made in the init() function. More...
|
|
sint | main (const char *serviceShortName, const char *serviceLongName, uint16 servicePort, const char *configDir, const char *logDir) |
| This main is called by the macro (service5 says if we have to use layer5 or not). More...
|
void | setArgs (int argc, const char **argv) |
| Sets the command line and init _Args variable. You must call this before calling main(). More...
|
void | setArgs (const char *args) |
| Sets the command line and init _Args variable. You must call this before calling main(). More...
|
void | setCallbackArray (TUnifiedCallbackItem *array, uint nbelem) |
| Sets the default callback array given from the macro. More...
|
void | requireResetMeasures () |
| Require to reset the hierarchical timer. More...
|
| IService () |
| Ctor. You must not inherit ctor but overload init() function. More...
|
virtual | ~IService () |
| Dtor. You must not inherit dtor but overload release() function. More...
|
Public Attributes |
NLMISC::CWindowDisplayer * | WindowDisplayer |
| The window displayer instance. More...
|
std::string | WriteFilesDirectory |
| Directory where to store files that the services will write (for example, packet_sheets). More...
|
Private Methods |
|
void | setRecordingState (CCallbackNetBase::TRecordingState rec) |
| Changes the recording state (use if you know what you are doing). More...
|
Friends |
struct | serviceInfoClass |
struct | getWinDisplayerInfoClass |
void | serviceGetView (uint32 rid, const std::string &rawvarpath, std::vector< std::string > &vara, std::vector< std::string > &vala) |
void | AESConnection (const std::string &serviceName, uint16 sid, void *arg) |
Detailed Description
Base class for all network services.
You must inherite from this class to create your own service. You must not create ctor and dtor but implement init() and release() methods. You have to create a global callback array called CallbackArray.
How to create a service ?
Temporary command line arguments :
-
Author:
-
Vianney Lecroart , Olivier Cado , Nevrax France
-
Date:
-
2000
Definition at line 168 of file service.h.
Constructor & Destructor Documentation
NLNET::IService::IService |
( |
|
) |
|
|
virtual NLNET::IService::~IService |
( |
|
) |
[inline, virtual] |
|
|
Dtor. You must not inherit dtor but overload release() function.
Definition at line 293 of file service.h. |
Member Function Documentation
void NLNET::IService::exit |
( |
sint |
code = 0x10 |
) |
|
|
|
Call this function if you want the service quits next loop.
The code will be returned outside of the application. -
Warning:
-
If you set the code to 0, it ll NOT exit the service
Definition at line 1301 of file service.cpp.
References NLNET::ExitSignalAsked, and nlinfo. |
string NLNET::IService::getArg |
( |
char |
argName |
) |
|
|
|
Returns the parameter linked to an option (ie: getArg('p') will return "toto" if -ptoto is in the command line) It'll thrown an Exception if the argName is not found.
Definition at line 379 of file service.cpp.
References _Args.
Referenced by main. |
const std::vector<std::string>& NLNET::IService::getArgs |
( |
|
) |
const [inline] |
|
|
Returns arguments of the program pass from the user to the program using parameters (ie: "myprog param1 param2").
Definition at line 212 of file service.h. |
uint64 NLNET::IService::getEntityId |
( |
uint8 |
Type |
) |
[inline] |
|
|
Returns the recording state (don't needed if you use layer5).
Definition at line 234 of file service.h. |
const std::string& NLNET::IService::getServiceAliasName |
( |
|
) |
const [inline] |
|
|
Returns the current service alias name setted by AES.
Definition at line 200 of file service.h. |
TServiceId NLNET::IService::getServiceId |
( |
|
) |
const [inline] |
|
const std::string& NLNET::IService::getServiceLongName |
( |
|
) |
const [inline] |
|
|
Returns the current service long name (ie: test_serivce).
Definition at line 197 of file service.h. |
const std::string& NLNET::IService::getServiceShortName |
( |
|
) |
const [inline] |
|
|
Returns the current service short name (ie: TS).
Definition at line 194 of file service.h. |
std::string NLNET::IService::getServiceUnifiedName |
( |
|
) |
const |
|
sint NLNET::IService::getStatus |
( |
|
) |
const [inline] |
|
|
Returns the status.
Definition at line 209 of file service.h.
Referenced by main. |
bool NLNET::IService::haveArg |
( |
char |
argName |
) |
|
|
|
Returns true if the argument if present in the command line (ie: haveArg('p') will return true if -p is in the command line).
Definition at line 364 of file service.cpp.
References _Args.
Referenced by main. |
virtual void NLNET::IService::init |
( |
|
) |
[inline, virtual] |
|
|
Initializes the service (must be called before the first call to update()).
Definition at line 176 of file service.h.
Referenced by main. |
IService* NLNET::IService::IService::getInstance |
( |
|
) |
[inline, static] |
|
sint NLNET::IService::main |
( |
const char * |
serviceShortName, |
|
|
const char * |
serviceLongName, |
|
|
uint16 |
servicePort, |
|
|
const char * |
configDir, |
|
|
const char * |
logDir |
|
) |
|
|
|
This main is called by the macro (service5 says if we have to use layer5 or not).
Definition at line 473 of file service.cpp.
References _AliasName, _CallbackArray, _CallbackArraySize, _ConfigDir, _DontUseAES, _DontUseNS, _Initialized, _LogDir, _LongName, _NextEntityId, _Port, _RecordingState, _ResetMeasures, _RunningPath, _ShortName, _SId, _UpdateTimeout, _Version, NLNET::AESCallbackArray, AESConnection, NLNET::AESDisconnection, NLMISC::AssertLog, NLNET::cbLogFilter, ConfigFile, NLMISC::CWindowDisplayer::create, NLMISC::createDebug, NLMISC::CWindowDisplayer::createLabel, NLMISC::DebugLog, NLMISC::ErrorLog, NLNET::ExitSignalAsked, getArg, NLNET::CUnifiedNetwork::getInstance, getStatus, NLMISC::CConfigFile::getVar, NLMISC::CConfigFile::getVarPtr, haveArg, NLMISC::InfoLog, init, NLNET::initSignal, IsDebuggerPresent, NLMISC::CConfigFile::load, NLNET::NetSpeedLoop, nlassert, nldebug, nlinfo, NLMISC::nlSleep, nlwarning, release, NLMISC::CConfigFile::setCallback, NLNET::setDefaultEmailParams, NLMISC::CWindowDisplayer::setLabel, NLMISC::setReportEmailFunction, NLMISC::CEntityId::setServiceId, setStatus, NLMISC::CWindowDisplayer::setTitleBar, NLMISC::TTime, NLMISC::CWindowDisplayer::update, update, NLNET::UserSpeedLoop, v, w, NLMISC::WarningLog, WindowDisplayer, WriteFilesDirectory, x, and y. |
virtual void NLNET::IService::release |
( |
void |
|
) |
[inline, virtual] |
|
|
Finalization. Release the service. For example, this founction free all allocation made in the init() function.
Definition at line 182 of file service.h.
Referenced by main. |
void NLNET::IService::requireResetMeasures |
( |
|
) |
|
|
void NLNET::IService::setArgs |
( |
const char * |
args |
) |
|
|
|
Sets the command line and init _Args variable. You must call this before calling main().
Definition at line 395 of file service.cpp.
References _Args. |
void NLNET::IService::setArgs |
( |
int |
argc, |
|
|
const char ** |
argv |
|
) |
|
|
|
Sets the command line and init _Args variable. You must call this before calling main().
Definition at line 412 of file service.cpp.
References _Args. |
|
Sets the default callback array given from the macro.
Definition at line 284 of file service.h. |
|
Changes the recording state (use if you know what you are doing).
Definition at line 311 of file service.h. |
void NLNET::IService::setStatus |
( |
sint |
status |
) |
[inline] |
|
|
Sets the status of the service, this status is return to the application.
EXIT_SUCCESS is the default status You can set it to EXIT_FAILURE or any value you want. It's useful when you use the service in a script and you want to know the return value of the application to do the appropriate things.
Definition at line 247 of file service.h.
Referenced by main. |
void NLNET::IService::setUpdateTimeout |
( |
NLMISC::TTime |
timeout |
) |
[inline] |
|
|
Selects timeout value in seconds for each update.
You are absolutely certain that your update() function will not be called before this amount of time you set. If you set the update timeout value higher than 0, all messages in queues will be process until the time greater than the timeout user update(). If you set the update timeout value to 0, all messages in queues will be process one time before calling the user update().
The default value is 100 (100ms)
Definition at line 260 of file service.h. |
void NLNET::IService::setVersion |
( |
const std::string & |
version |
) |
[inline] |
|
virtual bool NLNET::IService::update |
( |
|
) |
[inline, virtual] |
|
|
This function is called every "frame" (you must call init() before). It returns false if the service is stopped.
Definition at line 179 of file service.h.
Referenced by main. |
Friends And Related Function Documentation
void AESConnection |
( |
const std::string & |
serviceName, |
|
|
uint16 |
sid, |
|
|
void * |
arg |
|
) |
[friend] |
|
friend struct getWinDisplayerInfoClass [friend]
|
|
void serviceGetView |
( |
uint32 |
rid, |
|
|
const std::string & |
rawvarpath, |
|
|
std::vector< std::string > & |
vara, |
|
|
std::vector< std::string > & |
vala |
|
) |
[friend] |
|
friend struct serviceInfoClass [friend]
|
|
Member Data Documentation
std::string NLNET::IService::_AliasName [private]
|
|
std::vector<std::string> NLNET::IService::_Args [private]
|
|
uint NLNET::IService::_CallbackArraySize [private]
|
|
std::string NLNET::IService::_ConfigDir [private]
|
|
|
The directory where the configfile is.
Definition at line 352 of file service.h.
Referenced by main. |
bool NLNET::IService::_DontUseAES [private]
|
|
|
true if the service don't use the admin executor service.
Definition at line 368 of file service.h.
Referenced by main. |
bool NLNET::IService::_DontUseNS [private]
|
|
|
true if the service don't use the naming service.
Definition at line 366 of file service.h.
Referenced by main. |
bool NLNET::IService::_Initialized [private]
|
|
|
true if the service initialisation is passed.
Definition at line 346 of file service.h.
Referenced by main. |
IService * NLNET::IService::_Instance = NULL [static, private]
|
|
std::string NLNET::IService::_LogDir [private]
|
|
|
The directory where the logfiles are.
Definition at line 355 of file service.h.
Referenced by main. |
std::string NLNET::IService::_LongName [private]
|
|
|
This variable is used to generate uniq id for entities on this service.
Definition at line 349 of file service.h.
Referenced by main. |
uint16 NLNET::IService::_Port [private]
|
|
|
Listening port of this service.
Definition at line 323 of file service.h.
Referenced by main. |
bool NLNET::IService::_ResetMeasures [private]
|
|
std::string NLNET::IService::_RunningPath [private]
|
|
|
The directory where the service is running.
Definition at line 358 of file service.h.
Referenced by main. |
std::string NLNET::IService::_ShortName [private]
|
|
sint NLNET::IService::_Status [private]
|
|
|
the status of this service (the status is give to the at the release time).
Definition at line 343 of file service.h. |
|
Select timeout value in milliseconds between to call of user update().
Definition at line 337 of file service.h.
Referenced by main. |
std::string NLNET::IService::_Version [private]
|
|
|
The window displayer instance.
Definition at line 298 of file service.h.
Referenced by main. |
std::string NLNET::IService::WriteFilesDirectory
|
|
|
Directory where to store files that the services will write (for example, packet_sheets).
Definition at line 301 of file service.h.
Referenced by main. |
The documentation for this class was generated from the following files:
|
|