diff options
Diffstat (limited to 'remote-processor/Message.h')
-rw-r--r-- | remote-processor/Message.h | 64 |
1 files changed, 50 insertions, 14 deletions
diff --git a/remote-processor/Message.h b/remote-processor/Message.h index 2e52c09..3f5e847 100644 --- a/remote-processor/Message.h +++ b/remote-processor/Message.h @@ -64,25 +64,61 @@ public: protected: // Msg Id uint8_t getMsgId() const; - // Data - void writeData(const void* pvData, uint32_t uiSize); - void readData(void* pvData, uint32_t uiSize); + + /** Write raw data to the message + * + * @param[in] pvData pointer to the data array + * @param[in] uiSize array size in bytes + */ + void writeData(const void* pvData, size_t uiSize); + + /** Read raw data from the message + * + * @param[out] pvData pointer to the data array + * @param[in] uiSize array size in bytes + */ + void readData(void* pvData, size_t uiSize); + + /** Write string to the message + * + * @param[in] strData the string to write + */ void writeString(const std::string& strData); + + /** Write string to the message + * + * @param[out] strData the string to read to + */ void readString(std::string& strData); - uint32_t getStringSize(const std::string& strData) const; - // Remaining data size - uint32_t getRemainingDataSize() const; + + /** @return string length plus room to store its length + * + * @param[in] strData the string to get the size from + */ + size_t getStringSize(const std::string& strData) const; + + /** @return remaining data size to read or to write depending on the context + * (request: write, answer: read) + */ + size_t getRemainingDataSize() const; private: CMessage(const CMessage&); CMessage& operator=(const CMessage&); - // Data allocation - void allocateData(uint32_t uiDataSize); + + /** Allocate room to store the message + * + * @param[int] uiDataSize the szie to allocate in bytes + */ + void allocateData(size_t uiDataSize); // Fill data to send virtual void fillDataToSend() = 0; // Collect received data virtual void collectReceivedData() = 0; - // Size - virtual uint32_t getDataSize() const = 0; + + /** @return size of the transaction data in bytes + */ + virtual size_t getDataSize() const = 0; + // Checksum uint8_t computeChecksum() const; @@ -90,8 +126,8 @@ private: uint8_t _ucMsgId; // Data uint8_t* _pucData; - // Data size - uint32_t _uiDataSize; - // Read/Write Index - uint32_t _uiIndex; + /** Size of the allocated memory to store the message */ + size_t _uiDataSize; + /** Read/Write Index used to iterate across the message data */ + size_t _uiIndex; }; |