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.

41 lines
1.4 KiB

#ifndef UTILS_H
#define UTILS_H
#define CLASS_NAME metaObject()->className()
#define INSTANCE(OBJ) OBJ::getInstance()
#define EVENT_SENDER(OBJ) OBJ::getInstance()->getEventSender()
#define EVENT_RECEIVER(OBJ) OBJ::getInstance()->getEventReceiver()
#define CONNECT_REQ_PATH(SENDER, RECEIVER) \
connect(EVENT_SENDER(SENDER), &UsEventSender::commandRequest, \
EVENT_RECEIVER(RECEIVER), &UsEventReceiver::newCommandRequest); \
connect(EVENT_RECEIVER(RECEIVER), &UsEventReceiver::commandResponse, \
EVENT_SENDER(SENDER), &UsEventSender::newCommandResponse);
#define CONNECT_RESPONSE_PATH(RECEIVER) \
connect(EVENT_RECEIVER(RECEIVER), &UsEventReceiver::commandResponse, \
_eventSender, &UsEventSender::newCommandResponse)
#define CONNECT_RESULT_PATH(SENDER, RECEIVER) \
connect(EVENT_SENDER(SENDER), \
&UsEventSender::commandResult, \
_eventReceiver, &UsEventReceiver::newCommandResult)
#define GET_COMMAND_TYPE(REQUEST) REQUEST.getCommandType()
#define COMMAND_TYPE(COMMAND) ECommandType::COMMAND
#define CHECK_COMMAND_TYPE(REQUEST, COMMAND) \
GET_COMMAND_TYPE(REQUEST) == COMMAND_TYPE(COMMAND)
#define SND_REQ_NO_ARG(command, ...) \
_eventSender->sendRequest(ECommandType::command, \
QVector<QString>({__VA_ARGS__}), \
QVector<QVariant>())
//#define GET_VALUE(REQUEST, INDEX, TYPE) REQUEST.getValueList()[INDEX].value<TYPE>()
#define PATH_CONCAT(P1, P2) P1 + "/" + P2
#endif // UTILS_H