mirror of
https://github.com/QuasarApp/Patronum.git
synced 2025-04-26 15:44:32 +00:00
commit
ba2ae3f752
@ -22,11 +22,11 @@ class Feature;
|
||||
enum class ControllerError {
|
||||
/// Unknown error
|
||||
Undefined,
|
||||
/// Service is unavailable. Try send start comand or restart the service manually.
|
||||
/// Service is unavailable. Try send start command or restart the service manually.
|
||||
ServiceUnavailable,
|
||||
/// Invalid package received
|
||||
/// Invalid package received.
|
||||
InvalidPackage,
|
||||
/// Library unsupported command received
|
||||
/// Library unsupported command received.
|
||||
WrongCommand,
|
||||
/// Internal error of the work of the Patronum library. Contact the developers and provide them with an error report. https://github.com/QuasarApp/Patronum/issues
|
||||
SystemError
|
||||
@ -42,9 +42,9 @@ public:
|
||||
virtual ~IController() = default;
|
||||
|
||||
/**
|
||||
* @brief errorToString this method convert the ControllerError to QString.
|
||||
* @param error - error id
|
||||
* @return return text of error
|
||||
* @brief errorToString This method convert the ControllerError to QString.
|
||||
* @param error - Error id.
|
||||
* @return return text of error.
|
||||
*/
|
||||
QString errorToString(ControllerError error) const;
|
||||
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
virtual ~IService() = default;
|
||||
|
||||
/**
|
||||
* @brief handleReceiveData This method get all received comnads and proccess its.
|
||||
* @brief handleReceiveData This method get all received commnads and process its.
|
||||
* For each command will invoke the handleReceive method.
|
||||
* @param data
|
||||
*/
|
||||
@ -33,36 +33,36 @@ public:
|
||||
|
||||
/**
|
||||
* @brief handleReceive This method invoked when service receive a request from terminal.
|
||||
* Override this method for wor service.
|
||||
* Override this method for work service.
|
||||
* @param data This is input data.
|
||||
* @return This method showld be return true if the @a data command is supported and processed succesful.
|
||||
* @return This method should be return true if the @a data command is supported and processed successful.
|
||||
* IF you return false then a negative message will be sent to a terminal app.
|
||||
*/
|
||||
virtual bool handleReceive(const Feature &data) = 0;
|
||||
|
||||
/**
|
||||
* @brief supportedFeatures Override this method for add your featores for the service.
|
||||
* @return should be return a set of supported Features.
|
||||
* @brief supportedFeatures Override this method for add your features for the service.
|
||||
* @return should be return a set of supported features.
|
||||
*/
|
||||
virtual QSet<Feature> supportedFeatures() = 0;
|
||||
|
||||
/**
|
||||
* @brief onStart This method invoked when service is started successful
|
||||
* @brief onStart This method invoked when service is started successful.
|
||||
*/
|
||||
virtual void onStart() = 0;
|
||||
|
||||
/**
|
||||
* @brief onStop This method invoked when service receive stop command from the terminal
|
||||
* @brief onStop This method invoked when service receive stop command from the terminal.
|
||||
*/
|
||||
virtual void onStop() = 0;
|
||||
|
||||
/**
|
||||
* @brief onResume This method invoked when service receive resume command from the terminal
|
||||
* @brief onResume This method invoked when service receive resume command from the terminal.
|
||||
*/
|
||||
virtual void onResume() = 0;
|
||||
|
||||
/**
|
||||
* @brief onPause This method invoked when service receive pause command from the terminal
|
||||
* @brief onPause This method invoked when service receive pause command from the terminal.
|
||||
*/
|
||||
virtual void onPause() = 0;
|
||||
};
|
||||
|
@ -20,44 +20,44 @@ class ControllerPrivate;
|
||||
* ###How to use :
|
||||
* - create QCoreApplication object
|
||||
* - just inherit from the Service Controller and override the methods you need.
|
||||
* - So, invoke the send methon, and if you need to get a responce from your service then invoke a waitForResponce method.
|
||||
* - 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.
|
||||
*/
|
||||
class PATRONUM_LIBRARYSHARED_EXPORT Controller : protected IController
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Controller - base constructor
|
||||
* @param name - name of you service
|
||||
* @param servicePath - path to service executable. @note If servicePath argument well be empty then 'start' commnad not working
|
||||
* @brief Controller - Base constructor.
|
||||
* @param name - Name of you service.
|
||||
* @param servicePath - Path to service executable. @note If servicePath argument well be empty then 'start' commnad not working
|
||||
*/
|
||||
Controller(const QString& name, const QString& servicePath = "");
|
||||
~Controller() override;
|
||||
|
||||
/**
|
||||
* @brief send - this method send request to service
|
||||
* @param argc - count of arguments
|
||||
* @param argv - arguments list
|
||||
* @return true if all sendet seccussful
|
||||
* @brief send - This method send request to service.
|
||||
* @param argc - Count of arguments.
|
||||
* @param argv - Arguments list.
|
||||
* @return true if all sendet successful.
|
||||
*/
|
||||
bool send(int argc, char **argv);
|
||||
|
||||
/**
|
||||
* @brief send - this method send request to service. @warning Invoke this method if you invoked QuasarAppUtils::Params::parse() befor invoke this method else use send(int argc, char **argv).
|
||||
* @return true if all sendet seccussful
|
||||
* @brief 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).
|
||||
* @return true if all sendet successful.
|
||||
*/
|
||||
bool send();
|
||||
|
||||
/**
|
||||
* @brief startDetached
|
||||
* @return true if service started seccessful.
|
||||
* @return true if service started successful.
|
||||
*/
|
||||
int startDetached() const;
|
||||
|
||||
/**
|
||||
* @brief waitForResponce - waut for get a responce from servece
|
||||
* @param msec timeout
|
||||
* @return true if all seccussful
|
||||
* @brief waitForResponce - Wait for get a responce from servece.
|
||||
* @param msec Timeout in msec.
|
||||
* @return true if all seccussful.
|
||||
*/
|
||||
bool waitForResponce(int msec = 10000);
|
||||
|
||||
@ -72,23 +72,23 @@ protected:
|
||||
void handleError(ControllerError error) override;
|
||||
|
||||
/**
|
||||
* @brief handleFeatures - override this method if you want cerate a custom reaction of get service features
|
||||
* default inplenebtation prin help of available command of your service
|
||||
* @param features - list of features
|
||||
* @brief 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.
|
||||
* @param features - List of features.
|
||||
*/
|
||||
void handleFeatures(const QList<Feature> &features) override;
|
||||
|
||||
/**
|
||||
* @brief handleResponce - override this method if you want create a custom reaction of get responce from service
|
||||
* @brief handleResponce - Override this method if you want create a custom reaction of get responce from service.
|
||||
* Default inplementation print responce to console.
|
||||
* @param responce - responce from service
|
||||
* @param responce - Responce from service.
|
||||
*/
|
||||
void handleResponce(const QVariantMap &responce) override;
|
||||
|
||||
/**
|
||||
* @brief features - this metho return current features of connected service.
|
||||
* @note If Responed from service not received then return empty list.
|
||||
* @return features list
|
||||
* @brief features - This method return current features of connected service.
|
||||
* @note If Respond from service not received then return empty list.
|
||||
* @return Features list.
|
||||
*/
|
||||
QList<Feature> features();
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
namespace Patronum {
|
||||
|
||||
/**
|
||||
* @brief The Feature class it is atomic type for describe service command
|
||||
* @brief The Feature class it is atomic type for describe service command.
|
||||
*/
|
||||
class PATRONUM_LIBRARYSHARED_EXPORT Feature
|
||||
{
|
||||
@ -26,8 +26,8 @@ public:
|
||||
const QString& description = "", const QString& example = "");
|
||||
|
||||
/**
|
||||
* @brief cmd This method return command of the feature
|
||||
* @return command of the feature
|
||||
* @brief cmd This method return command of the feature.
|
||||
* @return Command of the feature.
|
||||
*/
|
||||
QString cmd() const;
|
||||
|
||||
@ -40,7 +40,7 @@ public:
|
||||
/**
|
||||
* @brief arg This method return argument value.
|
||||
* The argument value has a qvariant type, so this object maybe have a list or array type.
|
||||
* @return argument value.
|
||||
* @return Argument value.
|
||||
*/
|
||||
QString arg() const;
|
||||
void setArg(const QString &arg);
|
||||
@ -51,32 +51,32 @@ public:
|
||||
|
||||
/**
|
||||
* @brief description This method return description message of the command.
|
||||
* This string display in a teminal application in the help section.
|
||||
* @return description message of the command
|
||||
* This string display in a terminal application in the help section.
|
||||
* @return Description message of the command.
|
||||
*/
|
||||
QString description() const;
|
||||
|
||||
/**
|
||||
* @brief setDescription This method sets description for command.
|
||||
* @param description tihs is new value of the description command.
|
||||
* @param description This is new value of the description command.
|
||||
*/
|
||||
void setDescription(const QString &description);
|
||||
|
||||
/**
|
||||
* @brief example This is exmaple of using this command.
|
||||
* @return example of use.
|
||||
* @return Example of use.
|
||||
*/
|
||||
QString example() const;
|
||||
|
||||
/**
|
||||
* @brief setExample This method sets a new example
|
||||
* @brief setExample This method sets a new example.
|
||||
* @param example This is a new example value.
|
||||
*/
|
||||
void setExample(const QString &example);
|
||||
|
||||
/**
|
||||
* @brief toString This is general method of the converting command to string.
|
||||
* @return string of all command.
|
||||
* @return String of all command.
|
||||
*/
|
||||
QString toString() const;
|
||||
|
||||
|
@ -27,9 +27,9 @@ class Service : public ServiceBase
|
||||
public:
|
||||
/**
|
||||
* @brief Service
|
||||
* @param argc - count params
|
||||
* @param argv - test of arguments
|
||||
* @param name - name of your service
|
||||
* @param argc - Count params.
|
||||
* @param argv - Test of arguments.
|
||||
* @param name - Name of your service.
|
||||
*/
|
||||
Service(int argc, char *argv[], const QString &name)
|
||||
: ServiceBase(argc, argv, name) {
|
||||
|
@ -25,9 +25,9 @@ class PATRONUM_LIBRARYSHARED_EXPORT ServiceBase : protected IService
|
||||
public:
|
||||
/**
|
||||
* @brief Service
|
||||
* @param argc - count params
|
||||
* @param argv - test of arguments
|
||||
* @param name - name of your service
|
||||
* @param argc - Count params.
|
||||
* @param argv - Test of arguments.
|
||||
* @param name - Name of your service.
|
||||
*/
|
||||
ServiceBase(int argc, char *argv[], const QString &name);
|
||||
|
||||
@ -36,72 +36,72 @@ public:
|
||||
|
||||
/**
|
||||
* @brief exec
|
||||
* @return result of work application
|
||||
* @return Result of work application.
|
||||
*/
|
||||
virtual int exec();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief handleReceiveData - this method invoce when service receive new command from terminal of controller of this service.
|
||||
* @param data - is list of commands from controller
|
||||
* Default inplementation send message abount error, and invoke the .
|
||||
* @brief handleReceiveData - This method invoice when service receive new command from terminal of controller of this service.
|
||||
* @param data - Is list of commands from controller.
|
||||
* Default implementation send message about error, and invoke the.
|
||||
*/
|
||||
void handleReceiveData(const QSet<Feature> &data) override final;
|
||||
|
||||
/**
|
||||
* @brief supportedFeatures
|
||||
* @return a set supported features of this service. Override this method for correctly work of your pair (service and controller)
|
||||
* @return A set supported features of this service. Override this method for correctly work of your pair (service and controller).
|
||||
*/
|
||||
QSet<Feature> supportedFeatures() override;
|
||||
|
||||
/**
|
||||
* @brief sendResuylt - call this method for send responce from service to tour controller
|
||||
* @param result
|
||||
* @return true if data sendet is seccusseful
|
||||
* @brief sendResuylt - Call this method for send responce from service to tour controller.
|
||||
* @param result Message.
|
||||
* @return True if data sendet is seccusseful.
|
||||
*/
|
||||
bool sendResuylt(const QVariantMap &result);
|
||||
|
||||
/**
|
||||
* @brief sendResuylt this method send text responce to controller
|
||||
* @param result - message
|
||||
* @return true if data sendet is seccusseful
|
||||
* @brief sendResuylt This method send text responce to controller.
|
||||
* @param result - Message.
|
||||
* @return True if data sendet is seccusseful.
|
||||
*/
|
||||
bool sendResuylt(const QString &result);
|
||||
|
||||
/**
|
||||
* @brief sendCloseeConnetion This method send signal that all request command processed.
|
||||
* @return return true if the message sent successul.
|
||||
* @return Return true if the message sent successul.
|
||||
*/
|
||||
bool sendCloseeConnetion();
|
||||
|
||||
/**
|
||||
* @brief createApplication default implementation create a Application object and parse argumnts.
|
||||
* @brief createApplication Default implementation create a Application object and parse arguments.
|
||||
*/
|
||||
virtual void createApplication() = 0;
|
||||
|
||||
/**
|
||||
* @brief onStart called when get start command from terminal. Override this method work correctly work of service.
|
||||
* @brief onStart Called when get start command from terminal. Override this method work correctly work of service.
|
||||
*/
|
||||
void onStart() override = 0;
|
||||
|
||||
/**
|
||||
* @brief onStop called when get stop command from terminal. The default implementation of this method invoke a quit method of QCoreApplication.
|
||||
* @brief onStop Called when get stop command from terminal. The default implementation of this method invoke a quit method of QCoreApplication.
|
||||
*/
|
||||
void onStop() override;
|
||||
|
||||
/**
|
||||
* @brief onStop called when get resume command from terminal. The Default implementation do nothing.
|
||||
* @brief onResume Called when get resume command from terminal. The Default implementation do nothing.
|
||||
*/
|
||||
void onResume() override;
|
||||
|
||||
/**
|
||||
* @brief onStop called when get pause command from terminal. The Default implementation do nothing.
|
||||
* @brief onPause Called when get pause command from terminal. The Default implementation do nothing.
|
||||
*/
|
||||
void onPause() override;
|
||||
|
||||
/**
|
||||
* @brief controller
|
||||
* @return own controller instance;
|
||||
* @return Own controller instance.
|
||||
*/
|
||||
Controller *controller();
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "PService.h"
|
||||
|
||||
/**
|
||||
* @brief The Patronum namespace - it is main name space of Patronum Library
|
||||
* @brief The Patronum namespace - It is main name space of Patronum Library.
|
||||
*/
|
||||
namespace Patronum {}
|
||||
#endif // PATRONUM_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user