Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed logging when objects are constructed and destructed #19

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
223 changes: 108 additions & 115 deletions ElasticFrameProtocol.cpp

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions ElasticFrameProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <vector>
#include <iostream>
#include <sstream>
#include <climits>
#include <cmath>
#include <thread>
#include <map>
Expand All @@ -46,7 +45,6 @@
#include <bitset>
#include <mutex>
#include <atomic>
#include <algorithm>
#include <deque>
#include <condition_variable>
#include <chrono>
Expand All @@ -64,7 +62,7 @@ extern "C" {
#define UNIT_TESTS

///The size of the circular buffer. Must be contiguous set bits defining the size 0b1111111111111 == 8191
#define CIRCULAR_BUFFER_SIZE 0b1111111111111
constexpr uint16_t CIRCULAR_BUFFER_SIZE = 0b1111111111111;

/// Flag defines used py EFP
#define NO_FLAGS 0b00000000 // Normal operation
Expand All @@ -75,8 +73,9 @@ extern "C" {
#define PRIORITY_P3 0b01100000 // God-mode priority (not implemented)
#define UNDEFINED_FLAG 0b10000000 // TBD

#define EFP_MAJOR_VERSION 0
#define EFP_MINOR_VERSION 4
constexpr uint8_t EFP_MAJOR_VERSION = 0;
constexpr uint8_t EFP_MINOR_VERSION = 4;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we increase version, just for the record? After all, you have made some changes, most of them (hopefully) not noticeable, except for the removed loggings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR should not have changed the behavior of the repo, not even fixed any bugs, so I would argue this would not bump the version number. This PR ought to just be a refactorization of the code style.
And the logs should not have been used for anything except manual debugging, so no need to bump the version because of them, if you ask me.

constexpr uint16_t EFP_VERSION = static_cast<uint16_t>(EFP_MAJOR_VERSION) << 8 | EFP_MINOR_VERSION;

// Bitwise operations are used on members therefore the namespace is wrapping enum instead of 'enum class'
/// Definition of the data types supported by EFP
Expand Down Expand Up @@ -220,7 +219,7 @@ class ElasticFrameProtocolSender {
virtual ~ElasticFrameProtocolSender();

///Return the version of the current implementation (Uint16)((8 MSB Major) + (8 LSB Minor))
uint16_t getVersion() { return ((uint16_t)EFP_MAJOR_VERSION << 8) | (uint16_t)EFP_MINOR_VERSION; }
static uint16_t getVersion() { return EFP_VERSION; }

/**
* Converts the original data from a vector to EFP packets/fragments
Expand Down Expand Up @@ -343,7 +342,7 @@ class ElasticFrameProtocolSender {
private:
//Private methods ----- START ------
// Used by the C - API
void sendData(const std::vector<uint8_t> &rSubPacket, uint8_t lStreamID, ElasticFrameProtocolContext* pCTX);
void sendData(const std::vector<uint8_t> &rSubPacket, uint8_t lStreamID, ElasticFrameProtocolContext* pCTX) const;
//Private methods ----- END ------

// Internal lists and variables ----- START ------
Expand Down Expand Up @@ -439,8 +438,7 @@ class ElasticFrameProtocolReceiver {
virtual ~ElasticFrameProtocolReceiver();

///Return the version of the current implementation
uint16_t getVersion() { return ((uint16_t)EFP_MAJOR_VERSION << 8) | (uint16_t)EFP_MINOR_VERSION; }

static uint16_t getVersion() { return EFP_VERSION; }
/**
* Function assembling received fragments from a vector
*
Expand Down Expand Up @@ -593,7 +591,7 @@ class ElasticFrameProtocolReceiver {
ElasticFrameMessages stopReceiver();

// C-API callback. If C++ is used this is a dummy callback
void gotData(pFramePtr &rPacket, ElasticFrameProtocolContext* pCTX);
void gotData(pFramePtr &rPacket, ElasticFrameProtocolContext* pCTX) const;

// Method unpacking Type1 fragments
ElasticFrameMessages unpackType1(const uint8_t *pSubPacket, size_t lPacketSize, uint8_t lFromSource);
Expand Down
8 changes: 4 additions & 4 deletions efp_c_api/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void send_data_callback(const uint8_t *data, size_t size, uint8_t stream_id, voi
}

void receive_embedded_data_callback(uint8_t *data, size_t size, uint8_t data_type, uint64_t pts, void* ctx) {
printf("Got embedded data: %zu bytes size and of type %d pts: %llu\n", size, data_type, pts);
printf("Got embedded data: %zu bytes size and of type %d pts: %lu\n", size, data_type, pts);
//In this example we know it's a string, print it.
printf("Data: %s \n", data);
printf("Context: %d \n\n", *(int*)ctx);
Expand Down Expand Up @@ -72,8 +72,8 @@ void receive_data_callback(uint8_t *data,
printf("mFrameSize: %zu\n", size);
printf("mDataContent: %d\n", data_content);
printf("mBroken: %d\n", broken);
printf("mPts: %llu\n", pts);
printf("mDts: %llu\n", dts);
printf("mPts: %lu\n", pts);
printf("mDts: %lu\n", dts);
printf("mCode: %d\n", code);
printf("mStreamID: %d\n", stream_id);
printf("mSource: %d\n", source);
Expand Down Expand Up @@ -180,4 +180,4 @@ int main() {
}

return 0;
}
}
4 changes: 2 additions & 2 deletions logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (g == (LOGG_NOTIFY & (LOGG_MASK))) {a << "Notification: ";} \
else if (g == (LOGG_WARN & (LOGG_MASK))) {a << "Warning: ";} \
else if (g == (LOGG_ERROR & (LOGG_MASK))) {a << "Error: ";} \
else if (g == (LOGG_FATAL & (LOGG_MASK))) {a << "Fatal: ";} \
if (a.str().length()) { \
if (!a.str().empty()) { \
if (l) {a << __FILE__ << " " << __LINE__ << " ";} \
a << f << std::endl; \
std::cout << a.str(); \
Expand All @@ -31,4 +31,4 @@ std::cout << a.str(); \
#define EFP_LOGGER(l,g,f)
#endif

#endif
#endif
1 change: 1 addition & 0 deletions unitTests/UnitTest14.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <memory>

#include "ElasticFrameProtocol.h"
Expand Down
1 change: 1 addition & 0 deletions unitTests/UnitTest15.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <memory>

#include "ElasticFrameProtocol.h"
Expand Down
1 change: 1 addition & 0 deletions unitTests/UnitTest16.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <memory>
#include <random>

Expand Down
1 change: 1 addition & 0 deletions unitTests/UnitTest17.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <memory>

#include "ElasticFrameProtocol.h"
Expand Down
1 change: 1 addition & 0 deletions unitTests/UnitTest19.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <memory>

#include "ElasticFrameProtocol.h"
Expand Down
1 change: 1 addition & 0 deletions unitTests/UnitTest21.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <memory>

#include "ElasticFrameProtocol.h"
Expand Down
3 changes: 2 additions & 1 deletion unitTests/UnitTest22.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <memory>

#include "ElasticFrameProtocol.h"
Expand Down Expand Up @@ -93,4 +94,4 @@ TEST(UnitTest22, HeadOfLineBlocking) {
}

EXPECT_EQ(dataReceived.load(), 4);
}
}
1 change: 1 addition & 0 deletions unitTests/UnitTest5.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <memory>

#include "ElasticFrameProtocol.h"
Expand Down
1 change: 1 addition & 0 deletions unitTests/UnitTest6.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <memory>

#include "ElasticFrameProtocol.h"
Expand Down
1 change: 1 addition & 0 deletions unitTests/UnitTest7.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <memory>

#include "ElasticFrameProtocol.h"
Expand Down
1 change: 1 addition & 0 deletions unitTests/UnitTest8.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <memory>

#include "ElasticFrameProtocol.h"
Expand Down
1 change: 1 addition & 0 deletions unitTests/UnitTest9.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include <algorithm>
#include <memory>

#include "ElasticFrameProtocol.h"
Expand Down
Loading