Patronum
Loading...
Searching...
No Matches
Patronum::ServiceBase Class Referenceabstract

The ServiceBase class This is Base service class. Please for create your own services use the Patronum::Service class. More...

#include <PServiceBase.h>

Inheritance diagram for Patronum::ServiceBase:
Inheritance graph
Collaboration diagram for Patronum::ServiceBase:
Collaboration graph

Public Member Functions

 ServiceBase (int argc, char *argv[])
 ServiceBase This is main constructor of the service.
 
 ~ServiceBase () override
 
virtual int exec ()
 exec This is main method of the service. Use this like a QCoreApplication::exec.
 

Protected Member Functions

void handleReceiveData (const QHash< QString, Feature > &data) override
 handleReceiveData - This method invoice when service receive new command from terminal of controller of this service.
 
QSet< FeaturesupportedFeatures () override
 supportedFeatures
 
bool sendResuylt (const QVariantMap &result)
 sendResuylt - Call this method for send responce from service to tour controller.
 
bool sendResuylt (const QString &result)
 sendResuylt This method send text responce to controller.
 
bool sendRawResuylt (const QByteArray &result)
 sendRawResuylt This method send raw text responce to controller.
 
virtual void createApplication ()=0
 createApplication Default implementation create a Application object and parse arguments.
 
bool onStart () override=0
 onStart Called when get start command from terminal. Override this method work correctly work of service.
 
void onStop () override
 onStop Called when get stop command from terminal. The default implementation of this method invoke a quit method of QCoreApplication.
 
void onResume () override
 onResume Called when get resume command from terminal. The Default implementation do nothing.
 
void onPause () override
 onPause Called when get pause command from terminal. The Default implementation do nothing.
 
Controllercontroller ()
 controller This method return the local controller object. If the controller object is not inited the this methd create a new object.
 
QCoreApplication * core ()
 core This method return a pointer to instance of the core application.
 
void setCore (QCoreApplication *core)
 setCore This method sets new object of the core application.
 
- Protected Member Functions inherited from Patronum::IService
 IService ()
 
virtual ~IService ()=default
 
virtual bool handleReceive (const Feature &data)=0
 handleReceive This method invoked when service receive a request from terminal. Override this method for work your service.
 

Detailed Description

The ServiceBase class This is Base service class. Please for create your own services use the Patronum::Service class.

Definition at line 23 of file PServiceBase.h.

Constructor & Destructor Documentation

◆ ServiceBase()

Patronum::ServiceBase::ServiceBase ( int  argc,
char *  argv[] 
)

ServiceBase This is main constructor of the service.

Parameters
argcThis is count of input arguments.
argvThis is raw C array of the input arguments.
Note
If you create a console client for your service then you need to sets some service name as a this. Fot This use the QCoreApplication::setApplicationName() methid. You need to invoke this method befor invoke the ServiceBase::exec method.

Definition at line 24 of file PServiceBase.cpp.

Here is the call graph for this function:

◆ ~ServiceBase()

Patronum::ServiceBase::~ServiceBase ( )
override

Definition at line 32 of file PServiceBase.cpp.

Member Function Documentation

◆ controller()

Controller * Patronum::ServiceBase::controller ( )
protected

controller This method return the local controller object. If the controller object is not inited the this methd create a new object.

Returns
Own controller instance.

Definition at line 114 of file PServiceBase.cpp.

Here is the caller graph for this function:

◆ core()

QCoreApplication * Patronum::ServiceBase::core ( )
protected

core This method return a pointer to instance of the core application.

Returns
pointer to core application object.

Definition at line 146 of file PServiceBase.cpp.

Here is the caller graph for this function:

◆ createApplication()

virtual void Patronum::ServiceBase::createApplication ( )
protectedpure virtual

createApplication Default implementation create a Application object and parse arguments.

Implemented in Patronum::Service< Application >.

Here is the caller graph for this function:

◆ exec()

int Patronum::ServiceBase::exec ( )
virtual

exec This is main method of the service. Use this like a QCoreApplication::exec.

Returns
Result of work application.

Definition at line 157 of file PServiceBase.cpp.

Here is the call graph for this function:

◆ handleReceiveData()

void Patronum::ServiceBase::handleReceiveData ( const QHash< QString, Feature > &  data)
overrideprotectedvirtual

handleReceiveData - This method invoice when service receive new command from terminal of controller of this service.

Parameters
data- Is list of commands from controller. Default implementation send message about error, and invoke the.
Note
If you override this method the ServiceBase::handleReceive method wil not invoked wuthou base implementation of thism method.
See also
ServiceBase::handleReceive

Implements Patronum::IService.

Definition at line 50 of file PServiceBase.cpp.

Here is the call graph for this function:

◆ onPause()

void Patronum::ServiceBase::onPause ( )
overrideprotectedvirtual

onPause Called when get pause command from terminal. The Default implementation do nothing.

Implements Patronum::IService.

Definition at line 110 of file PServiceBase.cpp.

Here is the call graph for this function:

◆ onResume()

void Patronum::ServiceBase::onResume ( )
overrideprotectedvirtual

onResume Called when get resume command from terminal. The Default implementation do nothing.

Implements Patronum::IService.

Definition at line 106 of file PServiceBase.cpp.

Here is the call graph for this function:

◆ onStart()

bool Patronum::ServiceBase::onStart ( )
overrideprotectedpure virtual

onStart Called when get start command from terminal. Override this method work correctly work of service.

Implements Patronum::IService.

◆ onStop()

void Patronum::ServiceBase::onStop ( )
overrideprotectedvirtual

onStop Called when get stop command from terminal. The default implementation of this method invoke a quit method of QCoreApplication.

Implements Patronum::IService.

Definition at line 98 of file PServiceBase.cpp.

Here is the call graph for this function:

◆ sendRawResuylt()

bool Patronum::ServiceBase::sendRawResuylt ( const QByteArray &  result)
protected

sendRawResuylt This method send raw text responce to controller.

Parameters
result- Message.
Returns
True if data sendet is seccusseful.

Definition at line 94 of file PServiceBase.cpp.

◆ sendResuylt() [1/2]

bool Patronum::ServiceBase::sendResuylt ( const QString &  result)
protected

sendResuylt This method send text responce to controller.

Parameters
result- Message.
Returns
True if data sendet is seccusseful.

Definition at line 90 of file PServiceBase.cpp.

◆ sendResuylt() [2/2]

bool Patronum::ServiceBase::sendResuylt ( const QVariantMap &  result)
protected

sendResuylt - Call this method for send responce from service to tour controller.

Parameters
resultMessage.
Returns
True if data sendet is seccusseful.

Definition at line 86 of file PServiceBase.cpp.

Here is the caller graph for this function:

◆ setCore()

void Patronum::ServiceBase::setCore ( QCoreApplication *  core)
protected

setCore This method sets new object of the core application.

Parameters
coreThis is new core application object.

Definition at line 150 of file PServiceBase.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ supportedFeatures()

QSet< Feature > Patronum::ServiceBase::supportedFeatures ( )
overrideprotectedvirtual

supportedFeatures

Returns
A set supported features of this service. Override this method for correctly work of your pair (service and controller).

Implements Patronum::IService.

Definition at line 82 of file PServiceBase.cpp.

Here is the caller graph for this function:

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