Patronum
Loading...
Searching...
No Matches
Patronum::Controller Class Reference

The Controller class provide control functionality for your service. More...

#include <PController.h>

Inheritance diagram for Patronum::Controller:
Inheritance graph
Collaboration diagram for Patronum::Controller:
Collaboration graph

Public Member Functions

 Controller ()
 Controller This is base constructor of the controller.
 
 ~Controller () override
 
bool send (int argc, char **argv)
 send This method send request to service.
 
bool send ()
 send - This method send request to service.
 
bool sendStop ()
 sendStop This method send stop command to service;
 
QuasarAppUtils::Help::Section help () const
 help This method return help of the Controller.
 

Protected Member Functions

void handleError (PatronumError error) override
 handleError - override this method if you want track errors the default implementation print error message.
 
void handleFeatures (const QList< Feature > &features) override
 handleFeatures - Override this method if you want create a custom reaction of get service features. default implementation print help of available command of your service.
 
void handleResponce (const QVariantMap &responce) override
 handleResponce - Override this method if you want create a custom reaction of get responce from service. Default inplementation print responce to console.
 
void finished () override
 finished This method invoked when controler receive from service the Command::CloseConnection command This implementation invoke he exit method of the QCoreApplication and finished application. If do not want to stop application after receive Command::CloseConnection then override this method.
 
QList< Featurefeatures ()
 features - This method return current features of connected service.
 
- Protected Member Functions inherited from Patronum::IController
 IController ()=default
 
virtual ~IController ()=default
 

Detailed Description

The Controller class provide control functionality for your service.

How to use :

  • create QCoreApplication object
  • just inherit from the Service Controller and override the methods you need.
  • So, invoke the send method, and if you need to get a response from your service then invoke a waitForResponce method.
  • or run application exec method.

Example:

#include <patronum.h>
class MyControllerApp : public Patronum::Controller
{
public:
MyControllerApp():
}
};
int main(int argc, char **argv) {
QCoreApplication::setApplicationName("MyServiceName"); // <--
QCoreApplication::setOrganizationName("MyCompany"); // <--
QCoreApplcication app
MyControllerApp controller;
controller.send(argc, argv);
return app.exec();
}
The Controller class provide control functionality for your service.
Definition PController.h:57
The Patronum namespace - It is main name space of Patronum Library. The Patronum library support the ...
Note
The Controller class provide only base functionality. Sending custom command and receive response of service. If you want to start or install/unistall service tou need to use the Patronum::Service class.

Definition at line 56 of file PController.h.

Constructor & Destructor Documentation

◆ Controller()

Patronum::Controller::Controller ( )

Controller This is base constructor of the controller.

Definition at line 20 of file PController.cpp.

◆ ~Controller()

Patronum::Controller::~Controller ( )
override

Definition at line 24 of file PController.cpp.

Member Function Documentation

◆ features()

QList< Feature > Patronum::Controller::features ( )
protected

features - This method return current features of connected service.

Note
If Respond from service not received then return empty list.
Returns
Features list.

Definition at line 172 of file PController.cpp.

Here is the caller graph for this function:

◆ finished()

void Patronum::Controller::finished ( )
overrideprotectedvirtual

finished This method invoked when controler receive from service the Command::CloseConnection command This implementation invoke he exit method of the QCoreApplication and finished application. If do not want to stop application after receive Command::CloseConnection then override this method.

Implements Patronum::IController.

Definition at line 167 of file PController.cpp.

◆ handleError()

void Patronum::Controller::handleError ( PatronumError  error)
overrideprotectedvirtual

handleError - override this method if you want track errors the default implementation print error message.

Parameters
error- error id see PatronumError

Implements Patronum::IController.

Definition at line 123 of file PController.cpp.

Here is the call graph for this function:

◆ handleFeatures()

void Patronum::Controller::handleFeatures ( const QList< Feature > &  features)
overrideprotectedvirtual

handleFeatures - Override this method if you want create a custom reaction of get service features. default implementation print help of available command of your service.

Parameters
features- List of features.

Implements Patronum::IController.

Definition at line 127 of file PController.cpp.

Here is the call graph for this function:

◆ handleResponce()

void Patronum::Controller::handleResponce ( const QVariantMap &  responce)
overrideprotectedvirtual

handleResponce - Override this method if you want create a custom reaction of get responce from service. Default inplementation print responce to console.

Parameters
responce- Responce from service.

Implements Patronum::IController.

Definition at line 151 of file PController.cpp.

◆ help()

QuasarAppUtils::Help::Section Patronum::Controller::help ( ) const

help This method return help of the Controller.

Returns
Available otions list.

Definition at line 109 of file PController.cpp.

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

◆ send() [1/2]

bool Patronum::Controller::send ( )

send - This method send request to service.

Warning
Invoke this method if you invoked QuasarAppUtils::Params::parse() before invoke this method else use send(int argc, char **argv).
Returns
true if all sendet successful.

Definition at line 36 of file PController.cpp.

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

◆ send() [2/2]

bool Patronum::Controller::send ( int  argc,
char **  argv 
)

send This method send request to service.

Parameters
argcThis is count of arguments.
argvThis is arguments list.
Returns
true if all sendet successful.

Definition at line 28 of file PController.cpp.

Here is the call graph for this function:

◆ sendStop()

bool Patronum::Controller::sendStop ( )

sendStop This method send stop command to service;

Returns
trie if command sendet successfull

Definition at line 94 of file PController.cpp.


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