Skip to content

Commit 957a072

Browse files
committed
Removed logging when objects are constructed and destructed
Changed from c-style casting to c++-style.
1 parent 3f72183 commit 957a072

15 files changed

+130
-127
lines changed

ElasticFrameProtocol.cpp

+108-115
Large diffs are not rendered by default.

ElasticFrameProtocol.h

+7-9
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include <vector>
3333
#include <iostream>
3434
#include <sstream>
35-
#include <climits>
3635
#include <cmath>
3736
#include <thread>
3837
#include <map>
@@ -46,7 +45,6 @@
4645
#include <bitset>
4746
#include <mutex>
4847
#include <atomic>
49-
#include <algorithm>
5048
#include <deque>
5149
#include <condition_variable>
5250
#include <chrono>
@@ -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 {
343342
private:
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);

logger.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if (g == (LOGG_NOTIFY & (LOGG_MASK))) {a << "Notification: ";} \
2121
else if (g == (LOGG_WARN & (LOGG_MASK))) {a << "Warning: ";} \
2222
else if (g == (LOGG_ERROR & (LOGG_MASK))) {a << "Error: ";} \
2323
else if (g == (LOGG_FATAL & (LOGG_MASK))) {a << "Fatal: ";} \
24-
if (a.str().length()) { \
24+
if (!a.str().empty()) { \
2525
if (l) {a << __FILE__ << " " << __LINE__ << " ";} \
2626
a << f << std::endl; \
2727
std::cout << a.str(); \
@@ -31,4 +31,4 @@ std::cout << a.str(); \
3131
#define EFP_LOGGER(l,g,f)
3232
#endif
3333

34-
#endif
34+
#endif

unitTests/UnitTest14.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <algorithm>
34
#include <memory>
45

56
#include "ElasticFrameProtocol.h"

unitTests/UnitTest15.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <algorithm>
34
#include <memory>
45

56
#include "ElasticFrameProtocol.h"

unitTests/UnitTest16.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <algorithm>
34
#include <memory>
45
#include <random>
56

unitTests/UnitTest17.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <algorithm>
34
#include <memory>
45

56
#include "ElasticFrameProtocol.h"

unitTests/UnitTest19.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <algorithm>
34
#include <memory>
45

56
#include "ElasticFrameProtocol.h"

unitTests/UnitTest21.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <algorithm>
34
#include <memory>
45

56
#include "ElasticFrameProtocol.h"

unitTests/UnitTest22.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <algorithm>
34
#include <memory>
45

56
#include "ElasticFrameProtocol.h"
@@ -93,4 +94,4 @@ TEST(UnitTest22, HeadOfLineBlocking) {
9394
}
9495

9596
EXPECT_EQ(dataReceived.load(), 4);
96-
}
97+
}

unitTests/UnitTest5.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <algorithm>
34
#include <memory>
45

56
#include "ElasticFrameProtocol.h"

unitTests/UnitTest6.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <algorithm>
34
#include <memory>
45

56
#include "ElasticFrameProtocol.h"

unitTests/UnitTest7.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <algorithm>
34
#include <memory>
45

56
#include "ElasticFrameProtocol.h"

unitTests/UnitTest8.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <algorithm>
34
#include <memory>
45

56
#include "ElasticFrameProtocol.h"

unitTests/UnitTest9.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <algorithm>
34
#include <memory>
45

56
#include "ElasticFrameProtocol.h"

0 commit comments

Comments
 (0)