3232#include < vector>
3333#include < iostream>
3434#include < sstream>
35- #include < climits>
3635#include < cmath>
3736#include < thread>
3837#include < map>
4645#include < bitset>
4746#include < mutex>
4847#include < atomic>
49- #include < algorithm>
5048#include < deque>
5149#include < condition_variable>
5250#include < chrono>
@@ -64,7 +62,7 @@ extern "C" {
6462#define UNIT_TESTS
6563
6664// /The size of the circular buffer. Must be contiguous set bits defining the size 0b1111111111111 == 8191
67- # define CIRCULAR_BUFFER_SIZE 0b1111111111111
65+ constexpr uint16_t CIRCULAR_BUFFER_SIZE = 0b1111111111111 ;
6866
6967// / Flag defines used py EFP
7068#define NO_FLAGS 0b00000000 // Normal operation
@@ -75,8 +73,9 @@ extern "C" {
7573#define PRIORITY_P3 0b01100000 // God-mode priority (not implemented)
7674#define UNDEFINED_FLAG 0b10000000 // TBD
7775
78- #define EFP_MAJOR_VERSION 0
79- #define EFP_MINOR_VERSION 4
76+ constexpr uint8_t EFP_MAJOR_VERSION = 0 ;
77+ constexpr uint8_t EFP_MINOR_VERSION = 4 ;
78+ constexpr uint16_t EFP_VERSION = static_cast <uint16_t >(EFP_MAJOR_VERSION) << 8 | EFP_MINOR_VERSION;
8079
8180// Bitwise operations are used on members therefore the namespace is wrapping enum instead of 'enum class'
8281// / Definition of the data types supported by EFP
@@ -220,7 +219,7 @@ class ElasticFrameProtocolSender {
220219 virtual ~ElasticFrameProtocolSender ();
221220
222221 // /Return the version of the current implementation (Uint16)((8 MSB Major) + (8 LSB Minor))
223- uint16_t getVersion () { return (( uint16_t )EFP_MAJOR_VERSION << 8 ) | ( uint16_t )EFP_MINOR_VERSION ; }
222+ static uint16_t getVersion () { return EFP_VERSION ; }
224223
225224 /* *
226225 * Converts the original data from a vector to EFP packets/fragments
@@ -343,7 +342,7 @@ class ElasticFrameProtocolSender {
343342private:
344343 // Private methods ----- START ------
345344 // Used by the C - API
346- void sendData (const std::vector<uint8_t > &rSubPacket, uint8_t lStreamID, ElasticFrameProtocolContext* pCTX);
345+ void sendData (const std::vector<uint8_t > &rSubPacket, uint8_t lStreamID, ElasticFrameProtocolContext* pCTX) const ;
347346 // Private methods ----- END ------
348347
349348 // Internal lists and variables ----- START ------
@@ -439,8 +438,7 @@ class ElasticFrameProtocolReceiver {
439438 virtual ~ElasticFrameProtocolReceiver ();
440439
441440 // /Return the version of the current implementation
442- uint16_t getVersion () { return ((uint16_t )EFP_MAJOR_VERSION << 8 ) | (uint16_t )EFP_MINOR_VERSION; }
443-
441+ static uint16_t getVersion () { return EFP_VERSION; }
444442 /* *
445443 * Function assembling received fragments from a vector
446444 *
@@ -593,7 +591,7 @@ class ElasticFrameProtocolReceiver {
593591 ElasticFrameMessages stopReceiver ();
594592
595593 // C-API callback. If C++ is used this is a dummy callback
596- void gotData (pFramePtr &rPacket, ElasticFrameProtocolContext* pCTX);
594+ void gotData (pFramePtr &rPacket, ElasticFrameProtocolContext* pCTX) const ;
597595
598596 // Method unpacking Type1 fragments
599597 ElasticFrameMessages unpackType1 (const uint8_t *pSubPacket, size_t lPacketSize, uint8_t lFromSource);
0 commit comments