You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

57 lines
1.9 KiB

#ifndef USEVENTRECEIVER_H
#define USEVENTRECEIVER_H
#include <QObject>
#include "model/ultrasoundModule/type/CommandRequest.h"
#include "model/ultrasoundModule/type/CommandResponse.h"
#include "model/ultrasoundModule/type/ECommandResult.h"
/*************************************************************************************************/
//Helper macros
#define US_EVENT_RECEIVER(ACCESS) \
ACCESS: \
UsEventReceiver* _eventReceiver; \
public: \
UsEventReceiver* getEventReceiver() { return _eventReceiver; } \
#define US_EVENT_RECEIVER_INSTANTIATE \
_eventReceiver = new UsEventReceiver(metaObject()->className())
/*************************************************************************************************/
/**
* @brief The class is responsible for receiving commands
* @details This class with help of \see UsEventSender form the communication channel for commands
* between all \see US_MODULE s
* @author Hessamoddin Hediyehloo(H-4nd-H)
* @date 2019/8/5(1398/5/14)
*/
/*************************************************************************************************/
class UsEventReceiver : public QObject
{
Q_OBJECT
private:
QString _ownerName; // In contradiction to the composition rule
// this add a level of safety to app without calling
// actual functions of parent
public:
explicit UsEventReceiver (QString _ownerName);
void sendResponse(const CommandRequest &request,
ECommandResult::eCommandResult result);
void sendResponse(const CommandRequest &request,
ECommandResult::eCommandResult result,
QList<QVariant> args);
signals:
void commandResponse(const CommandResponse &reponse);
void commandRequest(const CommandRequest &request);
public slots:
void newCommandRequest(const CommandRequest &request);
};
#endif // USEVENTRECEIVER_H