# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
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 Reference

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

CCallbackServergetServer ()
 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)
User overload methods. These methods can be overload by the user do handle init, update and release operation.
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...

private methods. These methods are used by internal system but can't be put in private, don't use them.
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::CWindowDisplayerWindowDisplayer
 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

methods. These methods are used by internal system.
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 :

  • -n<AliasName>
Author:
Vianney Lecroart , Olivier Cado , Nevrax France
Date:
2000

Definition at line 168 of file service.h.


Constructor & Destructor Documentation

NLNET::IService::IService  
 

Ctor. You must not inherit ctor but overload init() function.

Definition at line 346 of file service.cpp.

References _Instance, and nlassert.

Referenced by IService::getInstance.

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 an uniq id for an entities on this service.

Definition at line 223 of file service.h.

References NLMISC::CEntityId::getRawId, id, and NLMISC::CEntityId::setType.

CCallbackNetBase::TRecordingState NLNET::IService::getRecordingState   const [inline]
 

Returns the recording state (don't needed if you use layer5).

Definition at line 234 of file service.h.

CCallbackServer * NLNET::IService::getServer  
 

Returns a pointer to the CCallbackServer object.

Definition at line 423 of file service.cpp.

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]
 

Returns the service identifier.

Definition at line 206 of file service.h.

References NLNET::TServiceId.

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
 

Returns the current service unified name that is alias/short-id or short-id if alias is empty.

Definition at line 1316 of file service.cpp.

References _AliasName, _ShortName, _SId, nlassert, and res.

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]
 

Returns the instance of the service to access to methods/variables class.

Definition at line 191 of file service.h.

References _Instance, IService, IService::getInstance, and nlassert.

Referenced by IService::getInstance.

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  
 

Require to reset the hierarchical timer.

Definition at line 1310 of file service.cpp.

References _ResetMeasures.

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.

void NLNET::IService::setCallbackArray TUnifiedCallbackItem   array,
uint    nbelem
[inline]
 

Sets the default callback array given from the macro.

Definition at line 284 of file service.h.

void NLNET::IService::setRecordingState CCallbackNetBase::TRecordingState    rec [inline, private]
 

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]
 

Definition at line 303 of file service.h.

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]
 

Referenced by main.

friend struct getWinDisplayerInfoClass [friend]
 

Definition at line 378 of file service.h.

void serviceGetView uint32    rid,
const std::string &    rawvarpath,
std::vector< std::string > &    vara,
std::vector< std::string > &    vala
[friend]
 

friend struct serviceInfoClass [friend]
 

Definition at line 377 of file service.h.


Member Data Documentation

std::string NLNET::IService::_AliasName [private]
 

Definition at line 331 of file service.h.

Referenced by getServiceUnifiedName, and main.

std::vector<std::string> NLNET::IService::_Args [private]
 

Array of arguments pass from the command line.

Definition at line 320 of file service.h.

Referenced by getArg, haveArg, and setArgs.

TUnifiedCallbackItem* NLNET::IService::_CallbackArray [private]
 

Definition at line 362 of file service.h.

Referenced by main.

uint NLNET::IService::_CallbackArraySize [private]
 

Definition at line 363 of file service.h.

Referenced by main.

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]
 

Instance of this service (singleton).

Definition at line 105 of file service.cpp.

Referenced by IService, and IService::getInstance.

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]
 

Definition at line 330 of file service.h.

Referenced by main.

NLMISC::CEntityId NLNET::IService::_NextEntityId [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.

CCallbackNetBase::TRecordingState NLNET::IService::_RecordingState [private]
 

Recording state.

Definition at line 326 of file service.h.

Referenced by main.

bool NLNET::IService::_ResetMeasures [private]
 

Require to reset the hierarchical timer.

Definition at line 371 of file service.h.

Referenced by main, and requireResetMeasures.

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]
 

Current service name sets by the actual service when declaring NLNET_SERVICE_MAIN.

Definition at line 329 of file service.h.

Referenced by getServiceUnifiedName, and main.

TServiceId NLNET::IService::_SId [private]
 

the service id of this sevice.

Definition at line 340 of file service.h.

Referenced by getServiceUnifiedName, and main.

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.

NLMISC::TTime NLNET::IService::_UpdateTimeout [private]
 

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]
 

Definition at line 360 of file service.h.

Referenced by main.

NLMISC::CConfigFile NLNET::IService::ConfigFile
 

Definition at line 266 of file service.h.

Referenced by main.

NLMISC::CWindowDisplayer* NLNET::IService::WindowDisplayer
 

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: