#ifndef ICONTROL_H #define ICONTROL_H #include #include #include "model/ultrasoundModule/type/ECommandType.h" #include "model/csm/type/EConsole.h" #include "model/csm/dto/CommandControl.h" /*****************************************************************************/ /** * @brief this is an abtract of controls, like buttons and rotaries * @author Mohammad Mohsen Talaie * @details * @date 12 jan 2021 */ /*****************************************************************************/ class ControlAbstract : public QObject { Q_OBJECT protected: bool _exist = false; bool _enable; quint8 _functionCode = 0; quint8 _ledFunctionCode; //This dictionary that store commands depend on csm state QMap > _commandList; /*****************************************************************************/ /** * @brief Dtor */ /*****************************************************************************/ virtual ~ControlAbstract() { } public: /*****************************************************************************/ /** * @brief this fuction return existance of an ControlAbstract. * @details in detaile this fuction is use full for console button to check its chield is exist * or not. * @return existance of ControlAbstract */ /*****************************************************************************/ bool isExist() const { return _exist; } /*****************************************************************************/ /** * @brief this fuction return enable situation of an ControlAbstract. * @details in detaile this fuction is use full for console button to check its chield is enable * or not. * @return enable situation of ControlAbstract */ /*****************************************************************************/ bool isEnable() const { return _enable; } /*****************************************************************************/ /** * @brief this function append command to command list of object. */ /*****************************************************************************/ void appendCommandList(const QString& csmState, const CommandControl_t& commandControl) { QList temp; if(!_commandList.contains(EConsole::stringToEConsoleEnum(csmState))) { temp.append(commandControl); _commandList.insert(EConsole::stringToEConsoleEnum(csmState), temp); } else { temp = _commandList[EConsole::stringToEConsoleEnum(csmState)]; temp.append(commandControl); _commandList[EConsole::stringToEConsoleEnum(csmState)] = temp; } } /*****************************************************************************/ /** * @brief this fuction sets the function code and led function code of Icontrol. */ /*****************************************************************************/ void setFunctionCodes(const quint8& functionCode, const quint8& ledFunctionCode) { _functionCode = functionCode; _ledFunctionCode = ledFunctionCode; _exist = true; } /*****************************************************************************/ /** * @brief return the function code of ControlAbstract */ /*****************************************************************************/ quint8 getFunctionCode() const { return _functionCode; } /*****************************************************************************/ /** * @brief return the led's function code of ControlAbstract */ /*****************************************************************************/ quint8 getLedFunctionCode() { return _ledFunctionCode; } virtual QList getCommandList(const EConsole::eConsoleState& csmState) = 0; virtual void enable() = 0; virtual void disable() = 0; virtual EConsole::eControlType getType() const = 0; }; #endif //ICONTROL_H