Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=ON -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_MODERN=ON -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=ON -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON
make

- name: Perform CodeQL Analysis
Expand Down
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ endif (WIN32)

set(ENABLE_QPID_PROTON ON CACHE BOOL "Enable qpid proton clients")
set(ENABLE_QPID_MESSAGING ON CACHE BOOL "Enable qpid messaging clients")
set(ENABLE_MODERN ON CACHE BOOL "Enable usage of refactored code")
set(BUILD_WITH_UNIT_TESTS OFF CACHE BOOL "Build unit tests for the CPP client code")

if (NOT WIN32)
Expand Down Expand Up @@ -168,6 +169,14 @@ if (BUILD_WITH_UNIT_TESTS)
set (CTEST_BINARY_DIRECTORY ${CMAKE_BINARY_DIR}/target/tests/bin)
endif (BUILD_WITH_UNIT_TESTS)

if (ENABLE_MODERN)
add_definitions(-DENABLE_MODERN)
else (ENABLE_MODERN)
if (ENABLE_QPID_PROTON)
message(FATAL_ERROR "Modern code is a requirement for proton code")
endif(ENABLE_QPID_PROTON)
endif(ENABLE_MODERN)

add_subdirectory(src/contrib)
add_subdirectory(src/common)

Expand All @@ -185,7 +194,7 @@ set(CPPCHECK_EXECUTABLE "/usr/bin/cppcheck" CACHE STRING "Path to cppcheck")
set(CPPCHECK_FLAGS "--report-progress" "-v" "--enable=all" "--xml"
CACHE STRING "Options for cppcheck")

set(CPPCHECK_DEFS "-DENABLE_PROTON" "-DENABLE_QPID_MESSAGING"
set(CPPCHECK_DEFS "-DENABLE_MODERN" "-DENABLE_PROTON" "-DENABLE_QPID_MESSAGING"
"-DQPIDSYSEPOCH" CACHE STRING "Defines for cppcheck")

add_custom_target(check
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ sudo make install ;
These variables apply to all code base and may affect what code is built with
along with the project. For example, they may enable refactored code.

* ENABLE_MODERN: Enable new and/or refactored code. It is a requirement for -DENABLE_QPID_PROTON.

Check notice

Code scanning / Markdownlint (reported by Codacy)

Expected: 0 or 2; Actual: 1

Expected: 0 or 2; Actual: 1

Check notice

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 98

Expected: 80; Actual: 98
Default: off


#### Boost libraries

Expand Down Expand Up @@ -93,7 +96,7 @@ for some older RHEL/qpid versions. Default: false.
These variables affect only the QPID Proton clients.

* ENABLE_QPID_PROTON: Enable qpid proton messaging/reactor clients (eg.: aac3
and aac4).
and aac4). This variable requires ENABLE_MODERN.
* PROTON_DIR: QPID Proton base directory.


Expand All @@ -106,14 +109,14 @@ RHEL >= 6, with QPID Proton clients, using a non-standard QPID Proton directory

```
cmake -DENABLE_QPID_PROTON=ON -DPROTON_DIR=/opt/devel/qpid-proton \
-DCMAKE_CXX_COMPILER=`which c++` .
-DENABLE_MODERN=ON -DCMAKE_CXX_COMPILER=`which c++` .
```

RHEL 5.11 without QPID Proton and disabled unit tests

```
cmake -DENABLE_QPID_PROTON=ON -DPROTON_DIR=/opt/devel/qpid-proton \
-DCMAKE_CXX_COMPILER=`which c++` \
-DENABLE_MODERN=ON -DCMAKE_CXX_COMPILER=`which c++` \
-DCMAKE_VERBOSE_MAKEFILE=OFF -DBUILD_WITH_UNIT_TESTS=OFF \
-DQPID_WITH_GET_CONTENT_OBJECT=ON \
-DBoost_INCLUDE_DIRS=/usr/include/boost141/ \
Expand All @@ -124,7 +127,7 @@ RHEL 5.11 with QPID Proton and disabled unit tests

```
cmake -DENABLE_QPID_PROTON=ON -DPROTON_DIR=/opt/devel/qpid-proton \
-DCMAKE_CXX_COMPILER=`which c++` `
-DENABLE_MODERN=ON -DCMAKE_CXX_COMPILER=`which c++` `
-DCMAKE_VERBOSE_MAKEFILE=OFF -DBUILD_WITH_UNIT_TESTS=OFF `
-DQPID_WITH_GET_CONTENT_OBJECT=ON `
-DBoost_INCLUDE_DIRS=/usr/include/boost141/ `
Expand Down
4 changes: 2 additions & 2 deletions dist/dtests-rhel-cpp.spec
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ C++ clients, tools and runtime libraries
%build

%ifarch x86_64
cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=ON -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/dtests
cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_MODERN=ON -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=ON -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/dtests
%else
cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=OFF -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/dtests
cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_MODERN=ON -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=OFF -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/dtests
%endif
make

Expand Down
9 changes: 5 additions & 4 deletions src/api/qpid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ target_link_libraries(
dtests-qpid-messaging-common

${Qpid_LIBRARIES}
${ProtonCpp_LIBRARIES}
dtests-cpp-legacy
boost_regex # would be `Boost::regex` in new CMake
${qpid_client_link_libraries}
Expand Down Expand Up @@ -127,9 +126,11 @@ foreach(client ${qpid_messaging_clients})
endforeach(client)


if (BUILD_WITH_UNIT_TESTS)
add_subdirectory(common/formatter/test)
endif (BUILD_WITH_UNIT_TESTS)
if (ENABLE_MODERN)
if (BUILD_WITH_UNIT_TESTS)
add_subdirectory(common/formatter/test)
endif (BUILD_WITH_UNIT_TESTS)
endif (ENABLE_MODERN)


install(TARGETS
Expand Down
45 changes: 35 additions & 10 deletions src/api/qpid/common/formatter/FormatUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,30 @@ namespace messaging {
using std::cout;

void printMessageUpstream(const Message &message, bool verbose) {
QpidDecoder decoder = QpidDecoder(message);

std::ostringstream stream;
UpstreamWriter writer = UpstreamWriter(&stream);

UpstreamFormatter formatter = UpstreamFormatter();
formatter.printMessage(&decoder, &writer);

writer.endLine();
std::cout << writer.toString();
#ifdef ENABLE_MODERN
QpidDecoder decoder = QpidDecoder(message);

std::ostringstream stream;
UpstreamWriter writer = UpstreamWriter(&stream);

UpstreamFormatter formatter = UpstreamFormatter();
formatter.printMessage(&decoder, &writer);

writer.endLine();
std::cout << writer.toString();

#else
Formatter formatter;

Message tmp = const_cast<Message &>(message);

formatter.printMessage(tmp, verbose);
#endif // ENABLE_MODERN
}


void printMessageDict(const Message &message) {
#ifdef ENABLE_MODERN
QpidDecoder decoder = QpidDecoder(message);

std::ostringstream stream;
Expand All @@ -31,6 +41,13 @@ void printMessageDict(const Message &message) {

writer.endLine();
std::cout << writer.toString();
#else
Formatter formatter;

Message tmp = const_cast<Message &>(message);

formatter.printMessageAsDict(tmp);
#endif // ENABLE_MODERN
}

std::string formatBool(const bool b) {
Expand Down Expand Up @@ -337,6 +354,7 @@ void printMessageInterop(const Message &message) {
}

void printStatistics(const Message &message, const Variant::Map &stats) {
#ifdef ENABLE_MODERN
/*
* NOTE: this is *not* the best way to solve this problem and I will
* implement a more elegant design in the future
Expand All @@ -348,6 +366,13 @@ void printStatistics(const Message &message, const Variant::Map &stats) {

DictFormatter formatter = DictFormatter();
formatter.printStatistics(&decoder, &writer, stats);
#else
Formatter formatter;

Variant::Map tmp = const_cast<Variant::Map &>(stats);

formatter.printStatistics(tmp);
#endif // ENABLE_MODERN
}

}}}
4 changes: 4 additions & 0 deletions src/api/qpid/common/formatter/FormatUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@
#include <iostream>
#include <iomanip>

#ifdef ENABLE_MODERN
#include "formatter/DictFormatter.h"
#include "formatter/DictWriter.h"

#include "formatter/UpstreamFormatter.h"
#include "formatter/UpstreamWriter.h"

#include "QpidDecoder.h"
#else
#include "Formatter.h"
#endif // ENABLE_MODERN

using qpid::messaging::Message;
using qpid::types::Variant;
Expand Down
68 changes: 34 additions & 34 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,43 @@ include_directories(
common/options/modern
)

set(COMMON_MODERN_SRC
output/Printer.cpp
exceptions/BaseException.cpp
exceptions/IOException.cpp
exceptions/TimerExpiredException.cpp
options/BaseOptionsParser.cpp
options/OptionsHelper.cpp
formatter/Writer.cpp
formatter/DictWriter.cpp
formatter/UpstreamWriter.cpp
formatter/AbstractDecoder.cpp
formatter/AbstractFormatter.cpp
formatter/DictFormatter.cpp
formatter/UpstreamFormatter.cpp
logger/Logger.cpp
logger/LoggerWrapper.cpp

Timer.cpp
UriParser.cpp
Client.cpp
ContentType.cpp
MessageHeader.cpp
)

if (BUILD_WITH_UNIT_TESTS)
set(TEST_SUPPORT_SRC
TestUtils.cpp
if (ENABLE_MODERN)
set(COMMON_MODERN_SRC
output/Printer.cpp
exceptions/BaseException.cpp
exceptions/IOException.cpp
exceptions/TimerExpiredException.cpp
options/BaseOptionsParser.cpp
options/OptionsHelper.cpp
formatter/Writer.cpp
formatter/DictWriter.cpp
formatter/UpstreamWriter.cpp
formatter/AbstractDecoder.cpp
formatter/AbstractFormatter.cpp
formatter/DictFormatter.cpp
formatter/UpstreamFormatter.cpp
logger/Logger.cpp
logger/LoggerWrapper.cpp

Timer.cpp
UriParser.cpp
Client.cpp
ContentType.cpp
MessageHeader.cpp
)

if (BUILD_WITH_UNIT_TESTS)
set(TEST_SUPPORT_SRC
TestUtils.cpp
)

add_subdirectory(test)
add_subdirectory(output/test)
add_subdirectory(logger/test)
add_subdirectory(options/test)
endif (BUILD_WITH_UNIT_TESTS)
add_subdirectory(output/test)
add_subdirectory(logger/test)
add_subdirectory(options/test)
endif (BUILD_WITH_UNIT_TESTS)

endif (ENABLE_MODERN)

add_library(dtests-cpp-common
${COMMON_MODERN_SRC}
Expand All @@ -55,9 +58,6 @@ add_library(dtests-cpp-common
Utils.cpp
)

target_include_directories(dtests-cpp-common
PRIVATE ${PROTON_INCLUDE_DIR}
)
if (WIN32)
target_link_libraries(dtests-cpp-common)
else (WIN32)
Expand Down