diff --git a/common/cpp/include/common/networking.h b/common/cpp/include/common/networking.h index fb0fdadb6c72e00a5d96c6e4a6b1c5494d135ac5..590ccfa66ddf62c42fb55cd9feee84cb6083062d 100644 --- a/common/cpp/include/common/networking.h +++ b/common/cpp/include/common/networking.h @@ -4,41 +4,40 @@ #include <cstdint> #include "os.h" -namespace HIDRA2 -{ - enum OP_CODE : uint8_t { - OP_CODE__HELLO, - }; - - enum ERROR_CODE : uint16_t { - ERR__NO_ERROR, - ERR__UNSUPPORTED_VERSION, - ERR__INTERNAL_SERVER_ERROR = 65535, - }; - - struct NetworkRequest { - OP_CODE op_code; - uint64_t request_id; - char data[]; - }; - - struct NetworkResponse { - OP_CODE op_code; - uint64_t request_id; - ERROR_CODE error_code; - char data[]; - }; - - struct OP_HelloRequest { - uint32_t client_version; - - OS_TYPE os : 4; - bool is_x64 : 1; - }; - - struct OP_HelloResponse { - uint32_t server_version; - }; +namespace HIDRA2 { +enum OP_CODE : uint8_t { + OP_CODE__HELLO, +}; + +enum ERROR_CODE : uint16_t { + ERR__NO_ERROR, + ERR__UNSUPPORTED_VERSION, + ERR__INTERNAL_SERVER_ERROR = 65535, +}; + +struct NetworkRequest { + OP_CODE op_code; + uint64_t request_id; + char data[]; +}; + +struct NetworkResponse { + OP_CODE op_code; + uint64_t request_id; + ERROR_CODE error_code; + char data[]; +}; + +struct OP_HelloRequest { + uint32_t client_version; + + OS_TYPE os : 4; + bool is_x64 : 1; +}; + +struct OP_HelloResponse { + uint32_t server_version; +}; } #endif //HIDRA2__COMMON_NETWORKING_H diff --git a/common/cpp/include/common/os.h b/common/cpp/include/common/os.h index 984756e0ade21ae2609f3dd84a9c773b617108b2..7b9adf120577844f36dcf2fde180f7b98a886f35 100644 --- a/common/cpp/include/common/os.h +++ b/common/cpp/include/common/os.h @@ -3,15 +3,14 @@ #include <cstdint> -namespace HIDRA2 -{ - enum OS_TYPE : uint8_t { - OS_UNKOWN, - OS_LINUX, - OS_WINDOWS, +namespace HIDRA2 { +enum OS_TYPE : uint8_t { + OS_UNKOWN, + OS_LINUX, + OS_WINDOWS, - OS_INVALID = 16, /* Never use more then 4 bit */ - }; + OS_INVALID = 16, /* Never use more then 4 bit */ +}; } #endif //HIDRA2__COMMON_OS_H diff --git a/common/cpp/unittests/test_common.cpp b/common/cpp/unittests/test_common.cpp index 5f7937f18df83b24f063f6df6cb2d3aaf7a10624..34528ae8fdfea5465c83cd706c9d28a1e7d827cf 100644 --- a/common/cpp/unittests/test_common.cpp +++ b/common/cpp/unittests/test_common.cpp @@ -1,6 +1,5 @@ #include <gtest/gtest.h> -TEST(EMPTY, REMOVEME) -{ - EXPECT_EQ(1, 1); +TEST(EMPTY, REMOVEME) { + EXPECT_EQ(1, 1); } diff --git a/producer/api/include/producer/producer.h b/producer/api/include/producer/producer.h index efcfb311d2dafdc8c546b9ffcac92f8892e6b0d5..5b9c919fc3daad1bfe4ba837a37556415211721d 100644 --- a/producer/api/include/producer/producer.h +++ b/producer/api/include/producer/producer.h @@ -3,21 +3,19 @@ #include <string> -namespace HIDRA2 -{ - class Producer - { - private: - static unsigned long kinit_count_; - Producer(); - public: - static const uint32_t VERSION; +namespace HIDRA2 { +class Producer { + private: + static unsigned long kinit_count_; + Producer(); + public: + static const uint32_t VERSION; - Producer(const Producer&) = delete; - Producer& operator=(const Producer&) = delete; + Producer(const Producer&) = delete; + Producer& operator=(const Producer&) = delete; - static Producer* CreateProducer(std::string receiver_address); - }; + static Producer* CreateProducer(std::string receiver_address); +}; } #endif //HIDRA2__PRODUCER_PRODUCER_H diff --git a/producer/api/src/producer/producer.cpp b/producer/api/src/producer/producer.cpp index dd530f97a5a69336a4b8df76ed8ea94eb87f8ab6..454d72d7c6d25c6504f8babbc6948e191052a66a 100644 --- a/producer/api/src/producer/producer.cpp +++ b/producer/api/src/producer/producer.cpp @@ -3,12 +3,10 @@ unsigned long HIDRA2::Producer::kinit_count_ = 0; const uint32_t HIDRA2::Producer::VERSION = 1; -HIDRA2::Producer::Producer() -{ - kinit_count_++; +HIDRA2::Producer::Producer() { + kinit_count_++; } -HIDRA2::Producer *HIDRA2::Producer::CreateProducer(std::string receiver_address) -{ - return new Producer(); +HIDRA2::Producer *HIDRA2::Producer::CreateProducer(std::string receiver_address) { + return new Producer(); } diff --git a/producer/api/unittests/test_producer.cpp b/producer/api/unittests/test_producer.cpp index edb6d762f83611ffc79cb92cf7cbccbfa61d047d..c5c6df8020ff70318542209530a4d1cd9809fc43 100644 --- a/producer/api/unittests/test_producer.cpp +++ b/producer/api/unittests/test_producer.cpp @@ -1,16 +1,13 @@ #include <gtest/gtest.h> #include <producer/producer.h> -namespace -{ - TEST(VERSION, VersionAboveZero) - { - EXPECT_GE(HIDRA2::Producer::VERSION, 0); - } +namespace { +TEST(VERSION, VersionAboveZero) { + EXPECT_GE(HIDRA2::Producer::VERSION, 0); +} - TEST(CreateProducer, PointerIsNotNullptr) - { - HIDRA2::Producer* prod = HIDRA2::Producer::CreateProducer("127.0.0.1"); - EXPECT_NE(prod, nullptr); - } +TEST(CreateProducer, PointerIsNotNullptr) { + HIDRA2::Producer* prod = HIDRA2::Producer::CreateProducer("127.0.0.1"); + EXPECT_NE(prod, nullptr); +} } diff --git a/producer/inotify-event-detector-cpp/src/main.cpp b/producer/inotify-event-detector-cpp/src/main.cpp index 0f7c8b6cf909fbb77eed4d6dfb8d0e67c1962d12..f3b74fca68b2efcb0a8663a4d9c29fdfbb0c03af 100644 --- a/producer/inotify-event-detector-cpp/src/main.cpp +++ b/producer/inotify-event-detector-cpp/src/main.cpp @@ -1,17 +1,16 @@ #include <producer/producer.h> #include <iostream> -int main (int argc, char* argv[]) -{ - std::cout << "Running producer version: " << HIDRA2::Producer::VERSION << std::endl; +int main (int argc, char* argv[]) { + std::cout << "Running producer version: " << HIDRA2::Producer::VERSION << std::endl; - HIDRA2::Producer* producer = HIDRA2::Producer::CreateProducer("127.0.0.1"); - if(!producer) { - std::cerr << "Fail to create producer" << std::endl; - return 1; - } + HIDRA2::Producer* producer = HIDRA2::Producer::CreateProducer("127.0.0.1"); + if(!producer) { + std::cerr << "Fail to create producer" << std::endl; + return 1; + } - std::cout << "Successfully create producer " << std::hex << producer << std::endl; + std::cout << "Successfully create producer " << std::hex << producer << std::endl; - return 0; + return 0; } diff --git a/producer/inotify-event-detector-cpp/unittests/test_inotify_client.cpp b/producer/inotify-event-detector-cpp/unittests/test_inotify_client.cpp index 5f7937f18df83b24f063f6df6cb2d3aaf7a10624..34528ae8fdfea5465c83cd706c9d28a1e7d827cf 100644 --- a/producer/inotify-event-detector-cpp/unittests/test_inotify_client.cpp +++ b/producer/inotify-event-detector-cpp/unittests/test_inotify_client.cpp @@ -1,6 +1,5 @@ #include <gtest/gtest.h> -TEST(EMPTY, REMOVEME) -{ - EXPECT_EQ(1, 1); +TEST(EMPTY, REMOVEME) { + EXPECT_EQ(1, 1); }