diff --git a/src/vscp/common/mdf.cpp b/src/vscp/common/mdf.cpp index 410b671a6..1d0fbaa76 100644 --- a/src/vscp/common/mdf.cpp +++ b/src/vscp/common/mdf.cpp @@ -88,16 +88,13 @@ CMDF_Object::CMDF_Object(mdf_record_type type) m_type = type; } -CMDF_Object::~CMDF_Object() -{ - -} +CMDF_Object::~CMDF_Object() {} /////////////////////////////////////////////////////////////////////////////// // getObjectTypeString // -std::string +std::string CMDF_Object::getObjectTypeString() { switch (m_type) { @@ -112,10 +109,10 @@ CMDF_Object::getObjectTypeString() // getMdfObjectType // -mdf_record_type -CMDF_Object::getMdfObjectType() -{ - return m_type; +mdf_record_type +CMDF_Object::getMdfObjectType() +{ + return m_type; }; // ---------------------------------------------------------------------------- @@ -124,8 +121,8 @@ CMDF_Object::getMdfObjectType() // Constructor/Destructor // -CMDF_Value::CMDF_Value() : - CMDF_Object(mdf_type_value) +CMDF_Value::CMDF_Value() + : CMDF_Object(mdf_type_value) { m_name.clear(); m_strValue.clear(); @@ -143,8 +140,8 @@ CMDF_Value::~CMDF_Value() // Constructor/Destructor // -CMDF_RemoteVariable::CMDF_RemoteVariable() : - CMDF_Object(mdf_type_remotevar) +CMDF_RemoteVariable::CMDF_RemoteVariable() + : CMDF_Object(mdf_type_remotevar) { m_strDefault.clear(); m_type = remote_variable_type_unknown; @@ -322,8 +319,8 @@ CMDF_RemoteVariable::getTypeByteCount(void) // Constructor/Destructor // -CMDF_Bit::CMDF_Bit() : - CMDF_Object(mdf_type_bit) +CMDF_Bit::CMDF_Bit() + : CMDF_Object(mdf_type_bit) { m_name.clear(); m_pos = 0; @@ -394,7 +391,7 @@ CMDF_Bit::setWidth(uint8_t width) for (int k = m_pos; k < (m_pos + m_width); k++) { m_mask |= (1 << k); } - + m_min = m_min & m_mask; m_max = m_max & m_mask; } @@ -403,13 +400,13 @@ CMDF_Bit::setWidth(uint8_t width) // setPos // -void +void CMDF_Bit::setPos(uint8_t pos) -{ - m_pos = (pos & 7); +{ + m_pos = (pos & 7); // Make sure width get masked - setWidth(m_width); + setWidth(m_width); } /////////////////////////////////////////////////////////////////////////////// @@ -438,8 +435,8 @@ CMDF_Bit::setMax(uint8_t max) // Constructor/Destructor // -CMDF_Register::CMDF_Register() : - CMDF_Object(mdf_type_register) +CMDF_Register::CMDF_Register() + : CMDF_Object(mdf_type_register) { m_page = 0; m_offset = 0; @@ -608,8 +605,8 @@ CMDF_Register::operator=(const CMDF_Register &other) // Constructor/Destructor // -CMDF_ActionParameter::CMDF_ActionParameter() : - CMDF_Object(mdf_type_action_param) +CMDF_ActionParameter::CMDF_ActionParameter() + : CMDF_Object(mdf_type_action_param) { m_name.clear(); m_offset = 0; @@ -666,8 +663,8 @@ CMDF_ActionParameter::clearStorage(void) // Constructor/Destructor // -CMDF_Action::CMDF_Action() : - CMDF_Object(mdf_type_action) +CMDF_Action::CMDF_Action() + : CMDF_Object(mdf_type_action) { m_name.clear(); m_code = 0; @@ -710,8 +707,8 @@ CMDF_Action::clearStorage(void) // Constructor/Destructor // -CMDF_DecisionMatrix::CMDF_DecisionMatrix() : - CMDF_Object(mdf_type_decision_matrix) +CMDF_DecisionMatrix::CMDF_DecisionMatrix() + : CMDF_Object(mdf_type_decision_matrix) { m_level = 1; m_startPage = 0; @@ -745,8 +742,8 @@ CMDF_DecisionMatrix::clearStorage() // Constructor/Destructor // -CMDF_EventData::CMDF_EventData() : - CMDF_Object(mdf_type_event_data) +CMDF_EventData::CMDF_EventData() + : CMDF_Object(mdf_type_event_data) { m_name.clear(); m_offset = 0; @@ -797,8 +794,8 @@ CMDF_EventData::clearStorage() // Constructor/Destructor // -CMDF_Event::CMDF_Event() : - CMDF_Object(mdf_type_event) +CMDF_Event::CMDF_Event() + : CMDF_Object(mdf_type_event) { m_name.clear(); m_class = 0; @@ -844,8 +841,8 @@ CMDF_Event::clearStorage() // Constructor/Destructor // -CMDF_Item::CMDF_Item() : - CMDF_Object(mdf_type_value_item) +CMDF_Item::CMDF_Item() + : CMDF_Object(mdf_type_value_item) { m_value.clear(); } @@ -859,8 +856,8 @@ CMDF_Item::~CMDF_Item() // Constructor/Destructor // -CMDF_BootLoaderInfo::CMDF_BootLoaderInfo() : - CMDF_Object(mdf_type_bootloader) +CMDF_BootLoaderInfo::CMDF_BootLoaderInfo() + : CMDF_Object(mdf_type_bootloader) { m_nAlgorithm = 0; m_nBlockSize = 0; @@ -888,8 +885,8 @@ CMDF_BootLoaderInfo::clearStorage(void) // Constructor/Destructor // -CMDF_Address::CMDF_Address() : - CMDF_Object(mdf_type_address) +CMDF_Address::CMDF_Address() + : CMDF_Object(mdf_type_address) { clearStorage(); } @@ -919,8 +916,8 @@ CMDF_Address::clearStorage(void) // Constructor/Destructor // -CMDF_Manufacturer::CMDF_Manufacturer() : - CMDF_Object(mdf_type_manufacturer) +CMDF_Manufacturer::CMDF_Manufacturer() + : CMDF_Object(mdf_type_manufacturer) { clearStorage(); } @@ -998,17 +995,14 @@ CMDF_Manufacturer::clearStorage(void) // Constructor/Destructor // -CMDF_Picture::CMDF_Picture() : - CMDF_Object(mdf_type_picture) +CMDF_Picture::CMDF_Picture() + : CMDF_Object(mdf_type_picture) { clearStorage(); m_strName = ""; // default name } -CMDF_Picture::~CMDF_Picture() -{ - ; -} +CMDF_Picture::~CMDF_Picture() {} /////////////////////////////////////////////////////////////////////////////// // clearStorage @@ -1029,8 +1023,8 @@ CMDF_Picture::clearStorage(void) // Constructor/Destructor // -CMDF_Video::CMDF_Video() : - CMDF_Object(mdf_type_video) +CMDF_Video::CMDF_Video() + : CMDF_Object(mdf_type_video) { clearStorage(); } @@ -1059,8 +1053,8 @@ CMDF_Video::clearStorage(void) // Constructor/Destructor // -CMDF_Firmware::CMDF_Firmware() : - CMDF_Object(mdf_type_firmware) +CMDF_Firmware::CMDF_Firmware() + : CMDF_Object(mdf_type_firmware) { clearStorage(); } @@ -1094,12 +1088,35 @@ CMDF_Firmware::clearStorage(void) m_mapInfoURL.clear(); } +/////////////////////////////////////////////////////////////////////////////// +// setVersion +// + +void +CMDF_Firmware::setVersion(const std::string &ver) +{ + std::deque vector; + vscp_split(vector, ver, "."); + + if (vector.size() >= 1) { + m_version_major = vscp_readStringValue(vector[0]); + } + + if (vector.size() >= 2) { + m_version_minor = vscp_readStringValue(vector[1]); + } + + if (vector.size() >= 3) { + m_version_patch = vscp_readStringValue(vector[2]); + } +} + /////////////////////////////////////////////////////////////////////////////// // Constructor/Destructor // -CMDF_Driver::CMDF_Driver() : - CMDF_Object(mdf_type_driver) +CMDF_Driver::CMDF_Driver() + : CMDF_Object(mdf_type_driver) { clearStorage(); } @@ -1134,12 +1151,35 @@ CMDF_Driver::clearStorage(void) m_mapInfoURL.clear(); } +/////////////////////////////////////////////////////////////////////////////// +// setVersion +// + +void +CMDF_Driver::setVersion(const std::string &ver) +{ + std::deque vector; + vscp_split(vector, ver, "."); + + if (vector.size() >= 1) { + m_version_major = vscp_readStringValue(vector[0]); + } + + if (vector.size() >= 2) { + m_version_minor = vscp_readStringValue(vector[1]); + } + + if (vector.size() >= 3) { + m_version_patch = vscp_readStringValue(vector[2]); + } +} + /////////////////////////////////////////////////////////////////////////////// // Constructor/Destructor // -CMDF_Manual::CMDF_Manual() : - CMDF_Object(mdf_type_manual) +CMDF_Manual::CMDF_Manual() + : CMDF_Object(mdf_type_manual) { clearStorage(); } @@ -1168,8 +1208,8 @@ CMDF_Manual::clearStorage(void) // Constructor/Destructor // -CMDF_Setup::CMDF_Setup() : - CMDF_Object(mdf_type_setup) +CMDF_Setup::CMDF_Setup() + : CMDF_Object(mdf_type_setup) { clearStorage(); } @@ -1200,8 +1240,8 @@ CMDF_Setup::clearStorage(void) // Constructor/Destructor // -CMDF::CMDF() : - CMDF_Object(mdf_type_mdf) +CMDF::CMDF() + : CMDF_Object(mdf_type_mdf) { m_strLocale = "en"; m_vscpLevel = VSCP_LEVEL1; @@ -1619,11 +1659,11 @@ __getBitAttributes(std::deque *pbitlist, const char **attr) pBits->m_name = attribute; } else if (0 == strcasecmp(attr[i], "pos")) { - //pBits->m_pos = vscp_readStringValue(attribute); + // pBits->m_pos = vscp_readStringValue(attribute); pBits->setPos(vscp_readStringValue(attribute)); } else if (0 == strcasecmp(attr[i], "width")) { - //pBits->m_width = vscp_readStringValue(attribute); + // pBits->m_width = vscp_readStringValue(attribute); pBits->setWidth(vscp_readStringValue(attribute)); } else if (0 == strcasecmp(attr[i], "default")) { @@ -5234,12 +5274,12 @@ CMDF::getBitList(json &j, std::deque &list) } if (j.contains("pos") && j["pos"].is_number()) { - //pbit->m_pos = j["pos"]; + // pbit->m_pos = j["pos"]; pbit->setPos(j["pos"]); spdlog::debug("Parse-JSON: Bitlist pos: {0}", pbit->m_pos); } else if (j.contains("pos") && j["pos"].is_string()) { - //pbit->m_pos = vscp_readStringValue(j["pos"]); + // pbit->m_pos = vscp_readStringValue(j["pos"]); pbit->setPos(vscp_readStringValue(j["pos"])); spdlog::debug("Parse-JSON: Bitlist pos: {0}", pbit->m_pos); } @@ -5249,12 +5289,12 @@ CMDF::getBitList(json &j, std::deque &list) } if (j.contains("width") && j["width"].is_number()) { - //pbit->m_width = j["width"]; + // pbit->m_width = j["width"]; pbit->setWidth(j["width"]); spdlog::debug("Parse-JSON: Bitlist width: {0}", pbit->m_width); } else if (j.contains("width") && j["width"].is_string()) { - //pbit->m_width = vscp_readStringValue(j["width"]); + // pbit->m_width = vscp_readStringValue(j["width"]); pbit->setWidth(vscp_readStringValue(j["width"])); spdlog::debug("Parse-JSON: Bitlist width: {0}", pbit->m_width); } @@ -7704,7 +7744,44 @@ CMDF::getRegisterMap(uint16_t page, std::map &mapRegs } /////////////////////////////////////////////////////////////////////////////// -// getRegisterList +// deleteRegister +// + +bool +CMDF::deleteRegister(CMDF_Register *preg) +{ + // Check pointer + if (nullptr == preg) { + return false; + } + + for (auto it = m_list_register.cbegin(); it != m_list_register.cend(); ++it) { + if (preg == *it) { + m_list_register.erase(it); + return true; + } + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// +// createRegisterStortedSet +// + +void +CMDF::createRegisterStortedSet(std::set &set, uint16_t page) +{ + std::deque *regset = getRegisterObjList(); + for (auto it = regset->cbegin(); it != regset->cend(); ++it) { + if (page == (*it)->getPage()) { + set.insert((*it)->getOffset()); + } + } +} + +/////////////////////////////////////////////////////////////////////////////// +// format // std::string & diff --git a/src/vscp/common/mdf.h b/src/vscp/common/mdf.h index b243ac6e8..7e70f1e1b 100644 --- a/src/vscp/common/mdf.h +++ b/src/vscp/common/mdf.h @@ -110,6 +110,7 @@ typedef enum mdf_record_type { mdf_type_bit_item, mdf_type_register, mdf_type_register_item, + mdf_type_register_sub_item, mdf_type_register_page, mdf_type_remotevar, mdf_type_remotevar_item, @@ -141,20 +142,25 @@ typedef enum mdf_record_type { mdf_type_web_item, mdf_type_social, mdf_type_social_item, - mdf_type_file, - mdf_type_file_item, - mdf_type_picture, - mdf_type_picture_item, - mdf_type_video, - mdf_type_video_item, - mdf_type_firmware, - mdf_type_firmware_item, - mdf_type_driver, - mdf_type_driver_item, - mdf_type_setup, - mdf_type_setup_item, - mdf_type_manual, - mdf_type_manual_item, + mdf_type_file, // File header - "File" + mdf_type_picture, // Picture head - "Pictures" + mdf_type_picture_item, // Picture object "Picture: some name" + mdf_type_picture_sub_item, // Picture content + mdf_type_video, // Video head - "Video" + mdf_type_video_item, // Video object - "Video : some name" + mdf_type_video_sub_item, // Video content + mdf_type_firmware, // Firmware head - "Firmware" + mdf_type_firmware_item, // Firmware object "Firmware: some name" + mdf_type_firmware_sub_item, // Firmware content + mdf_type_driver, // Driver head - "Driver" + mdf_type_driver_item, // Driver object - "Driver: some name" + mdf_type_driver_sub_item, // Diver content + mdf_type_setup, // Setup head - "Setup Script" + mdf_type_setup_item, // Setup object - "Setup: some name" + mdf_type_setup_sub_item, // Setup content + mdf_type_manual, // Manual head - "Manual" + mdf_type_manual_item, // Manula object - "Manual: some name" + mdf_type_manual_sub_item, // Manual content" mdf_type_redirection, mdf_type_alarm, mdf_type_generic_string, // Used for direct item editing @@ -523,13 +529,13 @@ class CMDF_Register : public CMDF_Object { Get the register name @return Register name */ - std::string &getName(void) { return m_name; }; + std::string getName(void) { return m_name; }; /*! Set register name @param name Register name to set */ - void setName(std::string &name) { m_name = name; }; + void setName(const std::string &name) { m_name = name; }; /*! Get the register description @@ -542,7 +548,7 @@ class CMDF_Register : public CMDF_Object { @param lang Language @param desc Register description to set */ - void setDescription(std::string &lang, std::string &desc) { m_mapDescription[lang] = desc; }; + void setDescription(const std::string &lang, const std::string &desc) { m_mapDescription[lang] = desc; }; /*! Get the register info URL @@ -555,7 +561,7 @@ class CMDF_Register : public CMDF_Object { @param lang Language @param url Register info URL to set */ - void setInfoURL(std::string &lang, std::string &url) { m_mapInfoURL[lang] = url; }; + void setInfoURL(const std::string &lang, const std::string &url) { m_mapInfoURL[lang] = url; }; /*! Get register default string @@ -576,7 +582,7 @@ class CMDF_Register : public CMDF_Object { Set register default @param str Default string to set */ - void setDefault(std::string &str) { m_strDefault = str; }; + void setDefault(const std::string &str) { m_strDefault = str; }; /*! Set register default @@ -663,12 +669,14 @@ class CMDF_Register : public CMDF_Object { void setWidth(uint32_t width) { m_width = width; }; /*! + *** Deprectated *** Get size for register @return Size for register. */ uint32_t getSize(void) { return m_span; }; /*! + *** Deprcated *** Set size for register @param size Size for register. */ @@ -1942,6 +1950,12 @@ class CMDF_Manufacturer : public CMDF_Object { */ CMDF_Item *getPhoneObj(size_t index = 0) { return ((m_list_Phone.size() <= index) ? nullptr : m_list_Phone[index]); }; + /*! + Get number of phone elements + @return Number of phone elements + */ + size_t getPhoneObjCount(void) { return m_list_Phone.size(); }; + /*! Get a fax object from it's index @param index Index of fax objext to get. @@ -1949,6 +1963,12 @@ class CMDF_Manufacturer : public CMDF_Object { */ CMDF_Item *getFaxObj(size_t index = 0) { return ((m_list_Fax.size() <= index) ? nullptr : m_list_Fax[index]); }; + /*! + Get number of fax elements + @return Number of fax elements + */ + size_t getFaxObjCount(void) { return m_list_Fax.size(); }; + /*! Get a email object from it's index @param index Index of email object to get. @@ -1956,6 +1976,12 @@ class CMDF_Manufacturer : public CMDF_Object { */ CMDF_Item *getEmailObj(size_t index = 0) { return ((m_list_Email.size() <= index) ? nullptr : m_list_Email[index]); }; + /*! + Get number of email elements + @return Number of email elements + */ + size_t getEmailObjCount(void) { return m_list_Email.size(); }; + /*! Get a web object from it's index @param index Index of web object to get. @@ -1963,6 +1989,12 @@ class CMDF_Manufacturer : public CMDF_Object { */ CMDF_Item *getWebObj(size_t index = 0) { return ((m_list_Web.size() <= index) ? nullptr : m_list_Web[index]); }; + /*! + Get number of web elements + @return Number of web elements + */ + size_t getWebObjCount(void) { return m_list_Web.size(); }; + /*! Get a social object from it's index @param index Index of web object to get. @@ -1973,6 +2005,12 @@ class CMDF_Manufacturer : public CMDF_Object { return ((m_list_Social.size() <= index) ? nullptr : m_list_Social[index]); }; + /*! + Get number of social elements + @return Number of social elements + */ + size_t getSocialObjCount(void) { return m_list_Social.size(); }; + /*! Get pointer to list for phone contact item @ſeturn Pointer to phone contact list @@ -2081,7 +2119,23 @@ class CMDF_Picture : public CMDF_Object { Set date for object @param isodate Date for object oin ISO string form. */ - void setDate(const std::string& isodate) { m_strDate = isodate; }; + void setDate(const std::string &isodate) { m_strDate = isodate; }; + + /*! + Assignment + */ + CMDF_Picture &operator=(const CMDF_Picture &other) + { + // Guard self assignment + if (this == &other) { + return *this; + } + m_strName = other.m_strName; + m_strURL = other.m_strURL; + m_strFormat = other.m_strFormat; + m_strDate = other.m_strDate; + return *this; + }; /*! Set description for picture @@ -2144,7 +2198,6 @@ class CMDF_Picture : public CMDF_Object { */ std::string m_strDate; - /*! Description of file */ @@ -2219,7 +2272,23 @@ class CMDF_Video : public CMDF_Object { Set date for object @param isodate Date for object oin ISO string form. */ - void setDate(const std::string& isodate) { m_strDate = isodate; }; + void setDate(const std::string &isodate) { m_strDate = isodate; }; + + /*! + Assignment + */ + CMDF_Video &operator=(const CMDF_Video &other) + { + // Guard self assignment + if (this == &other) { + return *this; + } + m_strName = other.m_strName; + m_strURL = other.m_strURL; + m_strFormat = other.m_strFormat; + m_strDate = other.m_strDate; + return *this; + }; /*! Set description for video @@ -2290,7 +2359,6 @@ class CMDF_Video : public CMDF_Object { */ std::string m_strDate; - /*! Description of file */ @@ -2344,6 +2412,12 @@ class CMDF_Firmware : public CMDF_Object { */ std::string getUrl(void) { return m_strURL; }; + /*! + Set URL + @param url URL to set + */ + void setUrl(std::string &url) { m_strURL = url; }; + /*! Get target string for firmware @return Target string for firmware @@ -2356,12 +2430,24 @@ class CMDF_Firmware : public CMDF_Object { */ uint16_t getTargetCode(void) { return m_targetCode; }; + /*! + Set target code + @param code + */ + void setTargetCode(uint16_t code) { m_targetCode = code; }; + /*! Get hex file string format for firmware @return Hex string format */ std::string getFormat(void) { return m_strFormat; }; + /*! + Set format + @param format Format to set + */ + void setFormat(const std::string &format) { m_strFormat = format; }; + /* Get date for object @return date on ISO string format @@ -2372,7 +2458,7 @@ class CMDF_Firmware : public CMDF_Object { Set date for object @param isodate Date for object oin ISO string form. */ - void setDate(const std::string& isodate) { m_strDate = isodate; }; + void setDate(const std::string &isodate) { m_strDate = isodate; }; /*! Get version major for firmware @@ -2380,30 +2466,100 @@ class CMDF_Firmware : public CMDF_Object { */ uint16_t getVersionMajor(void) { return m_version_major; }; + /*! + Set major version + @param ver Major version to set + */ + void setVersionMajor(uint16_t ver) { m_version_major = ver; }; + /*! Get version minor for firmware @return Version minor for firmware */ uint16_t getVersionMinor(void) { return m_version_minor; }; + /*! + Set minor version + @param ver Minor version to set + */ + void setVersionMinor(uint16_t ver) { m_version_minor = ver; }; + /*! Get version patch for firmware @return Version patch for firmware */ uint16_t getVersionPatch(void) { return m_version_patch; }; + /*! + Set patch version + @param ver Patch version to set + */ + void setVersionPatch(uint16_t ver) { m_version_patch = ver; }; + + /*! + Get version on string form (x.y.z) + @return Version on string form + */ + std::string getVersion(void) + { + return (std::to_string(getVersionMajor()) + "." + std::to_string(getVersionMinor()) + "." + + std::to_string(getVersionPatch())); + }; + + /*! + Set version from string on form x.y.z + @param ver Version string + */ + void setVersion(const std::string &ver); + /*! Get size for firmware @return Version patch for firmware */ size_t getSize(void) { return m_size; }; + /*! + Set flash size + @param size Flash size to set + */ + void setSize(size_t size) { m_size = size; }; + /*! Get MD5 for firmware file on hex string format @return md5 hash for firmware file on string format. */ std::string getMd5(void) { return m_strMd5; }; + /*! + Set MD5 checksum + @param md5 MD5 checksum string to set + */ + + void setMd5(std::string &md5) { m_strMd5 = md5; }; + + /*! + Assignment + */ + CMDF_Firmware &operator=(const CMDF_Firmware &other) + { + // Guard self assignment + if (this == &other) { + return *this; + } + m_strName = other.m_strName; + m_strURL = other.m_strURL; + m_strTarget = other.m_strTarget; + m_targetCode = other.m_targetCode; + m_strFormat = other.m_strFormat; + m_strDate = other.m_strDate; + m_size = other.m_size; + m_version_major = other.m_version_major; + m_version_minor = other.m_version_minor; + m_version_patch = other.m_version_patch; + m_strMd5 = other.m_strMd5; + return *this; + }; + /*! Set description for firmware */ @@ -2545,8 +2701,8 @@ class CMDF_Driver : public CMDF_Object { std::string getName(void) { return m_strName; }; /*! - Set name of setup - @param strURL name + Set name of driver + @param name name */ void setName(std::string &name) { m_strName = name; }; @@ -2556,18 +2712,38 @@ class CMDF_Driver : public CMDF_Object { */ std::string getUrl(void) { return m_strURL; }; + /*! + Set URL of driver + @param url name + */ + void setUrl(std::string &url) { m_strURL = url; }; + /*! Get driver type for CMDF_Driver @return Target string for CMDF_Driver */ std::string getType(void) { return m_strType; }; + /*! + Set type of driver + @param type Type of driver + */ + void setType(std::string &type) { m_strType = type; }; + /*! Get driver type for CMDF_Driver @return Target string for CMDF_Driver */ std::string getArchitecture(void) { return m_strArchitecture; }; - std::string getFormat(void) { return m_strArchitecture; }; // Deprecated + + /*! + Set architecture of driver + @param arch Architecture of driver + */ + void setArchitecture(std::string &arch) { m_strArchitecture = arch; }; + + // Deprecated + std::string getFormat(void) { return m_strArchitecture; }; /*! Get OS (Operation System) for driver @@ -2575,36 +2751,88 @@ class CMDF_Driver : public CMDF_Object { */ std::string getOS(void) { return m_strOS; }; + /*! + Set OS of driver + @param os Type of driver + */ + void setOS(std::string &os) { m_strOS = os; }; + /*! Get OS version for the driver @return OS version for driver */ std::string getOSVer(void) { return m_strOSVer; }; + /*! + Set OS version of driver + @param osver Type of driver + */ + void setOSVer(std::string &osver) { m_strOSVer = osver; }; + /*! Get version major for driver @return Version major for driver */ uint16_t getVersionMajor(void) { return m_version_major; }; + /*! + Set major version of driver + @param ver Major version to set + */ + void setVersionMajor(uint16_t ver) { m_version_major = ver; }; + /*! Get version minor for driver @return Version minor for driver */ uint16_t getVersionMinor(void) { return m_version_minor; }; + /*! + Set minor version of driver + @param ver Major version to set + */ + void setVersionMinor(uint16_t ver) { m_version_minor = ver; }; + /*! Get version patch for driver @return Version patch for driver */ uint16_t getVersionPatch(void) { return m_version_patch; }; + /*! + Set patch version of Driver + @param ver Major version to set + */ + void setVersionPatch(uint16_t ver) { m_version_patch = ver; }; + + /*! + Get version on string format x.y.x + @return Version on string format + */ + std::string getVersion(void) + { + return (std::to_string(getVersionMajor()) + "." + std::to_string(getVersionMinor()) + "." + + std::to_string(getVersionPatch())); + }; + + /*! + Set version from string on form x.y.z + @param ver Version string + */ + void setVersion(const std::string &ver); + /*! Get MD5 for driver file on hex string format - @return md5 hash for driver file on string format. + @return md5 hash for driver file on string hex format. */ std::string getMd5(void) { return m_strMd5; }; + /*! + Set MD5 checksum + @param md5 MD5 checksum to set as hex string. + */ + void setMd5(const std::string& md5) {m_strMd5 = md5; }; + /* Get date for object @return date on ISO string format @@ -2615,7 +2843,30 @@ class CMDF_Driver : public CMDF_Object { Set date for object @param isodate Date for object oin ISO string form. */ - void setDate(const std::string& isodate) { m_strDate = isodate; }; + void setDate(const std::string &isodate) { m_strDate = isodate; }; + + /*! + Assignment + */ + CMDF_Driver &operator=(const CMDF_Driver &other) + { + // Guard self assignment + if (this == &other) { + return *this; + } + m_strName = other.m_strName; + m_strURL = other.m_strURL; + m_strType = other.m_strType; + m_strOS = other.m_strOS; + m_strOSVer = other.m_strOSVer; + m_strDate = other.m_strDate; + m_strArchitecture = other.m_strArchitecture; + m_version_major = other.m_version_major; + m_version_minor = other.m_version_minor; + m_version_patch = other.m_version_patch; + m_strMd5 = other.m_strMd5; + return *this; + }; /*! Set description for picture @@ -2779,6 +3030,23 @@ class CMDF_Setup : public CMDF_Object { */ void setFormat(std::string &strFormat) { m_strFormat = strFormat; }; + /*! + Assignment + */ + CMDF_Setup &operator=(const CMDF_Setup &other) + { + // Guard self assignment + if (this == &other) { + return *this; + } + m_strName = other.m_strName; + m_strURL = other.m_strURL; + m_strFormat = other.m_strFormat; + m_strDate = other.m_strDate; + m_strVersion = other.m_strVersion; + return *this; + }; + /*! Set description for setup */ @@ -2812,7 +3080,7 @@ class CMDF_Setup : public CMDF_Object { Set date for object @param isodate Date for object oin ISO string form. */ - void setDate(const std::string& isodate) { m_strDate = isodate; }; + void setDate(const std::string &isodate) { m_strDate = isodate; }; /*! Get the value info URL @@ -2911,18 +3179,36 @@ class CMDF_Manual : public CMDF_Object { */ std::string getUrl(void) { return m_strURL; }; + /*! + Set url + @param url URL to set. + */ + void setUrl(const std::string &url) { m_strURL = url; }; + /*! Get URL for firmware @return Manual format string. */ std::string getFormat(void) { return m_strFormat; }; + /*! + Set format + @param fmt Format to set. + */ + void setFormat(const std::string &fmt) { m_strFormat = fmt; }; + /*! Get language @return Manual language string */ std::string getLanguage(void) { return m_strLanguage; }; + /*! + Set language + @param lang Language on ISO string form to set. + */ + void setLanguage(const std::string &lang) { m_strLanguage = lang; }; + /* Get date for object @return date on ISO string format @@ -2933,7 +3219,24 @@ class CMDF_Manual : public CMDF_Object { Set date for object @param isodate Date for object oin ISO string form. */ - void setDate(const std::string& isodate) { m_strDate = isodate; }; + void setDate(const std::string &isodate) { m_strDate = isodate; }; + + /*! + Assignment + */ + CMDF_Manual &operator=(const CMDF_Manual &other) + { + // Guard self assignment + if (this == &other) { + return *this; + } + m_strName = other.m_strName; + m_strURL = other.m_strURL; + m_strFormat = other.m_strFormat; + m_strDate = other.m_strDate; + m_strLanguage = other.m_strLanguage; + return *this; + }; /*! Set description for manual item @@ -3432,6 +3735,19 @@ class CMDF : public CMDF_Object { */ std::deque *getRegisterObjList(void) { return &m_list_register; }; + /*! + Delete a defined register + @param preg Pointer to registere + @return True on success, false otherwise + */ + bool deleteRegister(CMDF_Register *preg); + + /*! + Create a set with sorted register offsets for a page + @param set a std_set with offset uint32_t items + */ + void createRegisterStortedSet(std::set& set, uint16_t page); + /*! Get all registers for a specific page @param page Page to get registers for.