4
0
mirror of https://github.com/QuasarApp/Patronum.git synced 2025-05-04 11:09:35 +00:00

Merge pull request from QuasarApp/task_5

Documentation correction
This commit is contained in:
Oleg-designer 2021-04-16 12:02:49 +03:00 committed by GitHub
commit ba2ae3f752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 72 additions and 72 deletions

@ -22,11 +22,11 @@ class Feature;
enum class ControllerError { enum class ControllerError {
/// Unknown error /// Unknown error
Undefined, 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, ServiceUnavailable,
/// Invalid package received /// Invalid package received.
InvalidPackage, InvalidPackage,
/// Library unsupported command received /// Library unsupported command received.
WrongCommand, 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 /// 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 SystemError
@ -42,9 +42,9 @@ public:
virtual ~IController() = default; virtual ~IController() = default;
/** /**
* @brief errorToString this method convert the ControllerError to QString. * @brief errorToString This method convert the ControllerError to QString.
* @param error - error id * @param error - Error id.
* @return return text of error * @return return text of error.
*/ */
QString errorToString(ControllerError error) const; QString errorToString(ControllerError error) const;

@ -25,7 +25,7 @@ public:
virtual ~IService() = default; 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. * For each command will invoke the handleReceive method.
* @param data * @param data
*/ */
@ -33,36 +33,36 @@ public:
/** /**
* @brief handleReceive This method invoked when service receive a request from terminal. * @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. * @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. * IF you return false then a negative message will be sent to a terminal app.
*/ */
virtual bool handleReceive(const Feature &data) = 0; virtual bool handleReceive(const Feature &data) = 0;
/** /**
* @brief supportedFeatures Override this method for add your featores for the service. * @brief supportedFeatures Override this method for add your features for the service.
* @return should be return a set of supported Features. * @return should be return a set of supported features.
*/ */
virtual QSet<Feature> supportedFeatures() = 0; 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; 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; 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; 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; virtual void onPause() = 0;
}; };

@ -20,44 +20,44 @@ class ControllerPrivate;
* ###How to use : * ###How to use :
* - create QCoreApplication object * - create QCoreApplication object
* - just inherit from the Service Controller and override the methods you need. * - 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. * - or run application exec method.
*/ */
class PATRONUM_LIBRARYSHARED_EXPORT Controller : protected IController class PATRONUM_LIBRARYSHARED_EXPORT Controller : protected IController
{ {
public: public:
/** /**
* @brief Controller - base constructor * @brief Controller - Base constructor.
* @param name - name of you service * @param name - Name of you service.
* @param servicePath - path to service executable. @note If servicePath argument well be empty then 'start' commnad not working * @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(const QString& name, const QString& servicePath = "");
~Controller() override; ~Controller() override;
/** /**
* @brief send - this method send request to service * @brief send - This method send request to service.
* @param argc - count of arguments * @param argc - Count of arguments.
* @param argv - arguments list * @param argv - Arguments list.
* @return true if all sendet seccussful * @return true if all sendet successful.
*/ */
bool send(int argc, char **argv); 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). * @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 seccussful * @return true if all sendet successful.
*/ */
bool send(); bool send();
/** /**
* @brief startDetached * @brief startDetached
* @return true if service started seccessful. * @return true if service started successful.
*/ */
int startDetached() const; int startDetached() const;
/** /**
* @brief waitForResponce - waut for get a responce from servece * @brief waitForResponce - Wait for get a responce from servece.
* @param msec timeout * @param msec Timeout in msec.
* @return true if all seccussful * @return true if all seccussful.
*/ */
bool waitForResponce(int msec = 10000); bool waitForResponce(int msec = 10000);
@ -72,23 +72,23 @@ protected:
void handleError(ControllerError error) override; void handleError(ControllerError error) override;
/** /**
* @brief handleFeatures - override this method if you want cerate a custom reaction of get service features * @brief handleFeatures - Override this method if you want create a custom reaction of get service features.
* default inplenebtation prin help of available command of your service * default implementation print help of available command of your service.
* @param features - list of features * @param features - List of features.
*/ */
void handleFeatures(const QList<Feature> &features) override; 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. * Default inplementation print responce to console.
* @param responce - responce from service * @param responce - Responce from service.
*/ */
void handleResponce(const QVariantMap &responce) override; void handleResponce(const QVariantMap &responce) override;
/** /**
* @brief features - this metho return current features of connected service. * @brief features - This method return current features of connected service.
* @note If Responed from service not received then return empty list. * @note If Respond from service not received then return empty list.
* @return features list * @return Features list.
*/ */
QList<Feature> features(); QList<Feature> features();

@ -16,7 +16,7 @@
namespace Patronum { 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 class PATRONUM_LIBRARYSHARED_EXPORT Feature
{ {
@ -26,8 +26,8 @@ public:
const QString& description = "", const QString& example = ""); const QString& description = "", const QString& example = "");
/** /**
* @brief cmd This method return command of the feature * @brief cmd This method return command of the feature.
* @return command of the feature * @return Command of the feature.
*/ */
QString cmd() const; QString cmd() const;
@ -40,7 +40,7 @@ public:
/** /**
* @brief arg This method return argument value. * @brief arg This method return argument value.
* The argument value has a qvariant type, so this object maybe have a list or array type. * 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; QString arg() const;
void setArg(const QString &arg); void setArg(const QString &arg);
@ -51,32 +51,32 @@ public:
/** /**
* @brief description This method return description message of the command. * @brief description This method return description message of the command.
* This string display in a teminal application in the help section. * This string display in a terminal application in the help section.
* @return description message of the command * @return Description message of the command.
*/ */
QString description() const; QString description() const;
/** /**
* @brief setDescription This method sets description for command. * @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); void setDescription(const QString &description);
/** /**
* @brief example This is exmaple of using this command. * @brief example This is exmaple of using this command.
* @return example of use. * @return Example of use.
*/ */
QString example() const; 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. * @param example This is a new example value.
*/ */
void setExample(const QString &example); void setExample(const QString &example);
/** /**
* @brief toString This is general method of the converting command to string. * @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; QString toString() const;

@ -27,9 +27,9 @@ class Service : public ServiceBase
public: public:
/** /**
* @brief Service * @brief Service
* @param argc - count params * @param argc - Count params.
* @param argv - test of arguments * @param argv - Test of arguments.
* @param name - name of your service * @param name - Name of your service.
*/ */
Service(int argc, char *argv[], const QString &name) Service(int argc, char *argv[], const QString &name)
: ServiceBase(argc, argv, name) { : ServiceBase(argc, argv, name) {

@ -25,9 +25,9 @@ class PATRONUM_LIBRARYSHARED_EXPORT ServiceBase : protected IService
public: public:
/** /**
* @brief Service * @brief Service
* @param argc - count params * @param argc - Count params.
* @param argv - test of arguments * @param argv - Test of arguments.
* @param name - name of your service * @param name - Name of your service.
*/ */
ServiceBase(int argc, char *argv[], const QString &name); ServiceBase(int argc, char *argv[], const QString &name);
@ -36,72 +36,72 @@ public:
/** /**
* @brief exec * @brief exec
* @return result of work application * @return Result of work application.
*/ */
virtual int exec(); virtual int exec();
protected: protected:
/** /**
* @brief handleReceiveData - this method invoce when service receive new command from terminal of controller of this service. * @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 * @param data - Is list of commands from controller.
* Default inplementation send message abount error, and invoke the . * Default implementation send message about error, and invoke the.
*/ */
void handleReceiveData(const QSet<Feature> &data) override final; void handleReceiveData(const QSet<Feature> &data) override final;
/** /**
* @brief supportedFeatures * @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; QSet<Feature> supportedFeatures() override;
/** /**
* @brief sendResuylt - call this method for send responce from service to tour controller * @brief sendResuylt - Call this method for send responce from service to tour controller.
* @param result * @param result Message.
* @return true if data sendet is seccusseful * @return True if data sendet is seccusseful.
*/ */
bool sendResuylt(const QVariantMap &result); bool sendResuylt(const QVariantMap &result);
/** /**
* @brief sendResuylt this method send text responce to controller * @brief sendResuylt This method send text responce to controller.
* @param result - message * @param result - Message.
* @return true if data sendet is seccusseful * @return True if data sendet is seccusseful.
*/ */
bool sendResuylt(const QString &result); bool sendResuylt(const QString &result);
/** /**
* @brief sendCloseeConnetion This method send signal that all request command processed. * @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(); 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; 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; 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; 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; 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; void onPause() override;
/** /**
* @brief controller * @brief controller
* @return own controller instance; * @return Own controller instance.
*/ */
Controller *controller(); Controller *controller();

@ -12,7 +12,7 @@
#include "PService.h" #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 {} namespace Patronum {}
#endif // PATRONUM_H #endif // PATRONUM_H