From 7c3f4b8abfc4a57a3fcf5ff13360ac96db9d5cb0 Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Fri, 28 Jun 2024 11:12:05 +0200 Subject: [PATCH 01/12] Refs #21266 Add secured hello world example Signed-off-by: Carlosespicur --- examples/CMakeLists.txt | 4 + examples/cpp/dds_security/CMakeLists.txt | 15 + .../SecureHelloWorldExample/Application.cpp | 66 ++++ .../SecureHelloWorldExample/Application.hpp | 56 ++++ .../SecureHelloWorldExample/CLIParser.hpp | 311 ++++++++++++++++++ .../SecureHelloWorldExample/CMakeLists.txt | 70 ++++ .../SecureHelloWorldExample/HelloWorld.hpp | 227 +++++++++++++ .../SecureHelloWorldExample/HelloWorld.idl | 6 + .../HelloWorldCdrAux.hpp | 46 +++ .../HelloWorldCdrAux.ipp | 126 +++++++ .../HelloWorldPubSubTypes.cxx | 229 +++++++++++++ .../HelloWorldPubSubTypes.h | 133 ++++++++ .../HelloWorldTypeObjectSupport.cxx | 145 ++++++++ .../HelloWorldTypeObjectSupport.hpp | 56 ++++ .../ListenerSubscriberApp.cpp | 170 ++++++++++ .../ListenerSubscriberApp.hpp | 98 ++++++ .../SecureHelloWorldExample/PublisherApp.cpp | 179 ++++++++++ .../SecureHelloWorldExample/PublisherApp.hpp | 100 ++++++ .../SecureHelloWorldExample/README.md | 151 +++++++++ .../WaitsetSubscriberApp.cpp | 188 +++++++++++ .../WaitsetSubscriberApp.hpp | 91 +++++ .../certs/governance.smime | 71 ++++ .../certs/governance_dds_sec.xml | 30 ++ .../certs/maincacert.pem | 14 + .../certs/maincakey.pem | 5 + .../certs/mainpubcert.pem | 44 +++ .../certs/mainpubkey.pem | 5 + .../certs/mainsubcert.pem | 44 +++ .../certs/mainsubkey.pem | 5 + .../certs/permissions.smime | 88 +++++ .../certs/permissions_dds_sec.xml | 47 +++ .../hello_world_profile.xml | 132 ++++++++ .../SecureHelloWorldExample/main.cpp | 108 ++++++ .../SecureHelloWorldExample.compose.yml | 29 ++ test/examples/test_secure_hello_world.py | 54 +++ 35 files changed, 3143 insertions(+) create mode 100644 examples/cpp/dds_security/CMakeLists.txt create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/Application.hpp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/CMakeLists.txt create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.hpp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.idl create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.hpp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.ipp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.h create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.cxx create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.cpp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.hpp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/README.md create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.cpp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.hpp create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/certs/governance.smime create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/certs/governance_dds_sec.xml create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/certs/maincacert.pem create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/certs/maincakey.pem create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubcert.pem create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubkey.pem create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubcert.pem create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubkey.pem create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions.smime create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions_dds_sec.xml create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/hello_world_profile.xml create mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/main.cpp create mode 100644 test/examples/SecureHelloWorldExample.compose.yml create mode 100644 test/examples/test_secure_hello_world.py diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 07eb00f15be..c3c8300cc93 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -19,7 +19,11 @@ add_subdirectory(cpp/content_filter) add_subdirectory(cpp/custom_payload_pool) add_subdirectory(cpp/dds) add_subdirectory(cpp/delivery_mechanisms) +<<<<<<< HEAD add_subdirectory(cpp/discovery_server) +======= +add_subdirectory(cpp/dds_security) +>>>>>>> 420ed93df (Refs #21266 Add secured hello world example) add_subdirectory(cpp/hello_world) add_subdirectory(cpp/rtps) add_subdirectory(cpp/xtypes) diff --git a/examples/cpp/dds_security/CMakeLists.txt b/examples/cpp/dds_security/CMakeLists.txt new file mode 100644 index 00000000000..e3d1763df50 --- /dev/null +++ b/examples/cpp/dds_security/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +add_subdirectory(SecureHelloWorldExample) \ No newline at end of file diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp b/examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp new file mode 100644 index 00000000000..fb42f74aafc --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp @@ -0,0 +1,66 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file Application.cpp + * + */ + +#include "Application.hpp" + +#include "CLIParser.hpp" +#include "ListenerSubscriberApp.hpp" +#include "PublisherApp.hpp" +#include "WaitsetSubscriberApp.hpp" + +using namespace eprosima::fastdds::dds; + +namespace eprosima { +namespace fastdds { +namespace examples { +namespace hello_world { + +//! Factory method to create a publisher or subscriber +std::shared_ptr Application::make_app( + const CLIParser::hello_world_config& config, + const std::string& topic_name) +{ + std::shared_ptr entity; + switch (config.entity) + { + case CLIParser::EntityKind::PUBLISHER: + entity = std::make_shared(config.pub_config, topic_name); + break; + case CLIParser::EntityKind::SUBSCRIBER: + if (config.sub_config.use_waitset) + { + entity = std::make_shared(config.sub_config, topic_name); + } + else + { + entity = std::make_shared(config.sub_config, topic_name); + } + break; + case CLIParser::EntityKind::UNDEFINED: + default: + throw std::runtime_error("Entity initialization failed"); + break; + } + return entity; +} + +} // namespace hello_world +} // namespace examples +} // namespace fastdds +} // namespace eprosima diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/Application.hpp b/examples/cpp/dds_security/SecureHelloWorldExample/Application.hpp new file mode 100644 index 00000000000..9d1f01b214b --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/Application.hpp @@ -0,0 +1,56 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file Application.hpp + * + */ + +#ifndef _FASTDDS_HELLO_WORLD_APPLICATION_HPP_ +#define _FASTDDS_HELLO_WORLD_APPLICATION_HPP_ + +#include + +#include "CLIParser.hpp" + +namespace eprosima { +namespace fastdds { +namespace examples { +namespace hello_world { + +class Application +{ +public: + + //! Virtual destructor + virtual ~Application() = default; + + //! Run application + virtual void run() = 0; + + //! Trigger the end of execution + virtual void stop() = 0; + + //! Factory method to create applications based on configuration + static std::shared_ptr make_app( + const CLIParser::hello_world_config& config, + const std::string& topic_name); +}; + +} // namespace hello_world +} // namespace examples +} // namespace fastdds +} // namespace eprosima + +#endif /* _FASTDDS_HELLO_WORLD_APPLICATION_HPP_ */ diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp b/examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp new file mode 100644 index 00000000000..39dc393b050 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp @@ -0,0 +1,311 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include +#include + +#ifndef _FASTDDS_HELLO_WORLD_CLI_PARSER_HPP_ +#define _FASTDDS_HELLO_WORLD_CLI_PARSER_HPP_ + +namespace eprosima { +namespace fastdds { +namespace examples { +namespace hello_world { + +using dds::Log; + +class CLIParser +{ +public: + + CLIParser() = delete; + + //! Entity kind enumeration + enum class EntityKind : uint8_t + { + PUBLISHER, + SUBSCRIBER, + UNDEFINED + }; + + //! Publisher configuration structure (shared for both publisher and subscriber applications) + struct publisher_config + { + uint16_t samples = 0; + uint32_t interval = 100; // milliseconds + }; + + //! Subscriber application configuration structure + struct subscriber_config : public publisher_config + { + bool use_waitset = false; + }; + + //! Configuration structure for the application + struct hello_world_config + { + CLIParser::EntityKind entity = CLIParser::EntityKind::UNDEFINED; + publisher_config pub_config; + subscriber_config sub_config; + }; + + /** + * @brief Print usage help message and exit with the given return code + * + * @param return_code return code to exit with + * + * @warning This method finishes the execution of the program with the input return code + */ + static void print_help( + uint8_t return_code) + { + std::cout << "Usage: hello_world [options]" << std::endl; + std::cout << "" << std::endl; + std::cout << "Entities:" << std::endl; + std::cout << " publisher Run a publisher entity" << std::endl; + std::cout << " subscriber Run a subscriber entity" << std::endl; + std::cout << "" << std::endl; + std::cout << "Common options:" << std::endl; + std::cout << " -h, --help Print this help message" << std::endl; + std::cout << " -s , --samples Number of samples to send or receive" << std::endl; + std::cout << " [0 <= <= 65535]" << std::endl; + std::cout << " (Default: 0 [unlimited])" << std::endl; + std::cout << "Publisher options:" << std::endl; + std::cout << " -i , --interval Time between samples in milliseconds" << std::endl; + std::cout << " [1 <= <= 4294967]" << std::endl; + std::cout << "Subscriber options:" << std::endl; + std::cout << " -w, --waitset Use waitset & read condition" << std::endl; + std::exit(return_code); + } + + /** + * @brief Parse the command line options and return the configuration_config object + * + * @param argc number of arguments + * @param argv array of arguments + * @return configuration_config object with the parsed options + * + * @warning This method finishes the execution of the program if the input arguments are invalid + */ + static hello_world_config parse_cli_options( + int argc, + char* argv[]) + { + hello_world_config config; + + if (argc < 2) + { + EPROSIMA_LOG_ERROR(CLI_PARSER, "missing entity argument"); + print_help(EXIT_FAILURE); + } + + std::string first_argument = argv[1]; + + if (first_argument == "publisher" ) + { + config.entity = CLIParser::EntityKind::PUBLISHER; + } + else if (first_argument == "subscriber") + { + config.entity = CLIParser::EntityKind::SUBSCRIBER; + } + else if (first_argument == "-h" || first_argument == "--help") + { + print_help(EXIT_SUCCESS); + } + else + { + EPROSIMA_LOG_ERROR(CLI_PARSER, "parsing entity argument " + first_argument); + print_help(EXIT_FAILURE); + } + // max value allowed taking into account that the input is receiving millisecond values + uint32_t max_duration = static_cast(floor(std::numeric_limits::max() * 1e-3)); // = 4294967 + + for (int i = 2; i < argc; ++i) + { + std::string arg = argv[i]; + if (arg == "-h" || arg == "--help") + { + print_help(EXIT_SUCCESS); + } + else if (arg == "-s" || arg == "--samples") + { + if (i + 1 < argc) + { + try + { + int input = std::stoi(argv[++i]); + if (input < std::numeric_limits::min() || + input > std::numeric_limits::max()) + { + throw std::out_of_range("sample argument out of range"); + } + else + { + if (config.entity == CLIParser::EntityKind::PUBLISHER) + { + config.pub_config.samples = static_cast(input); + } + else if (config.entity == CLIParser::EntityKind::SUBSCRIBER) + { + config.sub_config.samples = static_cast(input); + } + else + { + EPROSIMA_LOG_ERROR(CLI_PARSER, "entity not specified for --sample argument"); + print_help(EXIT_FAILURE); + } + } + } + catch (const std::invalid_argument& e) + { + EPROSIMA_LOG_ERROR(CLI_PARSER, "invalid sample argument for " + arg + ": " + e.what()); + print_help(EXIT_FAILURE); + } + catch (const std::out_of_range& e) + { + EPROSIMA_LOG_ERROR(CLI_PARSER, "sample argument out of range for " + arg + ": " + e.what()); + print_help(EXIT_FAILURE); + } + } + else + { + EPROSIMA_LOG_ERROR(CLI_PARSER, "missing argument for " + arg); + print_help(EXIT_FAILURE); + } + } + else if (arg == "-w" || arg == "--waitset") + { + if (config.entity == CLIParser::EntityKind::SUBSCRIBER) + { + config.sub_config.use_waitset = true; + } + else + { + EPROSIMA_LOG_ERROR(CLI_PARSER, "waitset can only be used with the subscriber entity"); + print_help(EXIT_FAILURE); + } + } + else if (arg == "-i" || arg == "--interval") + { + if (config.entity == CLIParser::EntityKind::PUBLISHER) + { + if (++i < argc) + { + try + { + int input = std::stoi(argv[i]); + if (input < 1 || static_cast(input) > static_cast(max_duration)) + { + throw std::out_of_range("interval argument " + std::string( + argv[i]) + " out of range [1, " + std::to_string( + max_duration) + "]."); + } + else + { + config.pub_config.interval = static_cast(input); + } + } + catch (const std::invalid_argument& e) + { + EPROSIMA_LOG_ERROR(CLI_PARSER, "invalid interval argument " + std::string( + argv[i]) + ": " + std::string(e.what())); + print_help(EXIT_FAILURE); + } + catch (const std::out_of_range& e) + { + EPROSIMA_LOG_ERROR(CLI_PARSER, std::string(e.what())); + print_help(EXIT_FAILURE); + } + } + else + { + EPROSIMA_LOG_ERROR(CLI_PARSER, "parsing interval argument"); + print_help(EXIT_FAILURE); + } + } + else + { + EPROSIMA_LOG_ERROR(CLI_PARSER, "interval argument is only valid for publisher entity"); + print_help(EXIT_FAILURE); + } + } + else + { + EPROSIMA_LOG_ERROR(CLI_PARSER, "unknown option " + arg); + print_help(EXIT_FAILURE); + } + } + + return config; + } + + /** + * @brief Parse the signal number into the signal name + * + * @param signum signal number + * @return std::string signal name + */ + static std::string parse_signal( + const int& signum) + { + switch (signum) + { + case SIGINT: + return "SIGINT"; + case SIGTERM: + return "SIGTERM"; +#ifndef _WIN32 + case SIGQUIT: + return "SIGQUIT"; + case SIGHUP: + return "SIGHUP"; +#endif // _WIN32 + default: + return "UNKNOWN SIGNAL"; + } + } + + /** + * @brief Parse the entity kind into std::string + * + * @param entity entity kind + * @return std::string entity kind + */ + static std::string parse_entity_kind( + const EntityKind& entity) + { + switch (entity) + { + case EntityKind::PUBLISHER: + return "Publisher"; + case EntityKind::SUBSCRIBER: + return "Subscriber"; + case EntityKind::UNDEFINED: + default: + return "Undefined entity"; + } + } + +}; + +} // namespace hello_world +} // namespace examples +} // namespace fastdds +} // namespace eprosima + +#endif // _FASTDDS_HELLO_WORLD_CLI_PARSER_HPP_ diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/CMakeLists.txt b/examples/cpp/dds_security/SecureHelloWorldExample/CMakeLists.txt new file mode 100644 index 00000000000..4730ff52599 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/CMakeLists.txt @@ -0,0 +1,70 @@ +# Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.20) + +project(fastdds_secure_hello_world_example VERSION 1 LANGUAGES CXX) + +# Find requirements +if(NOT fastcdr_FOUND) + find_package(fastcdr 2 REQUIRED) +endif() + +if(NOT fastdds_FOUND) + find_package(fastdds 3 REQUIRED) +endif() + +#Check C++11 +include(CheckCXXCompilerFlag) +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + check_cxx_compiler_flag(-std=c++11 SUPPORTS_CXX11) + if(NOT SUPPORTS_CXX11) + message(FATAL_ERROR "Compiler doesn't support C++11") + endif() +endif() + +message(STATUS "Configuring secure hello world example...") +file(GLOB SECURE_HELLO_WORLD_SOURCES_CXX "*.cxx") +file(GLOB SECURE_HELLO_WORLD_SOURCES_CPP "*.cpp") + +add_executable(SecureHelloWorldExample ${SECURE_HELLO_WORLD_SOURCES_CXX} ${SECURE_HELLO_WORLD_SOURCES_CPP}) +target_compile_definitions(SecureHelloWorldExample PRIVATE + $<$>,$>:__DEBUG> + $<$:__INTERNALDEBUG> # Internal debug activated. + $<$:SHM_TRANSPORT_BUILTIN> # Enable SHM as built-in transport +) +target_link_libraries(SecureHelloWorldExample fastdds fastcdr) +install(TARGETS SecureHelloWorldExample + RUNTIME DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/dds_security/SecureHelloWorldExample/${BIN_INSTALL_DIR}) +install(DIRECTORY ${PROJECT_SOURCE_DIR}/certs + DESTINATION examples/cpp/dds_security/SecureHelloWorldExample/${BIN_INSTALL_DIR}) +# Copy the XML files over to the build directory +file(GLOB_RECURSE XML_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.xml) +# for each xml file detected +foreach(XML_FILE_COMPLETE_PATH ${XML_FILES}) + # obtain the file name + get_filename_component(XML_FILE ${XML_FILE_COMPLETE_PATH} NAME_WE) + # copy the file from src to build folders + configure_file( + ${XML_FILE_COMPLETE_PATH} # from full src path + ${CMAKE_CURRENT_BINARY_DIR}/${XML_FILE}.xml # to relative build path + COPYONLY) + install(FILES ${XML_FILE_COMPLETE_PATH} + DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/dds_security/SecureHelloWorldExample/${BIN_INSTALL_DIR}) +endforeach() + +add_custom_command(TARGET SecureHelloWorldExample POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${PROJECT_SOURCE_DIR}/certs + ${PROJECT_BINARY_DIR}/certs) diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.hpp b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.hpp new file mode 100644 index 00000000000..971fea8d920 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.hpp @@ -0,0 +1,227 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.hpp + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLD_HPP_ + +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(HELLOWORLD_SOURCE) +#define HELLOWORLD_DllAPI __declspec( dllexport ) +#else +#define HELLOWORLD_DllAPI __declspec( dllimport ) +#endif // HELLOWORLD_SOURCE +#else +#define HELLOWORLD_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define HELLOWORLD_DllAPI +#endif // _WIN32 + +/*! + * @brief This class represents the structure HelloWorld defined by the user in the IDL file. + * @ingroup HelloWorld + */ +class HelloWorld +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport HelloWorld() + { + } + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~HelloWorld() + { + } + + /*! + * @brief Copy constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld( + const HelloWorld& x) + { + m_index = x.m_index; + + m_message = x.m_message; + + } + + /*! + * @brief Move constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld( + HelloWorld&& x) noexcept + { + m_index = x.m_index; + m_message = std::move(x.m_message); + } + + /*! + * @brief Copy assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator =( + const HelloWorld& x) + { + + m_index = x.m_index; + + m_message = x.m_message; + + return *this; + } + + /*! + * @brief Move assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator =( + HelloWorld&& x) noexcept + { + + m_index = x.m_index; + m_message = std::move(x.m_message); + return *this; + } + + /*! + * @brief Comparison operator. + * @param x HelloWorld object to compare. + */ + eProsima_user_DllExport bool operator ==( + const HelloWorld& x) const + { + return (m_index == x.m_index && + m_message == x.m_message); + } + + /*! + * @brief Comparison operator. + * @param x HelloWorld object to compare. + */ + eProsima_user_DllExport bool operator !=( + const HelloWorld& x) const + { + return !(*this == x); + } + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index( + uint32_t _index) + { + m_index = _index; + } + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const + { + return m_index; + } + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index() + { + return m_index; + } + + + /*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ + eProsima_user_DllExport void message( + const std::string& _message) + { + m_message = _message; + } + + /*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ + eProsima_user_DllExport void message( + std::string&& _message) + { + m_message = std::move(_message); + } + + /*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ + eProsima_user_DllExport const std::string& message() const + { + return m_message; + } + + /*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ + eProsima_user_DllExport std::string& message() + { + return m_message; + } + + + +private: + + uint32_t m_index{0}; + std::string m_message; + +}; + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_HPP_ + + diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.idl b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.idl new file mode 100644 index 00000000000..192f8f9d487 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.idl @@ -0,0 +1,6 @@ +@extensibility(APPENDABLE) +struct HelloWorld +{ + unsigned long index; + string message; +}; diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.hpp b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.hpp new file mode 100644 index 00000000000..6feb8a9da15 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.hpp @@ -0,0 +1,46 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldCdrAux.hpp + * This source file contains some definitions of CDR related functions. + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ + +#include "HelloWorld.hpp" + +constexpr uint32_t HelloWorld_max_cdr_typesize {268UL}; +constexpr uint32_t HelloWorld_max_key_cdr_typesize {0UL}; + + +namespace eprosima { +namespace fastcdr { + +class Cdr; +class CdrSizeCalculator; + +eProsima_user_DllExport void serialize_key( + eprosima::fastcdr::Cdr& scdr, + const HelloWorld& data); + + +} // namespace fastcdr +} // namespace eprosima + +#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ + diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.ipp b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.ipp new file mode 100644 index 00000000000..97df3fe9d9e --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.ipp @@ -0,0 +1,126 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldCdrAux.ipp + * This source file contains some declarations of CDR related functions. + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ + +#include "HelloWorldCdrAux.hpp" + +#include +#include + + +#include +using namespace eprosima::fastcdr::exception; + +namespace eprosima { +namespace fastcdr { + +template<> +eProsima_user_DllExport size_t calculate_serialized_size( + eprosima::fastcdr::CdrSizeCalculator& calculator, + const HelloWorld& data, + size_t& current_alignment) +{ + static_cast(data); + + eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); + size_t calculated_size {calculator.begin_calculate_type_serialized_size( + eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, + current_alignment)}; + + + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.index(), current_alignment); + + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.message(), current_alignment); + + + calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); + + return calculated_size; +} + +template<> +eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& scdr, + const HelloWorld& data) +{ + eprosima::fastcdr::Cdr::state current_state(scdr); + scdr.begin_serialize_type(current_state, + eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); + + scdr + << eprosima::fastcdr::MemberId(0) << data.index() + << eprosima::fastcdr::MemberId(1) << data.message() +; + scdr.end_serialize_type(current_state); +} + +template<> +eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr, + HelloWorld& data) +{ + cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, + [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool + { + bool ret_value = true; + switch (mid.id) + { + case 0: + dcdr >> data.index(); + break; + + case 1: + dcdr >> data.message(); + break; + + default: + ret_value = false; + break; + } + return ret_value; + }); +} + +void serialize_key( + eprosima::fastcdr::Cdr& scdr, + const HelloWorld& data) +{ + static_cast(scdr); + static_cast(data); +} + + + +} // namespace fastcdr +} // namespace eprosima + +#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ + diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx new file mode 100644 index 00000000000..41da39407fa --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx @@ -0,0 +1,229 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + +#include "HelloWorldPubSubTypes.h" + +#include +#include + +#include "HelloWorldCdrAux.hpp" +#include "HelloWorldTypeObjectSupport.hpp" + +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; +using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + +HelloWorldPubSubType::HelloWorldPubSubType() +{ + setName("HelloWorld"); + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(HelloWorld::getMaxCdrSerializedSize()); +#else + HelloWorld_max_cdr_typesize; +#endif + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + m_typeSize = type_size + 4; /*encapsulation*/ + m_isGetKeyDefined = false; + uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +HelloWorldPubSubType::~HelloWorldPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool HelloWorldPubSubType::serialize( + const void* const data, + SerializedPayload_t* payload, + DataRepresentationId_t data_representation) +{ + const HelloWorld* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); +#endif // FASTCDR_VERSION_MAJOR > 1 + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length +#if FASTCDR_VERSION_MAJOR == 1 + payload->length = static_cast(ser.getSerializedDataLength()); +#else + payload->length = static_cast(ser.get_serialized_data_length()); +#endif // FASTCDR_VERSION_MAJOR == 1 + return true; +} + +bool HelloWorldPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + HelloWorld* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN +#if FASTCDR_VERSION_MAJOR == 1 + , eprosima::fastcdr::Cdr::CdrType::DDS_CDR +#endif // FASTCDR_VERSION_MAJOR == 1 + ); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +std::function HelloWorldPubSubType::getSerializedSizeProvider( + const void* const data, + DataRepresentationId_t data_representation) +{ + return [data, data_representation]() -> uint32_t + { +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 + }; +} + +void* HelloWorldPubSubType::createData() +{ + return reinterpret_cast(new HelloWorld()); +} + +void HelloWorldPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool HelloWorldPubSubType::getKey( + const void* const data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + const HelloWorld* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + HelloWorld_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else + eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 + if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) + { + m_md5.init(); +#if FASTCDR_VERSION_MAJOR == 1 + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); +#else + m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); +#endif // FASTCDR_VERSION_MAJOR == 1 + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} + +void HelloWorldPubSubType::register_type_object_representation() +{ + register_HelloWorld_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "HelloWorldCdrAux.ipp" diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.h b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.h new file mode 100644 index 00000000000..3db9ca96458 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.h @@ -0,0 +1,133 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ + +#include +#include +#include +#include +#include + +#include "HelloWorld.hpp" + + +#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#error \ + Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + + +/*! + * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. + * @ingroup HelloWorld + */ +class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef HelloWorld type; + + eProsima_user_DllExport HelloWorldPubSubType(); + + eProsima_user_DllExport ~HelloWorldPubSubType() override; + + eProsima_user_DllExport bool serialize( + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport bool serialize( + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool deserialize( + eprosima::fastdds::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport std::function getSerializedSizeProvider( + const void* const data) override + { + return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport std::function getSerializedSizeProvider( + const void* const data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool getKey( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport void* createData() override; + + eProsima_user_DllExport void deleteData( + void* data) override; + + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + + eProsima_user_DllExport inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + { + static_cast(data_representation); + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + static_cast(memory); + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; + +}; + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ + diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.cxx b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.cxx new file mode 100644 index 00000000000..aaf391eeed3 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.cxx @@ -0,0 +1,145 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "HelloWorldTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "HelloWorld.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_HelloWorld_type_identifier( + TypeIdentifierPair& type_ids_HelloWorld) +{ + + ReturnCode_t return_code_HelloWorld {eprosima::fastdds::dds::RETCODE_OK}; + return_code_HelloWorld = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "HelloWorld", type_ids_HelloWorld); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_HelloWorld) + { + StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_HelloWorld = "HelloWorld"; + eprosima::fastcdr::optional type_ann_builtin_HelloWorld; + eprosima::fastcdr::optional ann_custom_HelloWorld; + AppliedAnnotationSeq tmp_ann_custom_HelloWorld; + eprosima::fastcdr::optional verbatim_HelloWorld; + if (!tmp_ann_custom_HelloWorld.empty()) + { + ann_custom_HelloWorld = tmp_ann_custom_HelloWorld; + } + + CompleteTypeDetail detail_HelloWorld = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_HelloWorld, ann_custom_HelloWorld, type_name_HelloWorld.to_string()); + CompleteStructHeader header_HelloWorld; + header_HelloWorld = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_HelloWorld); + CompleteStructMemberSeq member_seq_HelloWorld; + { + TypeIdentifierPair type_ids_index; + ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; + return_code_index = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_index); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_index = 0x00000000; + bool common_index_ec {false}; + CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; + if (!common_index_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); + return; + } + MemberName name_index = "index"; + eprosima::fastcdr::optional member_ann_builtin_index; + ann_custom_HelloWorld.reset(); + CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_HelloWorld); + CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); + TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_index); + } + { + TypeIdentifierPair type_ids_message; + ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; + return_code_message = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_message); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_message)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_message = 0x00000001; + bool common_message_ec {false}; + CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; + if (!common_message_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); + return; + } + MemberName name_message = "message"; + eprosima::fastcdr::optional member_ann_builtin_message; + ann_custom_HelloWorld.reset(); + CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_HelloWorld); + CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); + TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_message); + } + CompleteStructType struct_type_HelloWorld = TypeObjectUtils::build_complete_struct_type(struct_flags_HelloWorld, header_HelloWorld, member_seq_HelloWorld); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_ids_HelloWorld)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "HelloWorld already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp new file mode 100644 index 00000000000..2eba797b07f --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ + +#include + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register HelloWorld related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_HelloWorld_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.cpp b/examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.cpp new file mode 100644 index 00000000000..f23bc15913b --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.cpp @@ -0,0 +1,170 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file ListenerSubscriber.cpp + * + */ + +#include "ListenerSubscriberApp.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "CLIParser.hpp" +#include "HelloWorldPubSubTypes.h" +#include "Application.hpp" + +using namespace eprosima::fastdds::dds; + +namespace eprosima { +namespace fastdds { +namespace examples { +namespace hello_world { + +ListenerSubscriberApp::ListenerSubscriberApp( + const CLIParser::subscriber_config& config, + const std::string& topic_name) + : participant_(nullptr) + , subscriber_(nullptr) + , topic_(nullptr) + , reader_(nullptr) + , type_(new HelloWorldPubSubType()) + , samples_(config.samples) + , received_samples_(0) + , stop_(false) +{ + // Create the participant + + auto factory = DomainParticipantFactory::get_instance(); + participant_ = factory->create_participant_with_default_profile(nullptr, StatusMask::none()); + if (participant_ == nullptr) + { + throw std::runtime_error("Participant initialization failed"); + } + + // Register the type + type_.register_type(participant_); + + // Create the subscriber + SubscriberQos sub_qos = SUBSCRIBER_QOS_DEFAULT; + participant_->get_default_subscriber_qos(sub_qos); + subscriber_ = participant_->create_subscriber(sub_qos, nullptr, StatusMask::none()); + if (subscriber_ == nullptr) + { + throw std::runtime_error("Subscriber initialization failed"); + } + + // Create the topic + TopicQos topic_qos = TOPIC_QOS_DEFAULT; + participant_->get_default_topic_qos(topic_qos); + topic_ = participant_->create_topic(topic_name, type_.get_type_name(), topic_qos); + if (topic_ == nullptr) + { + throw std::runtime_error("Topic initialization failed"); + } + + // Create the reader + DataReaderQos reader_qos = DATAREADER_QOS_DEFAULT; + subscriber_->get_default_datareader_qos(reader_qos); + reader_ = subscriber_->create_datareader(topic_, reader_qos, this, StatusMask::all()); + if (reader_ == nullptr) + { + throw std::runtime_error("DataReader initialization failed"); + } +} + +ListenerSubscriberApp::~ListenerSubscriberApp() +{ + if (nullptr != participant_) + { + // Delete DDS entities contained within the DomainParticipant + participant_->delete_contained_entities(); + + // Delete DomainParticipant + DomainParticipantFactory::get_instance()->delete_participant(participant_); + } +} + +void ListenerSubscriberApp::on_subscription_matched( + DataReader* /*reader*/, + const SubscriptionMatchedStatus& info) +{ + if (info.current_count_change == 1) + { + std::cout << "Subscriber matched." << std::endl; + } + else if (info.current_count_change == -1) + { + std::cout << "Subscriber unmatched." << std::endl; + } + else + { + std::cout << info.current_count_change + << " is not a valid value for SubscriptionMatchedStatus current count change" << std::endl; + } +} + +void ListenerSubscriberApp::on_data_available( + DataReader* reader) +{ + SampleInfo info; + while ((!is_stopped()) && (RETCODE_OK == reader->take_next_sample(&hello_, &info))) + { + if ((info.instance_state == ALIVE_INSTANCE_STATE) && info.valid_data) + { + received_samples_++; + // Print Hello world message data + std::cout << "Message: '" << hello_.message() << "' with index: '" << hello_.index() + << "' RECEIVED" << std::endl; + if (samples_ > 0 && (received_samples_ >= samples_)) + { + stop(); + } + } + } +} + +void ListenerSubscriberApp::run() +{ + std::unique_lock lck(terminate_cv_mtx_); + terminate_cv_.wait(lck, [&] + { + return is_stopped(); + }); +} + +bool ListenerSubscriberApp::is_stopped() +{ + return stop_.load(); +} + +void ListenerSubscriberApp::stop() +{ + stop_.store(true); + terminate_cv_.notify_all(); +} + +} // namespace hello_world +} // namespace examples +} // namespace fastdds +} // namespace eprosima diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.hpp b/examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.hpp new file mode 100644 index 00000000000..cd22791dec6 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.hpp @@ -0,0 +1,98 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file ListenerSubscriberApp.hpp + * + */ + +#ifndef _FASTDDS_HELLO_WORLD_LISTENER_SUBSCRIBER_APP_HPP_ +#define _FASTDDS_HELLO_WORLD_LISTENER_SUBSCRIBER_APP_HPP_ + +#include + +#include +#include +#include + +#include "CLIParser.hpp" +#include "HelloWorldPubSubTypes.h" +#include "Application.hpp" + +using namespace eprosima::fastdds::dds; + +namespace eprosima { +namespace fastdds { +namespace examples { +namespace hello_world { + +class ListenerSubscriberApp : public Application, public DataReaderListener +{ +public: + + ListenerSubscriberApp( + const CLIParser::subscriber_config& config, + const std::string& topic_name); + + ~ListenerSubscriberApp(); + + //! Subscription callback + void on_data_available( + DataReader* reader) override; + + //! Subscriber matched method + void on_subscription_matched( + DataReader* reader, + const SubscriptionMatchedStatus& info) override; + + //! Run subscriber + void run() override; + + //! Trigger the end of execution + void stop() override; + +private: + + //! Return the current state of execution + bool is_stopped(); + + HelloWorld hello_; + + DomainParticipant* participant_; + + Subscriber* subscriber_; + + Topic* topic_; + + DataReader* reader_; + + TypeSupport type_; + + uint16_t samples_; + + uint16_t received_samples_; + + std::atomic stop_; + + mutable std::mutex terminate_cv_mtx_; + + std::condition_variable terminate_cv_; +}; + +} // namespace hello_world +} // namespace examples +} // namespace fastdds +} // namespace eprosima + +#endif /* _FASTDDS_HELLO_WORLD_LISTENER_SUBSCRIBER_APP_HPP_ */ diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp b/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp new file mode 100644 index 00000000000..65b4ce0ca75 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp @@ -0,0 +1,179 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file PublisherApp.cpp + * + */ + +#include "PublisherApp.hpp" + +#include +#include + +#include +#include +#include +#include +#include + +using namespace eprosima::fastdds::dds; + +namespace eprosima { +namespace fastdds { +namespace examples { +namespace hello_world { + +PublisherApp::PublisherApp( + const CLIParser::publisher_config& config, + const std::string& topic_name) + : participant_(nullptr) + , publisher_(nullptr) + , topic_(nullptr) + , writer_(nullptr) + , type_(new HelloWorldPubSubType()) + , period_ms_(config.interval) + , matched_(0) + , samples_(config.samples) + , stop_(false) +{ + // Set up the data type with initial values + hello_.index(0); + hello_.message("Hello world"); + + // Create the participant + auto factory = DomainParticipantFactory::get_instance(); + participant_ = factory->create_participant_with_default_profile(nullptr, StatusMask::none()); + if (participant_ == nullptr) + { + throw std::runtime_error("Participant initialization failed"); + } + + // Register the type + type_.register_type(participant_); + + // Create the publisher + PublisherQos pub_qos = PUBLISHER_QOS_DEFAULT; + participant_->get_default_publisher_qos(pub_qos); + publisher_ = participant_->create_publisher(pub_qos, nullptr, StatusMask::none()); + if (publisher_ == nullptr) + { + throw std::runtime_error("Publisher initialization failed"); + } + + // Create the topic + TopicQos topic_qos = TOPIC_QOS_DEFAULT; + participant_->get_default_topic_qos(topic_qos); + topic_ = participant_->create_topic(topic_name, type_.get_type_name(), topic_qos); + if (topic_ == nullptr) + { + throw std::runtime_error("Topic initialization failed"); + } + + // Create the data writer + DataWriterQos writer_qos = DATAWRITER_QOS_DEFAULT; + publisher_->get_default_datawriter_qos(writer_qos); + writer_ = publisher_->create_datawriter(topic_, writer_qos, this, StatusMask::all()); + if (writer_ == nullptr) + { + throw std::runtime_error("DataWriter initialization failed"); + } +} + +PublisherApp::~PublisherApp() +{ + if (nullptr != participant_) + { + // Delete DDS entities contained within the DomainParticipant + participant_->delete_contained_entities(); + + // Delete DomainParticipant + DomainParticipantFactory::get_instance()->delete_participant(participant_); + } +} + +void PublisherApp::on_publication_matched( + DataWriter* /*writer*/, + const PublicationMatchedStatus& info) +{ + if (info.current_count_change == 1) + { + matched_ = static_cast(info.current_count); + std::cout << "Publisher matched." << std::endl; + cv_.notify_one(); + } + else if (info.current_count_change == -1) + { + matched_ = static_cast(info.current_count); + std::cout << "Publisher unmatched." << std::endl; + } + else + { + std::cout << info.current_count_change + << " is not a valid value for PublicationMatchedStatus current count change" << std::endl; + } +} + +void PublisherApp::run() +{ + while (!is_stopped() && ((samples_ == 0) || (hello_.index() < samples_))) + { + if (publish()) + { + std::cout << "Message: '" << hello_.message() << "' with index: '" << hello_.index() + << "' SENT" << std::endl; + } + // Wait for period or stop event + std::unique_lock period_lock(mutex_); + cv_.wait_for(period_lock, std::chrono::milliseconds(period_ms_), [&]() + { + return is_stopped(); + }); + } +} + +bool PublisherApp::publish() +{ + bool ret = false; + // Wait for the data endpoints discovery + std::unique_lock matched_lock(mutex_); + cv_.wait(matched_lock, [&]() + { + // at least one has been discovered + return ((matched_ > 0) || is_stopped()); + }); + + if (!is_stopped()) + { + hello_.index(hello_.index() + 1); + ret = writer_->write(&hello_); + } + return ret; +} + +bool PublisherApp::is_stopped() +{ + return stop_.load(); +} + +void PublisherApp::stop() +{ + stop_.store(true); + cv_.notify_one(); +} + +} // namespace hello_world +} // namespace examples +} // namespace fastdds +} // namespace eprosima diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp b/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp new file mode 100644 index 00000000000..23f2dd653b3 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp @@ -0,0 +1,100 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file PublisherApp.hpp + * + */ + +#ifndef _FASTDDS_HELLO_WORLD_PUBLISHER_APP_HPP_ +#define _FASTDDS_HELLO_WORLD_PUBLISHER_APP_HPP_ + +#include + +#include +#include +#include + +#include "Application.hpp" +#include "CLIParser.hpp" +#include "HelloWorldPubSubTypes.h" + +using namespace eprosima::fastdds::dds; + +namespace eprosima { +namespace fastdds { +namespace examples { +namespace hello_world { + +class PublisherApp : public Application, public DataWriterListener +{ +public: + + PublisherApp( + const CLIParser::publisher_config& config, + const std::string& topic_name); + + ~PublisherApp(); + + //! Publisher matched method + void on_publication_matched( + DataWriter* writer, + const PublicationMatchedStatus& info) override; + + //! Run publisher + void run() override; + + //! Stop publisher + void stop() override; + +private: + + //! Return the current state of execution + bool is_stopped(); + + //! Publish a sample + bool publish(); + + HelloWorld hello_; + + DomainParticipant* participant_; + + Publisher* publisher_; + + Topic* topic_; + + DataWriter* writer_; + + TypeSupport type_; + + const uint32_t period_ms_; // sleep time (ms) between consecutive samples + + int16_t matched_; + + uint16_t samples_; + + std::mutex mutex_; + + std::condition_variable cv_; + + std::atomic stop_; + +}; + +} // namespace hello_world +} // namespace examples +} // namespace fastdds +} // namespace eprosima + +#endif /* _FASTDDS_HELLO_WORLD_PUBLISHER_APP_HPP_ */ diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/README.md b/examples/cpp/dds_security/SecureHelloWorldExample/README.md new file mode 100644 index 00000000000..02e90eccacd --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/README.md @@ -0,0 +1,151 @@ +# Hello world example + +The *eProsima Fast DDS hello world* example is a simple application intended to demonstrate a basic DDS deployment. + +This example is part of the suite of examples designed by eProsima that aims to illustrate the features and possible configurations of DDS deployments through *eProsima Fast DDS*. + +In this case, the *hello world* example describes the simplest deployment of a Fast DDS publisher and subscriber. + +* [Description of the example](#description-of-the-example) +* [Run the example](#run-the-example) +* [Wait-set subscriber](#wait-set-subscriber) +* [XML profile playground](#xml-profile-playground) + +## Description of the example + +Each example application (publisher and subscriber) creates different nested DDS entities: domain participant, publisher, and data writer; and domain participant, subscriber, and data reader, respectively. +In both cases, the three DDS entities (domain participant, publisher/subscriber and data writer/data reader) load their default configuration from the environment. +If the environment does not specify the expected configuration, they take the default configuration per entity. +For further information regarding the configuration environment, please refer to the *[XML profile playground](#xml-profile-playground)* section. + +This particular example includes two different subscription paradigms; i.e. listening callbacks and wait-sets: + +* The listening callback mechanism consists on declaring a listener class and attaching it to the data reader. + When the data reader is triggered by an event, it runs the listener's method associated to that event, as a callback. + For simplicity, in this example, the subscriber class inherits from the listener class, overriding the corresponding callback. + +* The wait-set is a mechanism where a dedicated thread waits until a status condition occurs. + In that moment, that status condition triggering event would be evaluated to determine witch actions should be taken against it. + +For this example, both listening callback and wait-set implementation would run similar code and generate equivalent output for both triggering events: subscription matching and new data available. + +## Run the example + +To launch this example, two different terminals are required. +One of them will run the publisher example application, and the other will run the subscriber application. + +### Hello world publisher + +* Ubuntu ( / MacOS ) + + ```shell + user@machine:example_path$ ./hello_world publisher + Publisher running. Please press Ctrl+C to stop the Publisher at any time. + ``` + +* Windows + + ```powershell + example_path> hello_world.exe publisher + Publisher running. Please press Ctrl+C to stop the Publisher at any time. + ``` + +### Hello world subscriber + +* Ubuntu ( / MacOS ) + + ```shell + user@machine:example_path$ ./hello_world subscriber + Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. + ``` + +* Windows + + ```powershell + example_path> hello_world.exe subscriber + Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. + ``` + +All the example available flags can be queried running the executable with the ``-h`` or ``--help`` flag. + +### Expected output + +Regardless of which application is run first, since the publisher will not start sending data until a subscriber is discovered, the expected output both for publishers and subscribers is a first displayed message acknowledging the match, followed by the amount of samples sent or received until Ctrl+C is pressed. + +### Hello world publisher + +```shell +Publisher running. Please press Ctrl+C to stop the Publisher at any time. +Publisher matched. +Message: 'Hello world' with index: '1' SENT +Message: 'Hello world' with index: '2' SENT +Message: 'Hello world' with index: '3' SENT +... +``` + +### Hello world subscriber + +```shell +Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. +Subscriber matched. +Message: 'Hello world' with index: '1' RECEIVED +Message: 'Hello world' with index: '2' RECEIVED +Message: 'Hello world' with index: '3' RECEIVED +... +``` + +When Ctrl+C is pressed to stop one of the applications, the other one will show the unmatched status, displaying an informative message, and it will stop sending / receiving messages. +The following is a possible output of the publisher application when stopping the subscriber app. + +```shell +... +Message: 'Hello world' with index: '8' SENT +Message: 'Hello world' with index: '9' SENT +Message: 'Hello world' with index: '10' SENT +Message: 'Hello world' with index: '11' SENT +Publisher unmatched. +``` + +## Wait-set subscriber + +As described in the *[Description of the example](#description-of-the-example)* section, the *hello world* example has two listening implementations. Launching the subscriber example with the flag ``-w`` or ``--waitset`` will use the wait-set approach instead of the listening callback. + +* Ubuntu ( / MacOS ) + + ```shell + user@machine:example_path$ ./hello_world subscriber --waitset + ``` + +* Windows + + ```powershell + example_path> hello_world.exe subscriber --waitset + ``` + +The expected output is exactly the same as the described in the *[previous](#expected-output)* section. + +## XML profile playground + +The *eProsima Fast DDS* entities can be configured through an XML profile from the environment. +This is accomplished by setting the environment variable ``FASTDDS_DEFAULT_PROFILES_FILE`` to path to the XML profiles file: + +* Ubuntu ( / MacOS ) + + ```shell + user@machine:example_path$ export FASTDDS_DEFAULT_PROFILES_FILE=hello_world_profile.xml + ``` + +* Windows + + ```powershell + example_path> set FASTDDS_DEFAULT_PROFILES_FILE=hello_world_profile.xml + ``` + +The example provides with an XML profiles files with certain QoS: + +- Reliable reliability: avoid sample loss. +- Transient local durability: enable late-join subscriber applications to receive previous samples. +- Keep-last history with high depth: ensure certain amount of previous samples for late-joiners. + +Applying different configurations to the entities will change to a greater or lesser extent how the application behaves in relation to sample management. +Even when these settings affect the behavior of the sample management, the applications' output will be the similar. diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.cpp b/examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.cpp new file mode 100644 index 00000000000..49a39760e96 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.cpp @@ -0,0 +1,188 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file WaitsetSubscriberApp.cpp + * + */ + +#include "WaitsetSubscriberApp.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "HelloWorldPubSubTypes.h" +#include "CLIParser.hpp" +#include "Application.hpp" + +using namespace eprosima::fastdds::dds; + +namespace eprosima { +namespace fastdds { +namespace examples { +namespace hello_world { + +WaitsetSubscriberApp::WaitsetSubscriberApp( + const CLIParser::subscriber_config& config, + const std::string& topic_name) + : participant_(nullptr) + , subscriber_(nullptr) + , topic_(nullptr) + , reader_(nullptr) + , type_(new HelloWorldPubSubType()) + , samples_(config.samples) + , received_samples_(0) + , stop_(false) +{ + // Create the participant + auto factory = DomainParticipantFactory::get_instance(); + participant_ = factory->create_participant_with_default_profile(nullptr, StatusMask::none()); + if (participant_ == nullptr) + { + throw std::runtime_error("Participant initialization failed"); + } + + // Register the type + type_.register_type(participant_); + + // Create the subscriber + SubscriberQos sub_qos = SUBSCRIBER_QOS_DEFAULT; + participant_->get_default_subscriber_qos(sub_qos); + subscriber_ = participant_->create_subscriber(sub_qos, nullptr, StatusMask::none()); + if (subscriber_ == nullptr) + { + throw std::runtime_error("Subscriber initialization failed"); + } + + // Create the topic + TopicQos topic_qos = TOPIC_QOS_DEFAULT; + participant_->get_default_topic_qos(topic_qos); + topic_ = participant_->create_topic(topic_name, type_.get_type_name(), topic_qos); + if (topic_ == nullptr) + { + throw std::runtime_error("Topic initialization failed"); + } + + // Create the reader + DataReaderQos reader_qos = DATAREADER_QOS_DEFAULT; + subscriber_->get_default_datareader_qos(reader_qos); + reader_ = subscriber_->create_datareader(topic_, reader_qos, nullptr, StatusMask::all()); + if (reader_ == nullptr) + { + throw std::runtime_error("DataReader initialization failed"); + } + + // Prepare a wait-set + wait_set_.attach_condition(reader_->get_statuscondition()); + wait_set_.attach_condition(terminate_condition_); +} + +WaitsetSubscriberApp::~WaitsetSubscriberApp() +{ + if (nullptr != participant_) + { + // Delete DDS entities contained within the DomainParticipant + participant_->delete_contained_entities(); + + // Delete DomainParticipant + DomainParticipantFactory::get_instance()->delete_participant(participant_); + } +} + +void WaitsetSubscriberApp::run() +{ + while (!is_stopped()) + { + ConditionSeq triggered_conditions; + ReturnCode_t ret_code = wait_set_.wait(triggered_conditions, eprosima::fastdds::c_TimeInfinite); + if (RETCODE_OK != ret_code) + { + EPROSIMA_LOG_ERROR(SUBSCRIBER_WAITSET, "Error waiting for conditions"); + continue; + } + for (Condition* cond : triggered_conditions) + { + StatusCondition* status_cond = dynamic_cast(cond); + if (nullptr != status_cond) + { + Entity* entity = status_cond->get_entity(); + StatusMask changed_statuses = entity->get_status_changes(); + if (changed_statuses.is_active(StatusMask::subscription_matched())) + { + SubscriptionMatchedStatus status_; + reader_->get_subscription_matched_status(status_); + if (status_.current_count_change == 1) + { + std::cout << "Waitset Subscriber matched." << std::endl; + } + else if (status_.current_count_change == -1) + { + std::cout << "Waitset Subscriber unmatched." << std::endl; + } + else + { + std::cout << status_.current_count_change << + " is not a valid value for SubscriptionMatchedStatus current count change" << + std::endl; + } + } + if (changed_statuses.is_active(StatusMask::data_available())) + { + SampleInfo info; + while ((!is_stopped()) && + (RETCODE_OK == reader_->take_next_sample(&hello_, &info))) + { + if ((info.instance_state == ALIVE_INSTANCE_STATE) && info.valid_data) + { + received_samples_++; + // Print Hello world message data + std::cout << "Message: '" << hello_.message() << "' with index: '" + << hello_.index() << "' RECEIVED" << std::endl; + if (samples_ > 0 && (received_samples_ >= samples_)) + { + stop(); + } + } + } + } + } + } + } +} + +bool WaitsetSubscriberApp::is_stopped() +{ + return stop_.load(); +} + +void WaitsetSubscriberApp::stop() +{ + stop_.store(true); + terminate_condition_.set_trigger_value(true); +} + +} // namespace hello_world +} // namespace examples +} // namespace fastdds +} // namespace eprosima diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.hpp b/examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.hpp new file mode 100644 index 00000000000..cb27cc5c016 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.hpp @@ -0,0 +1,91 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file WaitsetSubscriberApp.hpp + * + */ + +#ifndef _FASTDDS_HELLO_WORLD_WAITSET_SUBSCRIBER_APP_HPP_ +#define _FASTDDS_HELLO_WORLD_WAITSET_SUBSCRIBER_APP_HPP_ + +#include +#include +#include +#include +#include +#include +#include + +#include "CLIParser.hpp" +#include "HelloWorldPubSubTypes.h" +#include "Application.hpp" + +using namespace eprosima::fastdds::dds; + +namespace eprosima { +namespace fastdds { +namespace examples { +namespace hello_world { + +class WaitsetSubscriberApp : public Application +{ +public: + + WaitsetSubscriberApp( + const CLIParser::subscriber_config& config, + const std::string& topic_name); + + ~WaitsetSubscriberApp(); + + //! Run subscriber + void run() override; + + //! Trigger the end of execution + void stop() override; + +private: + + //! Return the current state of execution + bool is_stopped(); + + HelloWorld hello_; + + DomainParticipant* participant_; + + Subscriber* subscriber_; + + Topic* topic_; + + DataReader* reader_; + + TypeSupport type_; + + WaitSet wait_set_; + + uint16_t samples_; + + uint16_t received_samples_; + + std::atomic stop_; + + GuardCondition terminate_condition_; +}; + +} // namespace hello_world +} // namespace examples +} // namespace fastdds +} // namespace eprosima + +#endif /* _FASTDDS_HELLO_WORLD_WAITSET_SUBSCRIBER_APP_HPP_ */ diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/governance.smime b/examples/cpp/dds_security/SecureHelloWorldExample/certs/governance.smime new file mode 100644 index 00000000000..42ffbceac6f --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/certs/governance.smime @@ -0,0 +1,71 @@ +MIME-Version: 1.0 +Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha-256"; boundary="----F43F382375A0826FABA8FE7FAAB5A1CB" + +This is an S/MIME signed message + +------F43F382375A0826FABA8FE7FAAB5A1CB +Content-Type: text/plain + + + + + + + + 0 + 230 + + + false + true + ENCRYPT + ENCRYPT + ENCRYPT + + + HelloWorldTopic + true + false + true + true + ENCRYPT + ENCRYPT + + + + + + +------F43F382375A0826FABA8FE7FAAB5A1CB +Content-Type: application/x-pkcs7-signature; name="smime.p7s" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="smime.p7s" + +MIIEeQYJKoZIhvcNAQcCoIIEajCCBGYCAQExDzANBglghkgBZQMEAgEFADALBgkq +hkiG9w0BBwGgggJAMIICPDCCAeOgAwIBAgIJALZwpgo2sxthMAoGCCqGSM49BAMC +MIGaMQswCQYDVQQGEwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2Fu +dG9zMREwDwYDVQQKDAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNV +BAMMFWVQcm9zaW1hIE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNh +QGVwcm9zaW1hLmNvbTAeFw0xNzA5MDYwOTAzMDNaFw0yNzA5MDQwOTAzMDNaMIGa +MQswCQYDVQQGEwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2FudG9z +MREwDwYDVQQKDAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNVBAMM +FWVQcm9zaW1hIE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNhQGVw +cm9zaW1hLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABGLlhB3WQ8l1fpUE +3DfOoulA/de38Zfj7hmpKtOnxiH2q6RJbwhxvJeA7R7mkmAKaJKmzx695BjyiXVS +7bE7vgejEDAOMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgVTY1BEvT +4pw3GyBMzaUqmp69wi0kBkyOgq04OhyJ13UCICR125vvt0fUhXsXaxOAx28E4Ac9 +SVxpI+3UYs2kV5n0MYIB/TCCAfkCAQEwgagwgZoxCzAJBgNVBAYTAkVTMQswCQYD +VQQIDAJNQTEUMBIGA1UEBwwLVHJlcyBDYW50b3MxETAPBgNVBAoMCGVQcm9zaW1h +MREwDwYDVQQLDAhlUHJvc2ltYTEeMBwGA1UEAwwVZVByb3NpbWEgTWFpbiBUZXN0 +IENBMSIwIAYJKoZIhvcNAQkBFhNtYWluY2FAZXByb3NpbWEuY29tAgkAtnCmCjaz +G2EwDQYJYIZIAWUDBAIBBQCggeQwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAc +BgkqhkiG9w0BCQUxDxcNMTgwNDIwMDgyMDQ2WjAvBgkqhkiG9w0BCQQxIgQgeV8j +PJHH8Gg7wfTMPR1+2k6an80T7+wAv/2B5p04GioweQYJKoZIhvcNAQkPMWwwajAL +BglghkgBZQMEASowCwYJYIZIAWUDBAEWMAsGCWCGSAFlAwQBAjAKBggqhkiG9w0D +BzAOBggqhkiG9w0DAgICAIAwDQYIKoZIhvcNAwICAUAwBwYFKw4DAgcwDQYIKoZI +hvcNAwICASgwCgYIKoZIzj0EAwIERzBFAiEAvzBGtFCtU3Y4kxT1B/yrEdSzFxgU +pjd1kI2z4Z92BnUCIGacA/Mi9qW5ezSNgL1qMr+F3RP1QVsugFndssz7OdQN + +------F43F382375A0826FABA8FE7FAAB5A1CB-- + diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/governance_dds_sec.xml b/examples/cpp/dds_security/SecureHelloWorldExample/certs/governance_dds_sec.xml new file mode 100644 index 00000000000..493fd3f1103 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/certs/governance_dds_sec.xml @@ -0,0 +1,30 @@ + + + + + + + 0 + 230 + + + false + true + ENCRYPT + ENCRYPT + ENCRYPT + + + HelloWorldTopic + true + false + true + true + ENCRYPT + ENCRYPT + + + + + diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/maincacert.pem b/examples/cpp/dds_security/SecureHelloWorldExample/certs/maincacert.pem new file mode 100644 index 00000000000..b6d2da28a1a --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/certs/maincacert.pem @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICPDCCAeOgAwIBAgIJALZwpgo2sxthMAoGCCqGSM49BAMCMIGaMQswCQYDVQQG +EwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2FudG9zMREwDwYDVQQK +DAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNVBAMMFWVQcm9zaW1h +IE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNhQGVwcm9zaW1hLmNv +bTAeFw0xNzA5MDYwOTAzMDNaFw0yNzA5MDQwOTAzMDNaMIGaMQswCQYDVQQGEwJF +UzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2FudG9zMREwDwYDVQQKDAhl +UHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNVBAMMFWVQcm9zaW1hIE1h +aW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNhQGVwcm9zaW1hLmNvbTBZ +MBMGByqGSM49AgEGCCqGSM49AwEHA0IABGLlhB3WQ8l1fpUE3DfOoulA/de38Zfj +7hmpKtOnxiH2q6RJbwhxvJeA7R7mkmAKaJKmzx695BjyiXVS7bE7vgejEDAOMAwG +A1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgVTY1BEvT4pw3GyBMzaUqmp69 +wi0kBkyOgq04OhyJ13UCICR125vvt0fUhXsXaxOAx28E4Ac9SVxpI+3UYs2kV5n0 +-----END CERTIFICATE----- diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/maincakey.pem b/examples/cpp/dds_security/SecureHelloWorldExample/certs/maincakey.pem new file mode 100644 index 00000000000..bd7d89f4bf3 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/certs/maincakey.pem @@ -0,0 +1,5 @@ +-----BEGIN PRIVATE KEY----- +MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgRaipe1KYZNzj+35E +N2jvtzjRsQ7n9Me/vm35UKGuVI6hRANCAARi5YQd1kPJdX6VBNw3zqLpQP3Xt/GX +4+4ZqSrTp8Yh9qukSW8IcbyXgO0e5pJgCmiSps8eveQY8ol1Uu2xO74H +-----END PRIVATE KEY----- diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubcert.pem b/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubcert.pem new file mode 100644 index 00000000000..ab99f06c5a5 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubcert.pem @@ -0,0 +1,44 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + ae:7b:ad:8c:07:5a:ea:f3 + Signature Algorithm: ecdsa-with-SHA256 + Issuer: C=ES, ST=MA, L=Tres Cantos, O=eProsima, OU=eProsima, CN=eProsima Main Test CA/emailAddress=mainca@eprosima.com + Validity + Not Before: Sep 6 09:04:05 2017 GMT + Not After : Sep 4 09:04:05 2027 GMT + Subject: C=ES, ST=MA, O=eProsima, OU=eProsima, CN=Main Publisher/emailAddress=mainpub@eprosima.com + Subject Public Key Info: + Public Key Algorithm: id-ecPublicKey + Public-Key: (256 bit) + pub: + 04:55:95:f0:0b:1f:56:3f:80:4e:97:7e:1b:69:9c: + 7b:54:53:22:c4:a3:96:e9:99:2c:3d:c7:a8:8c:ec: + 1c:fd:d1:35:e7:ba:7d:63:01:9b:42:82:00:73:2c: + 52:e2:e1:0b:db:53:d9:45:a0:f8:64:1c:be:c5:0d: + 51:18:14:9f:90 + ASN1 OID: prime256v1 + NIST CURVE: P-256 + X509v3 extensions: + X509v3 Basic Constraints: + CA:FALSE + Signature Algorithm: ecdsa-with-SHA256 + 30:45:02:21:00:9c:e7:46:44:78:0c:95:eb:a7:38:9a:a7:af: + 4b:6c:bd:84:3b:bb:85:09:25:3d:49:b1:79:9e:e2:7e:dc:99: + 42:02:20:60:78:bd:d0:1e:cd:bc:4b:e3:25:2f:dd:56:6d:c8: + 29:78:3d:df:72:bc:bd:90:de:c6:19:b0:48:44:31:c7:46 +-----BEGIN CERTIFICATE----- +MIICHTCCAcOgAwIBAgIJAK57rYwHWurzMAoGCCqGSM49BAMCMIGaMQswCQYDVQQG +EwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2FudG9zMREwDwYDVQQK +DAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNVBAMMFWVQcm9zaW1h +IE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNhQGVwcm9zaW1hLmNv +bTAeFw0xNzA5MDYwOTA0MDVaFw0yNzA5MDQwOTA0MDVaMH4xCzAJBgNVBAYTAkVT +MQswCQYDVQQIDAJNQTERMA8GA1UECgwIZVByb3NpbWExETAPBgNVBAsMCGVQcm9z +aW1hMRcwFQYDVQQDDA5NYWluIFB1Ymxpc2hlcjEjMCEGCSqGSIb3DQEJARYUbWFp +bnB1YkBlcHJvc2ltYS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARVlfAL +H1Y/gE6XfhtpnHtUUyLEo5bpmSw9x6iM7Bz90TXnun1jAZtCggBzLFLi4QvbU9lF +oPhkHL7FDVEYFJ+Qow0wCzAJBgNVHRMEAjAAMAoGCCqGSM49BAMCA0gAMEUCIQCc +50ZEeAyV66c4mqevS2y9hDu7hQklPUmxeZ7iftyZQgIgYHi90B7NvEvjJS/dVm3I +KXg933K8vZDexhmwSEQxx0Y= +-----END CERTIFICATE----- diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubkey.pem b/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubkey.pem new file mode 100644 index 00000000000..cfb610b539d --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubkey.pem @@ -0,0 +1,5 @@ +-----BEGIN PRIVATE KEY----- +MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgY5T1nA3Wpo8/JegF +k9vz0eTeboO2NB5LqoIDCICa8YChRANCAARVlfALH1Y/gE6XfhtpnHtUUyLEo5bp +mSw9x6iM7Bz90TXnun1jAZtCggBzLFLi4QvbU9lFoPhkHL7FDVEYFJ+Q +-----END PRIVATE KEY----- diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubcert.pem b/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubcert.pem new file mode 100644 index 00000000000..8d93e9e3b9f --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubcert.pem @@ -0,0 +1,44 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + ae:7b:ad:8c:07:5a:ea:f4 + Signature Algorithm: ecdsa-with-SHA256 + Issuer: C=ES, ST=MA, L=Tres Cantos, O=eProsima, OU=eProsima, CN=eProsima Main Test CA/emailAddress=mainca@eprosima.com + Validity + Not Before: Sep 6 09:05:01 2017 GMT + Not After : Sep 4 09:05:01 2027 GMT + Subject: C=ES, ST=MA, O=eProsima, OU=eProsima, CN=Main Subscriber/emailAddress=mainsub@eprosima.com + Subject Public Key Info: + Public Key Algorithm: id-ecPublicKey + Public-Key: (256 bit) + pub: + 04:bc:b4:db:7e:99:f8:24:a9:f9:ce:4d:ab:4e:4a: + 7c:17:73:9f:2a:15:0d:3b:0d:f5:f7:93:28:0b:df: + 00:f5:3d:96:84:11:c6:e4:fc:38:7b:bd:22:68:8a: + d7:07:80:d8:3c:b9:b0:c2:55:b2:eb:0c:8d:a7:a4: + 75:70:8b:16:3d + ASN1 OID: prime256v1 + NIST CURVE: P-256 + X509v3 extensions: + X509v3 Basic Constraints: + CA:FALSE + Signature Algorithm: ecdsa-with-SHA256 + 30:46:02:21:00:e0:aa:1e:90:67:d9:ef:37:cf:aa:30:d5:8a: + 9c:00:0c:7d:76:b8:61:49:eb:4a:7e:43:6d:bc:ea:2c:50:71: + 05:02:21:00:ed:73:99:02:f2:82:bc:49:69:43:97:19:14:a6: + d0:98:6a:49:ba:e3:ae:77:20:ab:6d:a5:43:b8:f1:5b:bb:46 +-----BEGIN CERTIFICATE----- +MIICHzCCAcSgAwIBAgIJAK57rYwHWur0MAoGCCqGSM49BAMCMIGaMQswCQYDVQQG +EwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2FudG9zMREwDwYDVQQK +DAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNVBAMMFWVQcm9zaW1h +IE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNhQGVwcm9zaW1hLmNv +bTAeFw0xNzA5MDYwOTA1MDFaFw0yNzA5MDQwOTA1MDFaMH8xCzAJBgNVBAYTAkVT +MQswCQYDVQQIDAJNQTERMA8GA1UECgwIZVByb3NpbWExETAPBgNVBAsMCGVQcm9z +aW1hMRgwFgYDVQQDDA9NYWluIFN1YnNjcmliZXIxIzAhBgkqhkiG9w0BCQEWFG1h +aW5zdWJAZXByb3NpbWEuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEvLTb +fpn4JKn5zk2rTkp8F3OfKhUNOw3195MoC98A9T2WhBHG5Pw4e70iaIrXB4DYPLmw +wlWy6wyNp6R1cIsWPaMNMAswCQYDVR0TBAIwADAKBggqhkjOPQQDAgNJADBGAiEA +4KoekGfZ7zfPqjDVipwADH12uGFJ60p+Q2286ixQcQUCIQDtc5kC8oK8SWlDlxkU +ptCYakm64653IKttpUO48Vu7Rg== +-----END CERTIFICATE----- diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubkey.pem b/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubkey.pem new file mode 100644 index 00000000000..27f93149cc9 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubkey.pem @@ -0,0 +1,5 @@ +-----BEGIN PRIVATE KEY----- +MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgJfWGXNN6B/1+Jz4x +o6H3pCmrC7rchZ/GMl8pg9uZ4gGhRANCAAS8tNt+mfgkqfnOTatOSnwXc58qFQ07 +DfX3kygL3wD1PZaEEcbk/Dh7vSJoitcHgNg8ubDCVbLrDI2npHVwixY9 +-----END PRIVATE KEY----- diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions.smime b/examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions.smime new file mode 100644 index 00000000000..cf559d7e311 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions.smime @@ -0,0 +1,88 @@ +MIME-Version: 1.0 +Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha-256"; boundary="----F47A2A15090FF0128FA1D352597E1AD4" + +This is an S/MIME signed message + +------F47A2A15090FF0128FA1D352597E1AD4 +Content-Type: text/plain + + + + + + emailAddress=mainpub@eprosima.com, CN=Main Publisher, OU=eProsima, O=eProsima, ST=MA, C=ES + + 2013-06-01T13:00:00 + 2038-06-01T13:00:00 + + + + + 0 + 230 + + + + + HelloWorldTopic + + + + DENY + + + emailAddress=mainsub@eprosima.com, CN=Main Subscriber, OU=eProsima, O=eProsima, ST=MA, C=ES + + 2013-06-01T13:00:00 + 2038-06-01T13:00:00 + + + + + 0 + 230 + + + + + HelloWorldTopic + + + + DENY + + + + +------F47A2A15090FF0128FA1D352597E1AD4 +Content-Type: application/x-pkcs7-signature; name="smime.p7s" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="smime.p7s" + +MIIEeQYJKoZIhvcNAQcCoIIEajCCBGYCAQExDzANBglghkgBZQMEAgEFADALBgkq +hkiG9w0BBwGgggJAMIICPDCCAeOgAwIBAgIJALZwpgo2sxthMAoGCCqGSM49BAMC +MIGaMQswCQYDVQQGEwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2Fu +dG9zMREwDwYDVQQKDAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNV +BAMMFWVQcm9zaW1hIE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNh +QGVwcm9zaW1hLmNvbTAeFw0xNzA5MDYwOTAzMDNaFw0yNzA5MDQwOTAzMDNaMIGa +MQswCQYDVQQGEwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2FudG9z +MREwDwYDVQQKDAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNVBAMM +FWVQcm9zaW1hIE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNhQGVw +cm9zaW1hLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABGLlhB3WQ8l1fpUE +3DfOoulA/de38Zfj7hmpKtOnxiH2q6RJbwhxvJeA7R7mkmAKaJKmzx695BjyiXVS +7bE7vgejEDAOMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgVTY1BEvT +4pw3GyBMzaUqmp69wi0kBkyOgq04OhyJ13UCICR125vvt0fUhXsXaxOAx28E4Ac9 +SVxpI+3UYs2kV5n0MYIB/TCCAfkCAQEwgagwgZoxCzAJBgNVBAYTAkVTMQswCQYD +VQQIDAJNQTEUMBIGA1UEBwwLVHJlcyBDYW50b3MxETAPBgNVBAoMCGVQcm9zaW1h +MREwDwYDVQQLDAhlUHJvc2ltYTEeMBwGA1UEAwwVZVByb3NpbWEgTWFpbiBUZXN0 +IENBMSIwIAYJKoZIhvcNAQkBFhNtYWluY2FAZXByb3NpbWEuY29tAgkAtnCmCjaz +G2EwDQYJYIZIAWUDBAIBBQCggeQwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAc +BgkqhkiG9w0BCQUxDxcNMTgwNDIwMDgyMjIzWjAvBgkqhkiG9w0BCQQxIgQgILQU +ebFR+2LG5xPwhlrTUf3b8T0MkR3aZjpsi/yptTMweQYJKoZIhvcNAQkPMWwwajAL +BglghkgBZQMEASowCwYJYIZIAWUDBAEWMAsGCWCGSAFlAwQBAjAKBggqhkiG9w0D +BzAOBggqhkiG9w0DAgICAIAwDQYIKoZIhvcNAwICAUAwBwYFKw4DAgcwDQYIKoZI +hvcNAwICASgwCgYIKoZIzj0EAwIERzBFAiEA2lSxk6YvQsqrx+LEjVwZI9/V6o5c +ggok/gGrVlbsEq0CIFWg6QFkrgny+OkJV2TNY3rSTr8YOvJa7Hm13pe9NqkP + +------F47A2A15090FF0128FA1D352597E1AD4-- + diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions_dds_sec.xml b/examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions_dds_sec.xml new file mode 100644 index 00000000000..b13d5051ef4 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions_dds_sec.xml @@ -0,0 +1,47 @@ + + + + + emailAddress=mainpub@eprosima.com, CN=Main Publisher, OU=eProsima, O=eProsima, ST=MA, C=ES + + 2013-06-01T13:00:00 + 2038-06-01T13:00:00 + + + + + 0 + 230 + + + + + HelloWorldTopic + + + + DENY + + + emailAddress=mainsub@eprosima.com, CN=Main Subscriber, OU=eProsima, O=eProsima, ST=MA, C=ES + + 2013-06-01T13:00:00 + 2038-06-01T13:00:00 + + + + + 0 + 230 + + + + + HelloWorldTopic + + + + DENY + + + diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/hello_world_profile.xml b/examples/cpp/dds_security/SecureHelloWorldExample/hello_world_profile.xml new file mode 100644 index 00000000000..646643e64f5 --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/hello_world_profile.xml @@ -0,0 +1,132 @@ + + + + 0 + + hello_world_participant + + + + + + dds.sec.auth.plugin + builtin.PKI-DH + + + + dds.sec.auth.builtin.PKI-DH.identity_ca + file://maincacert.pem + + + dds.sec.auth.builtin.PKI-DH.identity_certificate + file://partcert.pem + + + dds.sec.auth.builtin.PKI-DH.identity_crl + file://crl.pem + + + dds.sec.auth.builtin.PKI-DH.private_key + file://partkey.pem + + + dds.sec.auth.builtin.PKI-DH.password + domainParticipantPassword + + + + + + + + dds.sec.access.plugin + builtin.Access-Permissions + + + + dds.sec.access.builtin.Access-Permissions.permissions_ca + file://maincacet.pem + + + dds.sec.access.builtin.Access-Permissions.governance + file://governance.smime + + + dds.sec.access.builtin.Access-Permissions.permissions + file://permissions.smime + + + + + + + + dds.sec.crypto.plugin + builtin.AES-GCM-GMAC + + + + + + + + dds.sec.log.plugin + builtin.DDS_LogTopic + + + + dds.sec.log.builtin.DDS_LogTopic.logging_level + EMERGENCY_LEVEL + + + dds.sec.log.builtin.DDS_LogTopic.log_file + myLogFile.log + + + + + + + + + TRANSIENT_LOCAL + + + RELIABLE + + + + + KEEP_LAST + 100 + + + 100 + 1 + 100 + + + + + + + + TRANSIENT_LOCAL + + + RELIABLE + + + + + KEEP_LAST + 100 + + + 100 + 1 + 100 + + + + diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/main.cpp b/examples/cpp/dds_security/SecureHelloWorldExample/main.cpp new file mode 100644 index 00000000000..edfb6ff468e --- /dev/null +++ b/examples/cpp/dds_security/SecureHelloWorldExample/main.cpp @@ -0,0 +1,108 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file main.cpp + * + */ + +#include +#include +#include + +#include +#include + +#include "Application.hpp" +#include "CLIParser.hpp" + +using eprosima::fastdds::dds::Log; + +using namespace eprosima::fastdds::examples::hello_world; + +std::function stop_app_handler; +void signal_handler( + int signum) +{ + stop_app_handler(signum); +} + +int main( + int argc, + char** argv) +{ + auto ret = EXIT_SUCCESS; + const std::string topic_name = "hello_world_topic"; + CLIParser::hello_world_config config = CLIParser::parse_cli_options(argc, argv); + uint16_t samples = 0; + switch (config.entity) + { + case CLIParser::EntityKind::PUBLISHER: + samples = config.pub_config.samples; + break; + case CLIParser::EntityKind::SUBSCRIBER: + samples = config.sub_config.samples; + break; + default: + break; + } + + std::string app_name = CLIParser::parse_entity_kind(config.entity); + std::shared_ptr app; + + try + { + app = Application::make_app(config, topic_name); + } + catch (const std::runtime_error& e) + { + EPROSIMA_LOG_ERROR(app_name, e.what()); + ret = EXIT_FAILURE; + } + + if (EXIT_FAILURE != ret) + { + std::thread thread(&Application::run, app); + + if (samples == 0) + { + std::cout << app_name << " running. Please press Ctrl+C to stop the " + << app_name << " at any time." << std::endl; + } + else + { + std::cout << app_name << " running for " << samples << " samples. Please press Ctrl+C to stop the " + << app_name << " at any time." << std::endl; + } + + stop_app_handler = [&](int signum) + { + std::cout << "\n" << CLIParser::parse_signal(signum) << " received, stopping " << app_name + << " execution." << std::endl; + app->stop(); + }; + + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); + #ifndef _WIN32 + signal(SIGQUIT, signal_handler); + signal(SIGHUP, signal_handler); + #endif // _WIN32 + + thread.join(); + } + + Log::Reset(); + return ret; +} diff --git a/test/examples/SecureHelloWorldExample.compose.yml b/test/examples/SecureHelloWorldExample.compose.yml new file mode 100644 index 00000000000..0c858578d08 --- /dev/null +++ b/test/examples/SecureHelloWorldExample.compose.yml @@ -0,0 +1,29 @@ +# Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +version: "3" + +services: + subscriber-publisher: + image: @DOCKER_IMAGE_NAME@ + volumes: + - @PROJECT_BINARY_DIR@:@PROJECT_BINARY_DIR@ + - @fastcdr_LIB_DIR@:@fastcdr_LIB_DIR@ + @TINYXML2_LIB_DIR_COMPOSE_VOLUME@ + environment: + # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows + LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ + EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/dds_security/SecureHelloWorldExample + FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/dds_security/SecureHelloWorldExample/hello_world_profile.xml + command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ subscriber --samples 10 & $${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ publisher --samples 10" + diff --git a/test/examples/test_secure_hello_world.py b/test/examples/test_secure_hello_world.py new file mode 100644 index 00000000000..73fbbaa9568 --- /dev/null +++ b/test/examples/test_secure_hello_world.py @@ -0,0 +1,54 @@ +# Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import subprocess + +def test_hello_world(): + """.""" + ret = False + out = '' + try: + out = subprocess.check_output( + '@DOCKER_EXECUTABLE@ compose -f hello_world.compose.yml up', + stderr=subprocess.STDOUT, + shell=True, + timeout=30 + ).decode().split('\n') + + sent = 0 + received = 0 + for line in out: + if 'SENT' in line: + sent += 1 + continue + + if 'RECEIVED' in line: + received += 1 + continue + + if sent != 0 and received != 0 and sent * 2 == received: + ret = True + else: + print('ERROR: sent: ' + str(sent) + ', but received: ' + str(received) + + ' (expected: ' + str(sent * 2) + ')') + raise subprocess.CalledProcessError(1, '') + + except subprocess.CalledProcessError: + for l in out: + print(l) + except subprocess.TimeoutExpired: + print('TIMEOUT') + print(out) + + assert(ret) From 649fcb616bb3522c16c7e6cd89f47edaf8fc5c57 Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Fri, 28 Jun 2024 11:58:38 +0200 Subject: [PATCH 02/12] Refs #21266 Modify versions.md Signed-off-by: Carlosespicur --- versions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/versions.md b/versions.md index 0e089ecde11..30797c2f9e4 100644 --- a/versions.md +++ b/versions.md @@ -48,6 +48,7 @@ Forthcoming * Calling `DataReader::return_loan` returns `ReturnCode_t::RETCODE_OK` both for empty sequences and for sequences that were not loaned. * Refactor examples: * Hello world example with wait-sets and environment XML profiles. + * Secured hello world example with wait-sets and environment XML profiles. * Configuration example that condenses multiple QoS examples. Multiple configurations allowed through argument parsing. * Custom payload pool example that uses a user-defined payload pool instead of the default * X-Types example with dynamic type discovery and Hello world example compatibility. From e8d93cf048eae4dcf491f3acb8e39e5153ac1d29 Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Mon, 1 Jul 2024 08:11:01 +0200 Subject: [PATCH 03/12] Delete Waitset subscribers Signed-off-by: Carlosespicur --- .../SecureHelloWorldExample/Application.cpp | 12 +- .../SecureHelloWorldExample/CLIParser.hpp | 28 +-- .../SecureHelloWorldExample/PublisherApp.cpp | 2 +- .../SecureHelloWorldExample/PublisherApp.hpp | 2 +- ...nerSubscriberApp.cpp => SubscriberApp.cpp} | 18 +- ...nerSubscriberApp.hpp => SubscriberApp.hpp} | 10 +- .../WaitsetSubscriberApp.cpp | 188 ------------------ .../WaitsetSubscriberApp.hpp | 91 --------- 8 files changed, 22 insertions(+), 329 deletions(-) rename examples/cpp/dds_security/SecureHelloWorldExample/{ListenerSubscriberApp.cpp => SubscriberApp.cpp} (92%) rename examples/cpp/dds_security/SecureHelloWorldExample/{ListenerSubscriberApp.hpp => SubscriberApp.hpp} (90%) delete mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.cpp delete mode 100644 examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.hpp diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp b/examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp index fb42f74aafc..bab5ecce5ab 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp +++ b/examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp @@ -20,9 +20,8 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "ListenerSubscriberApp.hpp" +#include "SubscriberApp.hpp" #include "PublisherApp.hpp" -#include "WaitsetSubscriberApp.hpp" using namespace eprosima::fastdds::dds; @@ -43,14 +42,7 @@ std::shared_ptr Application::make_app( entity = std::make_shared(config.pub_config, topic_name); break; case CLIParser::EntityKind::SUBSCRIBER: - if (config.sub_config.use_waitset) - { - entity = std::make_shared(config.sub_config, topic_name); - } - else - { - entity = std::make_shared(config.sub_config, topic_name); - } + entity = std::make_shared(config.sub_config, topic_name); break; case CLIParser::EntityKind::UNDEFINED: default: diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp b/examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp index 39dc393b050..2e0a5e8349a 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp +++ b/examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp @@ -42,25 +42,19 @@ class CLIParser UNDEFINED }; - //! Publisher configuration structure (shared for both publisher and subscriber applications) - struct publisher_config + //! Configuration structure (shared for both publisher and subscriber applications) + struct entity_config { uint16_t samples = 0; uint32_t interval = 100; // milliseconds }; - //! Subscriber application configuration structure - struct subscriber_config : public publisher_config - { - bool use_waitset = false; - }; - //! Configuration structure for the application struct hello_world_config { CLIParser::EntityKind entity = CLIParser::EntityKind::UNDEFINED; - publisher_config pub_config; - subscriber_config sub_config; + entity_config pub_config; + entity_config sub_config; }; /** @@ -87,8 +81,6 @@ class CLIParser std::cout << "Publisher options:" << std::endl; std::cout << " -i , --interval Time between samples in milliseconds" << std::endl; std::cout << " [1 <= <= 4294967]" << std::endl; - std::cout << "Subscriber options:" << std::endl; - std::cout << " -w, --waitset Use waitset & read condition" << std::endl; std::exit(return_code); } @@ -188,18 +180,6 @@ class CLIParser print_help(EXIT_FAILURE); } } - else if (arg == "-w" || arg == "--waitset") - { - if (config.entity == CLIParser::EntityKind::SUBSCRIBER) - { - config.sub_config.use_waitset = true; - } - else - { - EPROSIMA_LOG_ERROR(CLI_PARSER, "waitset can only be used with the subscriber entity"); - print_help(EXIT_FAILURE); - } - } else if (arg == "-i" || arg == "--interval") { if (config.entity == CLIParser::EntityKind::PUBLISHER) diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp b/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp index 65b4ce0ca75..77eaa516f73 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp +++ b/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp @@ -36,7 +36,7 @@ namespace examples { namespace hello_world { PublisherApp::PublisherApp( - const CLIParser::publisher_config& config, + const CLIParser::entity_config& config, const std::string& topic_name) : participant_(nullptr) , publisher_(nullptr) diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp b/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp index 23f2dd653b3..ef904f7ad06 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp +++ b/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp @@ -42,7 +42,7 @@ class PublisherApp : public Application, public DataWriterListener public: PublisherApp( - const CLIParser::publisher_config& config, + const CLIParser::entity_config& config, const std::string& topic_name); ~PublisherApp(); diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.cpp b/examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.cpp similarity index 92% rename from examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.cpp rename to examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.cpp index f23bc15913b..0f1912d18f1 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.cpp +++ b/examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.cpp @@ -17,7 +17,7 @@ * */ -#include "ListenerSubscriberApp.hpp" +#include "SubscriberApp.hpp" #include #include @@ -41,8 +41,8 @@ namespace fastdds { namespace examples { namespace hello_world { -ListenerSubscriberApp::ListenerSubscriberApp( - const CLIParser::subscriber_config& config, +SubscriberApp::SubscriberApp( + const CLIParser::entity_config& config, const std::string& topic_name) : participant_(nullptr) , subscriber_(nullptr) @@ -93,7 +93,7 @@ ListenerSubscriberApp::ListenerSubscriberApp( } } -ListenerSubscriberApp::~ListenerSubscriberApp() +SubscriberApp::~SubscriberApp() { if (nullptr != participant_) { @@ -105,7 +105,7 @@ ListenerSubscriberApp::~ListenerSubscriberApp() } } -void ListenerSubscriberApp::on_subscription_matched( +void SubscriberApp::on_subscription_matched( DataReader* /*reader*/, const SubscriptionMatchedStatus& info) { @@ -124,7 +124,7 @@ void ListenerSubscriberApp::on_subscription_matched( } } -void ListenerSubscriberApp::on_data_available( +void SubscriberApp::on_data_available( DataReader* reader) { SampleInfo info; @@ -144,7 +144,7 @@ void ListenerSubscriberApp::on_data_available( } } -void ListenerSubscriberApp::run() +void SubscriberApp::run() { std::unique_lock lck(terminate_cv_mtx_); terminate_cv_.wait(lck, [&] @@ -153,12 +153,12 @@ void ListenerSubscriberApp::run() }); } -bool ListenerSubscriberApp::is_stopped() +bool SubscriberApp::is_stopped() { return stop_.load(); } -void ListenerSubscriberApp::stop() +void SubscriberApp::stop() { stop_.store(true); terminate_cv_.notify_all(); diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.hpp b/examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.hpp similarity index 90% rename from examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.hpp rename to examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.hpp index cd22791dec6..924889e96ab 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/ListenerSubscriberApp.hpp +++ b/examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.hpp @@ -13,7 +13,7 @@ // limitations under the License. /** - * @file ListenerSubscriberApp.hpp + * @file SubscriberApp.hpp * */ @@ -37,15 +37,15 @@ namespace fastdds { namespace examples { namespace hello_world { -class ListenerSubscriberApp : public Application, public DataReaderListener +class SubscriberApp : public Application, public DataReaderListener { public: - ListenerSubscriberApp( - const CLIParser::subscriber_config& config, + SubscriberApp( + const CLIParser::entity_config& config, const std::string& topic_name); - ~ListenerSubscriberApp(); + ~SubscriberApp(); //! Subscription callback void on_data_available( diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.cpp b/examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.cpp deleted file mode 100644 index 49a39760e96..00000000000 --- a/examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file WaitsetSubscriberApp.cpp - * - */ - -#include "WaitsetSubscriberApp.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "HelloWorldPubSubTypes.h" -#include "CLIParser.hpp" -#include "Application.hpp" - -using namespace eprosima::fastdds::dds; - -namespace eprosima { -namespace fastdds { -namespace examples { -namespace hello_world { - -WaitsetSubscriberApp::WaitsetSubscriberApp( - const CLIParser::subscriber_config& config, - const std::string& topic_name) - : participant_(nullptr) - , subscriber_(nullptr) - , topic_(nullptr) - , reader_(nullptr) - , type_(new HelloWorldPubSubType()) - , samples_(config.samples) - , received_samples_(0) - , stop_(false) -{ - // Create the participant - auto factory = DomainParticipantFactory::get_instance(); - participant_ = factory->create_participant_with_default_profile(nullptr, StatusMask::none()); - if (participant_ == nullptr) - { - throw std::runtime_error("Participant initialization failed"); - } - - // Register the type - type_.register_type(participant_); - - // Create the subscriber - SubscriberQos sub_qos = SUBSCRIBER_QOS_DEFAULT; - participant_->get_default_subscriber_qos(sub_qos); - subscriber_ = participant_->create_subscriber(sub_qos, nullptr, StatusMask::none()); - if (subscriber_ == nullptr) - { - throw std::runtime_error("Subscriber initialization failed"); - } - - // Create the topic - TopicQos topic_qos = TOPIC_QOS_DEFAULT; - participant_->get_default_topic_qos(topic_qos); - topic_ = participant_->create_topic(topic_name, type_.get_type_name(), topic_qos); - if (topic_ == nullptr) - { - throw std::runtime_error("Topic initialization failed"); - } - - // Create the reader - DataReaderQos reader_qos = DATAREADER_QOS_DEFAULT; - subscriber_->get_default_datareader_qos(reader_qos); - reader_ = subscriber_->create_datareader(topic_, reader_qos, nullptr, StatusMask::all()); - if (reader_ == nullptr) - { - throw std::runtime_error("DataReader initialization failed"); - } - - // Prepare a wait-set - wait_set_.attach_condition(reader_->get_statuscondition()); - wait_set_.attach_condition(terminate_condition_); -} - -WaitsetSubscriberApp::~WaitsetSubscriberApp() -{ - if (nullptr != participant_) - { - // Delete DDS entities contained within the DomainParticipant - participant_->delete_contained_entities(); - - // Delete DomainParticipant - DomainParticipantFactory::get_instance()->delete_participant(participant_); - } -} - -void WaitsetSubscriberApp::run() -{ - while (!is_stopped()) - { - ConditionSeq triggered_conditions; - ReturnCode_t ret_code = wait_set_.wait(triggered_conditions, eprosima::fastdds::c_TimeInfinite); - if (RETCODE_OK != ret_code) - { - EPROSIMA_LOG_ERROR(SUBSCRIBER_WAITSET, "Error waiting for conditions"); - continue; - } - for (Condition* cond : triggered_conditions) - { - StatusCondition* status_cond = dynamic_cast(cond); - if (nullptr != status_cond) - { - Entity* entity = status_cond->get_entity(); - StatusMask changed_statuses = entity->get_status_changes(); - if (changed_statuses.is_active(StatusMask::subscription_matched())) - { - SubscriptionMatchedStatus status_; - reader_->get_subscription_matched_status(status_); - if (status_.current_count_change == 1) - { - std::cout << "Waitset Subscriber matched." << std::endl; - } - else if (status_.current_count_change == -1) - { - std::cout << "Waitset Subscriber unmatched." << std::endl; - } - else - { - std::cout << status_.current_count_change << - " is not a valid value for SubscriptionMatchedStatus current count change" << - std::endl; - } - } - if (changed_statuses.is_active(StatusMask::data_available())) - { - SampleInfo info; - while ((!is_stopped()) && - (RETCODE_OK == reader_->take_next_sample(&hello_, &info))) - { - if ((info.instance_state == ALIVE_INSTANCE_STATE) && info.valid_data) - { - received_samples_++; - // Print Hello world message data - std::cout << "Message: '" << hello_.message() << "' with index: '" - << hello_.index() << "' RECEIVED" << std::endl; - if (samples_ > 0 && (received_samples_ >= samples_)) - { - stop(); - } - } - } - } - } - } - } -} - -bool WaitsetSubscriberApp::is_stopped() -{ - return stop_.load(); -} - -void WaitsetSubscriberApp::stop() -{ - stop_.store(true); - terminate_condition_.set_trigger_value(true); -} - -} // namespace hello_world -} // namespace examples -} // namespace fastdds -} // namespace eprosima diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.hpp b/examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.hpp deleted file mode 100644 index cb27cc5c016..00000000000 --- a/examples/cpp/dds_security/SecureHelloWorldExample/WaitsetSubscriberApp.hpp +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file WaitsetSubscriberApp.hpp - * - */ - -#ifndef _FASTDDS_HELLO_WORLD_WAITSET_SUBSCRIBER_APP_HPP_ -#define _FASTDDS_HELLO_WORLD_WAITSET_SUBSCRIBER_APP_HPP_ - -#include -#include -#include -#include -#include -#include -#include - -#include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.h" -#include "Application.hpp" - -using namespace eprosima::fastdds::dds; - -namespace eprosima { -namespace fastdds { -namespace examples { -namespace hello_world { - -class WaitsetSubscriberApp : public Application -{ -public: - - WaitsetSubscriberApp( - const CLIParser::subscriber_config& config, - const std::string& topic_name); - - ~WaitsetSubscriberApp(); - - //! Run subscriber - void run() override; - - //! Trigger the end of execution - void stop() override; - -private: - - //! Return the current state of execution - bool is_stopped(); - - HelloWorld hello_; - - DomainParticipant* participant_; - - Subscriber* subscriber_; - - Topic* topic_; - - DataReader* reader_; - - TypeSupport type_; - - WaitSet wait_set_; - - uint16_t samples_; - - uint16_t received_samples_; - - std::atomic stop_; - - GuardCondition terminate_condition_; -}; - -} // namespace hello_world -} // namespace examples -} // namespace fastdds -} // namespace eprosima - -#endif /* _FASTDDS_HELLO_WORLD_WAITSET_SUBSCRIBER_APP_HPP_ */ From a5ecca29272ec5c03ddbeefaf9ae55a2327cdcc7 Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Tue, 2 Jul 2024 07:24:24 +0200 Subject: [PATCH 04/12] Refs #21266 Change namespaces, README and regenerate types Signed-off-by: Carlosespicur --- examples/CMakeLists.txt | 3 -- examples/cpp/dds_security/CMakeLists.txt | 15 ------ .../Application.cpp | 8 +-- .../Application.hpp | 12 ++--- .../CLIParser.hpp | 19 +++---- .../CMakeLists.txt | 16 +++--- .../HelloWorld.hpp | 4 +- .../HelloWorld.idl | 0 .../HelloWorldCdrAux.hpp | 6 +-- .../HelloWorldCdrAux.ipp | 6 +-- .../HelloWorldPubSubTypes.cxx | 2 +- .../HelloWorldPubSubTypes.hpp} | 18 +++---- .../HelloWorldTypeObjectSupport.cxx | 0 .../HelloWorldTypeObjectSupport.hpp | 6 +-- .../PublisherApp.cpp | 9 ++-- .../PublisherApp.hpp | 12 ++--- .../README.md | 53 +++++-------------- .../SubscriberApp.cpp | 8 +-- .../SubscriberApp.hpp | 14 ++--- .../certs/governance.smime | 0 .../certs/governance_dds_sec.xml | 0 .../certs/maincacert.pem | 0 .../certs/maincakey.pem | 0 .../certs/mainpubcert.pem | 0 .../certs/mainpubkey.pem | 0 .../certs/mainsubcert.pem | 0 .../certs/mainsubkey.pem | 0 .../certs/permissions.smime | 0 .../certs/permissions_dds_sec.xml | 0 .../hello_world_profile.xml | 0 .../main.cpp | 6 +-- ...ample.compose.yml => security.compose.yml} | 6 +-- ...secure_hello_world.py => test_security.py} | 4 +- versions.md | 2 +- 34 files changed, 94 insertions(+), 135 deletions(-) delete mode 100644 examples/cpp/dds_security/CMakeLists.txt rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/Application.cpp (94%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/Application.hpp (82%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/CLIParser.hpp (96%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/CMakeLists.txt (80%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorld.hpp (98%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorld.idl (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorldCdrAux.hpp (88%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorldCdrAux.ipp (96%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorldPubSubTypes.cxx (99%) rename examples/cpp/{dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.h => security/HelloWorldPubSubTypes.hpp} (89%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorldTypeObjectSupport.cxx (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorldTypeObjectSupport.hpp (90%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/PublisherApp.cpp (98%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/PublisherApp.hpp (87%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/README.md (68%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/SubscriberApp.cpp (98%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/SubscriberApp.hpp (88%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/governance.smime (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/governance_dds_sec.xml (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/maincacert.pem (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/maincakey.pem (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/mainpubcert.pem (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/mainpubkey.pem (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/mainsubcert.pem (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/mainsubkey.pem (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/permissions.smime (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/permissions_dds_sec.xml (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/hello_world_profile.xml (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/main.cpp (93%) rename test/examples/{SecureHelloWorldExample.compose.yml => security.compose.yml} (77%) rename test/examples/{test_secure_hello_world.py => test_security.py} (94%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c3c8300cc93..9e10992efc5 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -19,11 +19,8 @@ add_subdirectory(cpp/content_filter) add_subdirectory(cpp/custom_payload_pool) add_subdirectory(cpp/dds) add_subdirectory(cpp/delivery_mechanisms) -<<<<<<< HEAD add_subdirectory(cpp/discovery_server) -======= add_subdirectory(cpp/dds_security) ->>>>>>> 420ed93df (Refs #21266 Add secured hello world example) add_subdirectory(cpp/hello_world) add_subdirectory(cpp/rtps) add_subdirectory(cpp/xtypes) diff --git a/examples/cpp/dds_security/CMakeLists.txt b/examples/cpp/dds_security/CMakeLists.txt deleted file mode 100644 index e3d1763df50..00000000000 --- a/examples/cpp/dds_security/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_subdirectory(SecureHelloWorldExample) \ No newline at end of file diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp b/examples/cpp/security/Application.cpp similarity index 94% rename from examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp rename to examples/cpp/security/Application.cpp index bab5ecce5ab..698d771e034 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp +++ b/examples/cpp/security/Application.cpp @@ -20,19 +20,19 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "SubscriberApp.hpp" #include "PublisherApp.hpp" +#include "SubscriberApp.hpp" using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { //! Factory method to create a publisher or subscriber std::shared_ptr Application::make_app( - const CLIParser::hello_world_config& config, + const CLIParser::security_config& config, const std::string& topic_name) { std::shared_ptr entity; @@ -52,7 +52,7 @@ std::shared_ptr Application::make_app( return entity; } -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/Application.hpp b/examples/cpp/security/Application.hpp similarity index 82% rename from examples/cpp/dds_security/SecureHelloWorldExample/Application.hpp rename to examples/cpp/security/Application.hpp index 9d1f01b214b..535b84dad08 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/Application.hpp +++ b/examples/cpp/security/Application.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_HELLO_WORLD_APPLICATION_HPP_ -#define _FASTDDS_HELLO_WORLD_APPLICATION_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__APPLICATION_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__APPLICATION_HPP #include @@ -27,7 +27,7 @@ namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { class Application { @@ -44,13 +44,13 @@ class Application //! Factory method to create applications based on configuration static std::shared_ptr make_app( - const CLIParser::hello_world_config& config, + const CLIParser::security_config& config, const std::string& topic_name); }; -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_HELLO_WORLD_APPLICATION_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__APPLICATION_HPP */ diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp b/examples/cpp/security/CLIParser.hpp similarity index 96% rename from examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp rename to examples/cpp/security/CLIParser.hpp index 2e0a5e8349a..7bbe8fe0e80 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp +++ b/examples/cpp/security/CLIParser.hpp @@ -16,15 +16,16 @@ #include #include #include + #include -#ifndef _FASTDDS_HELLO_WORLD_CLI_PARSER_HPP_ -#define _FASTDDS_HELLO_WORLD_CLI_PARSER_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__CLI_PARSER_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__CLI_PARSER_HPP namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { using dds::Log; @@ -50,7 +51,7 @@ class CLIParser }; //! Configuration structure for the application - struct hello_world_config + struct security_config { CLIParser::EntityKind entity = CLIParser::EntityKind::UNDEFINED; entity_config pub_config; @@ -67,7 +68,7 @@ class CLIParser static void print_help( uint8_t return_code) { - std::cout << "Usage: hello_world [options]" << std::endl; + std::cout << "Usage: security [options]" << std::endl; std::cout << "" << std::endl; std::cout << "Entities:" << std::endl; std::cout << " publisher Run a publisher entity" << std::endl; @@ -93,11 +94,11 @@ class CLIParser * * @warning This method finishes the execution of the program if the input arguments are invalid */ - static hello_world_config parse_cli_options( + static security_config parse_cli_options( int argc, char* argv[]) { - hello_world_config config; + security_config config; if (argc < 2) { @@ -283,9 +284,9 @@ class CLIParser }; -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima -#endif // _FASTDDS_HELLO_WORLD_CLI_PARSER_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_SECURITY__CLI_PARSER_HPP diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/CMakeLists.txt b/examples/cpp/security/CMakeLists.txt similarity index 80% rename from examples/cpp/dds_security/SecureHelloWorldExample/CMakeLists.txt rename to examples/cpp/security/CMakeLists.txt index 4730ff52599..5e7ac34ed0a 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/CMakeLists.txt +++ b/examples/cpp/security/CMakeLists.txt @@ -38,17 +38,17 @@ message(STATUS "Configuring secure hello world example...") file(GLOB SECURE_HELLO_WORLD_SOURCES_CXX "*.cxx") file(GLOB SECURE_HELLO_WORLD_SOURCES_CPP "*.cpp") -add_executable(SecureHelloWorldExample ${SECURE_HELLO_WORLD_SOURCES_CXX} ${SECURE_HELLO_WORLD_SOURCES_CPP}) -target_compile_definitions(SecureHelloWorldExample PRIVATE +add_executable(security ${SECURE_HELLO_WORLD_SOURCES_CXX} ${SECURE_HELLO_WORLD_SOURCES_CPP}) +target_compile_definitions(security PRIVATE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. $<$:SHM_TRANSPORT_BUILTIN> # Enable SHM as built-in transport ) -target_link_libraries(SecureHelloWorldExample fastdds fastcdr) -install(TARGETS SecureHelloWorldExample - RUNTIME DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/dds_security/SecureHelloWorldExample/${BIN_INSTALL_DIR}) +target_link_libraries(security fastdds fastcdr) +install(TARGETS security + RUNTIME DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/security/${BIN_INSTALL_DIR}) install(DIRECTORY ${PROJECT_SOURCE_DIR}/certs - DESTINATION examples/cpp/dds_security/SecureHelloWorldExample/${BIN_INSTALL_DIR}) + DESTINATION examples/cpp/security/${BIN_INSTALL_DIR}) # Copy the XML files over to the build directory file(GLOB_RECURSE XML_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.xml) # for each xml file detected @@ -61,10 +61,10 @@ foreach(XML_FILE_COMPLETE_PATH ${XML_FILES}) ${CMAKE_CURRENT_BINARY_DIR}/${XML_FILE}.xml # to relative build path COPYONLY) install(FILES ${XML_FILE_COMPLETE_PATH} - DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/dds_security/SecureHelloWorldExample/${BIN_INSTALL_DIR}) + DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/security/${BIN_INSTALL_DIR}) endforeach() -add_custom_command(TARGET SecureHelloWorldExample POST_BUILD +add_custom_command(TARGET security POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/certs ${PROJECT_BINARY_DIR}/certs) diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.hpp b/examples/cpp/security/HelloWorld.hpp similarity index 98% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.hpp rename to examples/cpp/security/HelloWorld.hpp index 971fea8d920..46d0d7b5814 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.hpp +++ b/examples/cpp/security/HelloWorld.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_HPP #include #include diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.idl b/examples/cpp/security/HelloWorld.idl similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.idl rename to examples/cpp/security/HelloWorld.idl diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.hpp b/examples/cpp/security/HelloWorldCdrAux.hpp similarity index 88% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.hpp rename to examples/cpp/security/HelloWorldCdrAux.hpp index 6feb8a9da15..1164cd5cce1 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.hpp +++ b/examples/cpp/security/HelloWorldCdrAux.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP +#define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP #include "HelloWorld.hpp" @@ -42,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.ipp b/examples/cpp/security/HelloWorldCdrAux.ipp similarity index 96% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.ipp rename to examples/cpp/security/HelloWorldCdrAux.ipp index 97df3fe9d9e..19316df7d3c 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.ipp +++ b/examples/cpp/security/HelloWorldCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP +#define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP #include "HelloWorldCdrAux.hpp" @@ -122,5 +122,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx b/examples/cpp/security/HelloWorldPubSubTypes.cxx similarity index 99% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx rename to examples/cpp/security/HelloWorldPubSubTypes.cxx index 41da39407fa..38393dbf8c9 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx +++ b/examples/cpp/security/HelloWorldPubSubTypes.cxx @@ -19,7 +19,7 @@ * This file was generated by the tool fastddsgen. */ -#include "HelloWorldPubSubTypes.h" +#include "HelloWorldPubSubTypes.hpp" #include #include diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.h b/examples/cpp/security/HelloWorldPubSubTypes.hpp similarity index 89% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.h rename to examples/cpp/security/HelloWorldPubSubTypes.hpp index 3db9ca96458..556d4c05ecf 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.h +++ b/examples/cpp/security/HelloWorldPubSubTypes.hpp @@ -13,21 +13,21 @@ // limitations under the License. /*! - * @file HelloWorldPubSubTypes.h + * @file HelloWorldPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "HelloWorld.hpp" @@ -106,7 +106,7 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -124,10 +124,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; -#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.cxx b/examples/cpp/security/HelloWorldTypeObjectSupport.cxx similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.cxx rename to examples/cpp/security/HelloWorldTypeObjectSupport.cxx diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp b/examples/cpp/security/HelloWorldTypeObjectSupport.hpp similarity index 90% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp rename to examples/cpp/security/HelloWorldTypeObjectSupport.hpp index 2eba797b07f..ec922163d11 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp +++ b/examples/cpp/security/HelloWorldTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP #include @@ -53,4 +53,4 @@ eProsima_user_DllExport void register_HelloWorld_type_identifier( #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp b/examples/cpp/security/PublisherApp.cpp similarity index 98% rename from examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp rename to examples/cpp/security/PublisherApp.cpp index 77eaa516f73..d918d162559 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp +++ b/examples/cpp/security/PublisherApp.cpp @@ -17,8 +17,6 @@ * */ -#include "PublisherApp.hpp" - #include #include @@ -28,12 +26,15 @@ #include #include +#include "PublisherApp.hpp" +#include "HelloWorldPubSubTypes.hpp" + using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { PublisherApp::PublisherApp( const CLIParser::entity_config& config, @@ -173,7 +174,7 @@ void PublisherApp::stop() cv_.notify_one(); } -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp b/examples/cpp/security/PublisherApp.hpp similarity index 87% rename from examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp rename to examples/cpp/security/PublisherApp.hpp index ef904f7ad06..0ff5efdeedd 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp +++ b/examples/cpp/security/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_HELLO_WORLD_PUBLISHER_APP_HPP_ -#define _FASTDDS_HELLO_WORLD_PUBLISHER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_PUBLISHER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_PUBLISHER_APP_HPP #include @@ -28,14 +28,14 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.h" +#include "HelloWorld.hpp" using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { class PublisherApp : public Application, public DataWriterListener { @@ -92,9 +92,9 @@ class PublisherApp : public Application, public DataWriterListener }; -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_HELLO_WORLD_PUBLISHER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_PUBLISHER_APP_HPP */ diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/README.md b/examples/cpp/security/README.md similarity index 68% rename from examples/cpp/dds_security/SecureHelloWorldExample/README.md rename to examples/cpp/security/README.md index 02e90eccacd..ab311ab61c3 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/README.md +++ b/examples/cpp/security/README.md @@ -1,10 +1,10 @@ -# Hello world example +# Secure Hello world example -The *eProsima Fast DDS hello world* example is a simple application intended to demonstrate a basic DDS deployment. +The *eProsima Fast DDS hello world* example is a simple application intended to demonstrate a basic DDS deployment with security builtin plugins. This example is part of the suite of examples designed by eProsima that aims to illustrate the features and possible configurations of DDS deployments through *eProsima Fast DDS*. -In this case, the *hello world* example describes the simplest deployment of a Fast DDS publisher and subscriber. +In this case, the *secure hello world* example describes the simplest deployment of a Fast DDS publisher and subscriber using the DDS Security specification. * [Description of the example](#description-of-the-example) * [Run the example](#run-the-example) @@ -18,51 +18,43 @@ In both cases, the three DDS entities (domain participant, publisher/subscriber If the environment does not specify the expected configuration, they take the default configuration per entity. For further information regarding the configuration environment, please refer to the *[XML profile playground](#xml-profile-playground)* section. -This particular example includes two different subscription paradigms; i.e. listening callbacks and wait-sets: - -* The listening callback mechanism consists on declaring a listener class and attaching it to the data reader. - When the data reader is triggered by an event, it runs the listener's method associated to that event, as a callback. - For simplicity, in this example, the subscriber class inherits from the listener class, overriding the corresponding callback. - -* The wait-set is a mechanism where a dedicated thread waits until a status condition occurs. - In that moment, that status condition triggering event would be evaluated to determine witch actions should be taken against it. - -For this example, both listening callback and wait-set implementation would run similar code and generate equivalent output for both triggering events: subscription matching and new data available. +This particular example includes only the listening callback mechanism, which consists on declaring a listener class and attaching it to the data reader. When the data reader is triggered by an event, it runs the listener's method associated to that event, as a callback. +For simplicity, in this example, the subscriber class inherits from the listener class, overriding the corresponding callback. ## Run the example To launch this example, two different terminals are required. One of them will run the publisher example application, and the other will run the subscriber application. -### Hello world publisher +### Secure Hello world publisher * Ubuntu ( / MacOS ) ```shell - user@machine:example_path$ ./hello_world publisher + user@machine:example_path$ ./security publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` * Windows ```powershell - example_path> hello_world.exe publisher + example_path> security.exe publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -### Hello world subscriber +### Secure Hello world subscriber * Ubuntu ( / MacOS ) ```shell - user@machine:example_path$ ./hello_world subscriber + user@machine:example_path$ ./security subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` * Windows ```powershell - example_path> hello_world.exe subscriber + example_path> security.exe subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` @@ -72,7 +64,7 @@ All the example available flags can be queried running the executable with the ` Regardless of which application is run first, since the publisher will not start sending data until a subscriber is discovered, the expected output both for publishers and subscribers is a first displayed message acknowledging the match, followed by the amount of samples sent or received until Ctrl+C is pressed. -### Hello world publisher +### Secure Hello world publisher ```shell Publisher running. Please press Ctrl+C to stop the Publisher at any time. @@ -83,7 +75,7 @@ Message: 'Hello world' with index: '3' SENT ... ``` -### Hello world subscriber +### Secure Hello world subscriber ```shell Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. @@ -106,24 +98,6 @@ Message: 'Hello world' with index: '11' SENT Publisher unmatched. ``` -## Wait-set subscriber - -As described in the *[Description of the example](#description-of-the-example)* section, the *hello world* example has two listening implementations. Launching the subscriber example with the flag ``-w`` or ``--waitset`` will use the wait-set approach instead of the listening callback. - -* Ubuntu ( / MacOS ) - - ```shell - user@machine:example_path$ ./hello_world subscriber --waitset - ``` - -* Windows - - ```powershell - example_path> hello_world.exe subscriber --waitset - ``` - -The expected output is exactly the same as the described in the *[previous](#expected-output)* section. - ## XML profile playground The *eProsima Fast DDS* entities can be configured through an XML profile from the environment. @@ -147,5 +121,6 @@ The example provides with an XML profiles files with certain QoS: - Transient local durability: enable late-join subscriber applications to receive previous samples. - Keep-last history with high depth: ensure certain amount of previous samples for late-joiners. +It also includes by default the builtin plugins required to provide secure communications. Applying different configurations to the entities will change to a greater or lesser extent how the application behaves in relation to sample management. Even when these settings affect the behavior of the sample management, the applications' output will be the similar. diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.cpp b/examples/cpp/security/SubscriberApp.cpp similarity index 98% rename from examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.cpp rename to examples/cpp/security/SubscriberApp.cpp index 0f1912d18f1..0152942c982 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.cpp +++ b/examples/cpp/security/SubscriberApp.cpp @@ -30,16 +30,16 @@ #include #include -#include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.h" #include "Application.hpp" +#include "CLIParser.hpp" +#include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { SubscriberApp::SubscriberApp( const CLIParser::entity_config& config, @@ -164,7 +164,7 @@ void SubscriberApp::stop() terminate_cv_.notify_all(); } -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.hpp b/examples/cpp/security/SubscriberApp.hpp similarity index 88% rename from examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.hpp rename to examples/cpp/security/SubscriberApp.hpp index 924889e96ab..4e3751e8cfb 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.hpp +++ b/examples/cpp/security/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_HELLO_WORLD_LISTENER_SUBSCRIBER_APP_HPP_ -#define _FASTDDS_HELLO_WORLD_LISTENER_SUBSCRIBER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_SUBSCRIBER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_SUBSCRIBER_APP_HPP #include @@ -26,16 +26,16 @@ #include #include -#include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.h" #include "Application.hpp" +#include "CLIParser.hpp" +#include "HelloWorld.hpp" using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { class SubscriberApp : public Application, public DataReaderListener { @@ -90,9 +90,9 @@ class SubscriberApp : public Application, public DataReaderListener std::condition_variable terminate_cv_; }; -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_HELLO_WORLD_LISTENER_SUBSCRIBER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_SUBSCRIBER_APP_HPP */ diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/governance.smime b/examples/cpp/security/certs/governance.smime similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/governance.smime rename to examples/cpp/security/certs/governance.smime diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/governance_dds_sec.xml b/examples/cpp/security/certs/governance_dds_sec.xml similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/governance_dds_sec.xml rename to examples/cpp/security/certs/governance_dds_sec.xml diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/maincacert.pem b/examples/cpp/security/certs/maincacert.pem similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/maincacert.pem rename to examples/cpp/security/certs/maincacert.pem diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/maincakey.pem b/examples/cpp/security/certs/maincakey.pem similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/maincakey.pem rename to examples/cpp/security/certs/maincakey.pem diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubcert.pem b/examples/cpp/security/certs/mainpubcert.pem similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubcert.pem rename to examples/cpp/security/certs/mainpubcert.pem diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubkey.pem b/examples/cpp/security/certs/mainpubkey.pem similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubkey.pem rename to examples/cpp/security/certs/mainpubkey.pem diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubcert.pem b/examples/cpp/security/certs/mainsubcert.pem similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubcert.pem rename to examples/cpp/security/certs/mainsubcert.pem diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubkey.pem b/examples/cpp/security/certs/mainsubkey.pem similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubkey.pem rename to examples/cpp/security/certs/mainsubkey.pem diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions.smime b/examples/cpp/security/certs/permissions.smime similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions.smime rename to examples/cpp/security/certs/permissions.smime diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions_dds_sec.xml b/examples/cpp/security/certs/permissions_dds_sec.xml similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions_dds_sec.xml rename to examples/cpp/security/certs/permissions_dds_sec.xml diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/hello_world_profile.xml b/examples/cpp/security/hello_world_profile.xml similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/hello_world_profile.xml rename to examples/cpp/security/hello_world_profile.xml diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/main.cpp b/examples/cpp/security/main.cpp similarity index 93% rename from examples/cpp/dds_security/SecureHelloWorldExample/main.cpp rename to examples/cpp/security/main.cpp index edfb6ff468e..702a77ccf3f 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/main.cpp +++ b/examples/cpp/security/main.cpp @@ -29,7 +29,7 @@ using eprosima::fastdds::dds::Log; -using namespace eprosima::fastdds::examples::hello_world; +using namespace eprosima::fastdds::examples::security; std::function stop_app_handler; void signal_handler( @@ -43,8 +43,8 @@ int main( char** argv) { auto ret = EXIT_SUCCESS; - const std::string topic_name = "hello_world_topic"; - CLIParser::hello_world_config config = CLIParser::parse_cli_options(argc, argv); + const std::string topic_name = "security_topic"; + CLIParser::security_config config = CLIParser::parse_cli_options(argc, argv); uint16_t samples = 0; switch (config.entity) { diff --git a/test/examples/SecureHelloWorldExample.compose.yml b/test/examples/security.compose.yml similarity index 77% rename from test/examples/SecureHelloWorldExample.compose.yml rename to test/examples/security.compose.yml index 0c858578d08..76c97afb25d 100644 --- a/test/examples/SecureHelloWorldExample.compose.yml +++ b/test/examples/security.compose.yml @@ -23,7 +23,7 @@ services: environment: # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ - EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/dds_security/SecureHelloWorldExample - FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/dds_security/SecureHelloWorldExample/hello_world_profile.xml - command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ subscriber --samples 10 & $${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ publisher --samples 10" + EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/security + FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/security/hello_world_profile.xml + command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/security@FILE_EXTENSION@ subscriber --samples 10 & $${EXAMPLE_DIR}/security@FILE_EXTENSION@ publisher --samples 10" diff --git a/test/examples/test_secure_hello_world.py b/test/examples/test_security.py similarity index 94% rename from test/examples/test_secure_hello_world.py rename to test/examples/test_security.py index 73fbbaa9568..63e4b93cd87 100644 --- a/test/examples/test_secure_hello_world.py +++ b/test/examples/test_security.py @@ -14,13 +14,13 @@ import subprocess -def test_hello_world(): +def test_security(): """.""" ret = False out = '' try: out = subprocess.check_output( - '@DOCKER_EXECUTABLE@ compose -f hello_world.compose.yml up', + '@DOCKER_EXECUTABLE@ compose -f security.compose.yml up', stderr=subprocess.STDOUT, shell=True, timeout=30 diff --git a/versions.md b/versions.md index 30797c2f9e4..de0ce875016 100644 --- a/versions.md +++ b/versions.md @@ -48,7 +48,7 @@ Forthcoming * Calling `DataReader::return_loan` returns `ReturnCode_t::RETCODE_OK` both for empty sequences and for sequences that were not loaned. * Refactor examples: * Hello world example with wait-sets and environment XML profiles. - * Secured hello world example with wait-sets and environment XML profiles. + * Secured hello world example with environment XML profiles. * Configuration example that condenses multiple QoS examples. Multiple configurations allowed through argument parsing. * Custom payload pool example that uses a user-defined payload pool instead of the default * X-Types example with dynamic type discovery and Hello world example compatibility. From d89c448aad7274319007a9f98e7f7bffd32ffb44 Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Tue, 2 Jul 2024 14:35:19 +0200 Subject: [PATCH 05/12] Refs #21266: Update fastdds examples guards and namespaces Signed-off-by: Carlosespicur --- examples/cpp/configuration/Application.hpp | 6 +- examples/cpp/configuration/CLIParser.hpp | 6 +- examples/cpp/configuration/PublisherApp.cpp | 5 +- examples/cpp/configuration/PublisherApp.hpp | 8 +- examples/cpp/configuration/SubscriberApp.cpp | 3 +- examples/cpp/configuration/SubscriberApp.hpp | 8 +- examples/cpp/content_filter/Application.hpp | 6 +- examples/cpp/content_filter/CLIParser.hpp | 6 +- .../content_filter/CustomContentFilter.hpp | 6 +- .../CustomContentFilterFactory.hpp | 6 +- examples/cpp/content_filter/PublisherApp.cpp | 4 +- examples/cpp/content_filter/PublisherApp.hpp | 8 +- examples/cpp/content_filter/SubscriberApp.cpp | 4 +- examples/cpp/content_filter/SubscriberApp.hpp | 8 +- .../cpp/custom_payload_pool/Application.hpp | 6 +- .../cpp/custom_payload_pool/CLIParser.hpp | 6 +- .../custom_payload_pool/CustomPayloadPool.hpp | 6 +- .../cpp/custom_payload_pool/PublisherApp.cpp | 5 +- .../cpp/custom_payload_pool/PublisherApp.hpp | 8 +- .../cpp/custom_payload_pool/SubscriberApp.cpp | 5 +- .../cpp/custom_payload_pool/SubscriberApp.hpp | 8 +- .../DiscoveryServerPublisher.h | 127 ++++++ .../DiscoveryServerServer.h | 107 +++++ .../DiscoveryServerSubscriber.h | 141 +++++++ .../arg_configuration.h | 382 ++++++++++++++++++ .../HelloWorldPublisher.cpp | 4 +- .../HelloWorldPublisher.h | 7 +- .../HelloWorldSubscriber.cpp | 5 +- .../HelloWorldSubscriber.h | 6 +- .../HelloWorld_main.cpp | 4 +- .../HelloWorldPublisher.cpp | 5 +- .../HelloWorldPublisher.h | 9 +- .../HelloWorldSubscriber.cpp | 5 +- .../HelloWorldSubscriber.h | 8 +- .../HelloWorldPublisher.cpp | 5 +- .../HelloWorldPublisher.h | 8 +- .../HelloWorldSubscriber.cpp | 4 +- .../HelloWorldSubscriber.h | 8 +- .../HelloWorldPublisher.cpp | 6 +- .../HelloWorldPublisher.h | 8 +- .../HelloWorldSubscriber.cpp | 4 +- .../HelloWorldSubscriber.h | 8 +- .../RequestReplyExample/CalculatorClient.cpp | 4 +- .../RequestReplyExample/CalculatorServer.cpp | 4 +- .../HelloWorldPublisher.cpp | 5 +- .../HelloWorldPublisher.h | 8 +- .../HelloWorldSubscriber.cpp | 5 +- .../HelloWorldSubscriber.h | 8 +- .../LoanableHelloWorldPublisher.cxx | 9 +- .../LoanableHelloWorldPublisher.h | 6 +- .../LoanableHelloWorldSubscriber.h | 6 +- .../LoanableHelloWorldPublisher.cxx | 9 +- .../LoanableHelloWorldPublisher.h | 6 +- .../LoanableHelloWorldSubscriber.h | 6 +- .../cpp/delivery_mechanisms/Application.hpp | 6 +- .../cpp/delivery_mechanisms/CLIParser.hpp | 6 +- .../cpp/delivery_mechanisms/PubSubApp.hpp | 6 +- .../cpp/delivery_mechanisms/PublisherApp.cpp | 6 +- .../cpp/delivery_mechanisms/PublisherApp.hpp | 6 +- .../cpp/delivery_mechanisms/SubscriberApp.hpp | 6 +- .../discovery_server/ClientPublisherApp.cpp | 5 + .../discovery_server/ClientSubscriberApp.cpp | 3 + examples/cpp/discovery_server/Helpers.hpp | 6 +- examples/cpp/discovery_server/ServerApp.cpp | 5 + examples/cpp/hello_world/Application.cpp | 2 +- examples/cpp/hello_world/Application.hpp | 6 +- examples/cpp/hello_world/CLIParser.hpp | 6 +- .../cpp/hello_world/ListenerSubscriberApp.hpp | 8 +- examples/cpp/hello_world/PublisherApp.cpp | 2 + examples/cpp/hello_world/PublisherApp.hpp | 8 +- .../cpp/hello_world/WaitsetSubscriberApp.cpp | 4 +- .../cpp/hello_world/WaitsetSubscriberApp.hpp | 10 +- examples/cpp/rtps/AsSocket/TestReaderSocket.h | 6 +- examples/cpp/rtps/AsSocket/TestWriterSocket.h | 6 +- .../rtps/Persistent/TestReaderPersistent.h | 6 +- .../rtps/Persistent/TestWriterPersistent.h | 6 +- .../rtps/Registered/TestReaderRegistered.h | 6 +- .../rtps/Registered/TestWriterRegistered.h | 6 +- examples/cpp/xtypes/Application.hpp | 6 +- examples/cpp/xtypes/CLIParser.hpp | 6 +- examples/cpp/xtypes/PublisherApp.hpp | 6 +- examples/cpp/xtypes/SubscriberApp.hpp | 6 +- 82 files changed, 998 insertions(+), 228 deletions(-) create mode 100644 examples/cpp/dds/DiscoveryServerExample/DiscoveryServerPublisher.h create mode 100644 examples/cpp/dds/DiscoveryServerExample/DiscoveryServerServer.h create mode 100644 examples/cpp/dds/DiscoveryServerExample/DiscoveryServerSubscriber.h create mode 100644 examples/cpp/dds/DiscoveryServerExample/arg_configuration.h diff --git a/examples/cpp/configuration/Application.hpp b/examples/cpp/configuration/Application.hpp index 67e2359d1c0..34679fd3dda 100644 --- a/examples/cpp/configuration/Application.hpp +++ b/examples/cpp/configuration/Application.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_CONFIGURATION_APPLICATION_HPP_ -#define _FASTDDS_CONFIGURATION_APPLICATION_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CONFIGURATION__APPLICATION_HPP +#define FASTDDS_EXAMPLES_CPP_CONFIGURATION__APPLICATION_HPP #include @@ -52,4 +52,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_CONFIGURATION_APPLICATION_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_CONFIGURATION__APPLICATION_HPP */ diff --git a/examples/cpp/configuration/CLIParser.hpp b/examples/cpp/configuration/CLIParser.hpp index a88d9999a89..4fe1fa61f40 100644 --- a/examples/cpp/configuration/CLIParser.hpp +++ b/examples/cpp/configuration/CLIParser.hpp @@ -21,8 +21,8 @@ #include #include -#ifndef _FASTDDS_CONFIGURATION_CLI_PARSER_HPP_ -#define _FASTDDS_CONFIGURATION_CLI_PARSER_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CONFIGURATION__CLI_PARSER_HPP +#define FASTDDS_EXAMPLES_CPP_CONFIGURATION__CLI_PARSER_HPP namespace eprosima { namespace fastdds { @@ -1137,4 +1137,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // _FASTDDS_CONFIGURATION_CLI_PARSER_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_CONFIGURATION__CLI_PARSER_HPP diff --git a/examples/cpp/configuration/PublisherApp.cpp b/examples/cpp/configuration/PublisherApp.cpp index b5b3c7504a1..f8f7c7bb1de 100644 --- a/examples/cpp/configuration/PublisherApp.cpp +++ b/examples/cpp/configuration/PublisherApp.cpp @@ -17,8 +17,6 @@ * */ -#include "PublisherApp.hpp" - #include #include #include @@ -35,6 +33,9 @@ #include #include +#include "ConfigurationPubSubTypes.hpp" +#include "PublisherApp.hpp" + using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/configuration/PublisherApp.hpp b/examples/cpp/configuration/PublisherApp.hpp index f7ab086e59f..8e2d520cbbd 100644 --- a/examples/cpp/configuration/PublisherApp.hpp +++ b/examples/cpp/configuration/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_CONFIGURATION_PUBLISHER_APP_HPP_ -#define _FASTDDS_CONFIGURATION_PUBLISHER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CONFIGURATION__PUBLISHER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_CONFIGURATION__PUBLISHER_APP_HPP #include @@ -29,7 +29,7 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "ConfigurationPubSubTypes.hpp" +#include "Configuration.hpp" using namespace eprosima::fastdds::dds; @@ -118,4 +118,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_CONFIGURATION_PUBLISHER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_CONFIGURATION__PUBLISHER_APP_HPP */ diff --git a/examples/cpp/configuration/SubscriberApp.cpp b/examples/cpp/configuration/SubscriberApp.cpp index 9bf1347b4af..353f29e87ed 100644 --- a/examples/cpp/configuration/SubscriberApp.cpp +++ b/examples/cpp/configuration/SubscriberApp.cpp @@ -17,8 +17,6 @@ * */ -#include "SubscriberApp.hpp" - #include #include @@ -36,6 +34,7 @@ #include "Application.hpp" #include "CLIParser.hpp" #include "ConfigurationPubSubTypes.hpp" +#include "SubscriberApp.hpp" using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/configuration/SubscriberApp.hpp b/examples/cpp/configuration/SubscriberApp.hpp index e2bbfd049ca..3951e2addf9 100644 --- a/examples/cpp/configuration/SubscriberApp.hpp +++ b/examples/cpp/configuration/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_CONFIGURATION_SUBSCRIBER_APP_HPP_ -#define _FASTDDS_CONFIGURATION_SUBSCRIBER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CONFIGURATION__SUBSCRIBER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_CONFIGURATION__SUBSCRIBER_APP_HPP #include #include @@ -32,7 +32,7 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "ConfigurationPubSubTypes.hpp" +#include "Configuration.hpp" using namespace eprosima::fastdds::dds; @@ -123,4 +123,4 @@ class SubscriberApp : public Application, public DataReaderListener } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_CONFIGURATION_SUBSCRIBER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_CONFIGURATION__SUBSCRIBER_APP_HPP */ diff --git a/examples/cpp/content_filter/Application.hpp b/examples/cpp/content_filter/Application.hpp index ea70fb8766a..d457ffa013a 100644 --- a/examples/cpp/content_filter/Application.hpp +++ b/examples/cpp/content_filter/Application.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_CONTENT_FILTER_APPLICATION_HPP_ -#define _FASTDDS_CONTENT_FILTER_APPLICATION_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__APPLICATION_HPP +#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__APPLICATION_HPP #include @@ -53,4 +53,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_CONTEN_FILTER_APPLICATION_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__APPLICATION_HPP */ diff --git a/examples/cpp/content_filter/CLIParser.hpp b/examples/cpp/content_filter/CLIParser.hpp index 9e483a3ba20..7d3845fd4c3 100644 --- a/examples/cpp/content_filter/CLIParser.hpp +++ b/examples/cpp/content_filter/CLIParser.hpp @@ -19,8 +19,8 @@ #include -#ifndef _FASTDDS_CONTENT_FILTER_CLI_PARSER_HPP_ -#define _FASTDDS_CONTENT_FILTER_CLI_PARSER_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CLI_PARSER_HPP +#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CLI_PARSER_HPP namespace eprosima { namespace fastdds { @@ -465,4 +465,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // _FASTDDS_CONTENT_FILTER_CLI_PARSER_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CLI_PARSER_HPP diff --git a/examples/cpp/content_filter/CustomContentFilter.hpp b/examples/cpp/content_filter/CustomContentFilter.hpp index 69ac5f49af6..661459ab9f2 100644 --- a/examples/cpp/content_filter/CustomContentFilter.hpp +++ b/examples/cpp/content_filter/CustomContentFilter.hpp @@ -1,5 +1,5 @@ -#ifndef _FASTDDS_CONTENT_FILTER_CUSTOM_FILTER_HPP_ -#define _FASTDDS_CONTENT_FILTER_CUSTOM_FILTER_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOM_CONTENT_FILTER_HPP +#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOM_CONTENT_FILTER_HPP #include @@ -78,4 +78,4 @@ class CustomContentFilter : public eprosima::fastdds::dds::IContentFilter }; -#endif // _FASTDDS_CONTENT_FILTER_CUSTOM_FILTER_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOM_CONTENT_FILTER_HPP diff --git a/examples/cpp/content_filter/CustomContentFilterFactory.hpp b/examples/cpp/content_filter/CustomContentFilterFactory.hpp index ea65f1394e5..1ad1ffb13b5 100644 --- a/examples/cpp/content_filter/CustomContentFilterFactory.hpp +++ b/examples/cpp/content_filter/CustomContentFilterFactory.hpp @@ -1,5 +1,5 @@ -#ifndef _FASTDDS_CONTENT_FILTER_CUSTOM_FILTER_FACTORY_HPP_ -#define _FASTDDS_CONTENT_FILTER_CUSTOM_FILTER_FACTORY_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOM_CONTENT_FILTER_FACTORY_HPP +#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOM_CONTENT_FILTER_FACTORY_HPP #include #include @@ -88,4 +88,4 @@ class CustomContentFilterFactory : public eprosima::fastdds::dds::IContentFilter } }; -#endif // _FASTDDS_CONTENT_FILTER_CUSTOM_FILTER_FACTORY_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOM_CONTENT_FILTER_FACTORY_HPP diff --git a/examples/cpp/content_filter/PublisherApp.cpp b/examples/cpp/content_filter/PublisherApp.cpp index c80d9d98f1e..536518296c2 100644 --- a/examples/cpp/content_filter/PublisherApp.cpp +++ b/examples/cpp/content_filter/PublisherApp.cpp @@ -17,8 +17,6 @@ * */ -#include "PublisherApp.hpp" - #include #include @@ -31,7 +29,9 @@ #include #include +#include "HelloWorldPubSubTypes.hpp" #include "HelloWorldTypeObjectSupport.hpp" +#include "PublisherApp.hpp" namespace eprosima { namespace fastdds { diff --git a/examples/cpp/content_filter/PublisherApp.hpp b/examples/cpp/content_filter/PublisherApp.hpp index 614c978f26e..c2cf1ccab2b 100644 --- a/examples/cpp/content_filter/PublisherApp.hpp +++ b/examples/cpp/content_filter/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_CONTENT_FILTER_PUBLISHER_APP_HPP_ -#define _FASTDDS_CONTENT_FILTER_PUBLISHER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__PUBLISHER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__PUBLISHER_APP_HPP #include @@ -28,7 +28,7 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.hpp" +#include "HelloWorld.hpp" using namespace eprosima::fastdds::dds; @@ -95,4 +95,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif // _FASTDDS_CONTENT_FILTER_PUBLISHER_APP_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__PUBLISHER_APP_HPP diff --git a/examples/cpp/content_filter/SubscriberApp.cpp b/examples/cpp/content_filter/SubscriberApp.cpp index d61b43c3e63..bbfc7300d4e 100644 --- a/examples/cpp/content_filter/SubscriberApp.cpp +++ b/examples/cpp/content_filter/SubscriberApp.cpp @@ -17,8 +17,6 @@ * */ -#include "SubscriberApp.hpp" - #include #include @@ -31,7 +29,9 @@ #include #include +#include "HelloWorldPubSubTypes.hpp" #include "HelloWorldTypeObjectSupport.hpp" +#include "SubscriberApp.hpp" namespace eprosima { namespace fastdds { diff --git a/examples/cpp/content_filter/SubscriberApp.hpp b/examples/cpp/content_filter/SubscriberApp.hpp index b2a240700f6..ccbf3e5c32f 100644 --- a/examples/cpp/content_filter/SubscriberApp.hpp +++ b/examples/cpp/content_filter/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_CONTENT_FILTER_SUBSCRIBER_APP_HPP_ -#define _FASTDDS_CONTENT_FILTER_SUBSCRIBER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__SUBSCRIBER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__SUBSCRIBER_APP_HPP #include #include @@ -35,8 +35,8 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.hpp" #include "CustomContentFilterFactory.hpp" +#include "HelloWorld.hpp" using namespace eprosima::fastdds::dds; namespace eprosima { @@ -107,4 +107,4 @@ class SubscriberApp : public Application, public DataReaderListener } // namespace fastdds } // namespace eprosima -#endif // _FASTDDS_CONTENT_FILTER_SUBSCRIBER_APP_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__SUBSCRIBER_APP_HPP diff --git a/examples/cpp/custom_payload_pool/Application.hpp b/examples/cpp/custom_payload_pool/Application.hpp index 3a78297c964..55c3bf60a3d 100644 --- a/examples/cpp/custom_payload_pool/Application.hpp +++ b/examples/cpp/custom_payload_pool/Application.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_CUSTOM_PAYLOAD_POOL_APPLICATION_HPP_ -#define _FASTDDS_CUSTOM_PAYLOAD_POOL_APPLICATION_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__APPLICATION_HPP +#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__APPLICATION_HPP #include @@ -53,4 +53,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_CUSTOM_PAYLOAD_POOL_APPLICATION_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__APPLICATION_HPP */ diff --git a/examples/cpp/custom_payload_pool/CLIParser.hpp b/examples/cpp/custom_payload_pool/CLIParser.hpp index 42c81d781e5..b0aea0c03e8 100644 --- a/examples/cpp/custom_payload_pool/CLIParser.hpp +++ b/examples/cpp/custom_payload_pool/CLIParser.hpp @@ -18,8 +18,8 @@ #include -#ifndef _FASTDDS_CUSTOM_PAYLOAD_POOL_CLI_PARSER_HPP_ -#define _FASTDDS_CUSTOM_PAYLOAD_POOL_CLI_PARSER_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CLI_PARSER_HPP +#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CLI_PARSER_HPP namespace eprosima { namespace fastdds { @@ -329,4 +329,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // _FASTDDS_CUSTOM_PAYLOAD_POOL_CLI_PARSER_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CLI_PARSER_HPP diff --git a/examples/cpp/custom_payload_pool/CustomPayloadPool.hpp b/examples/cpp/custom_payload_pool/CustomPayloadPool.hpp index 221c0eb4b00..3c1457ea599 100644 --- a/examples/cpp/custom_payload_pool/CustomPayloadPool.hpp +++ b/examples/cpp/custom_payload_pool/CustomPayloadPool.hpp @@ -16,8 +16,8 @@ * @file CustomPayloadPool.hpp */ -#ifndef _FASTDDS_CUSTOM_PAYLOAD_POOL_HPP_ -#define _FASTDDS_CUSTOM_PAYLOAD_POOL_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CUSTOM_PAYLOAD_POOL_HPP +#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CUSTOM_PAYLOAD_POOL_HPP #include #include @@ -97,4 +97,4 @@ class CustomPayloadPool : public eprosima::fastdds::rtps::IPayloadPool }; -#endif // _FASTDDS_CUSTOM_PAYLOAD_POOL_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CUSTOM_PAYLOAD_POOL_HPP diff --git a/examples/cpp/custom_payload_pool/PublisherApp.cpp b/examples/cpp/custom_payload_pool/PublisherApp.cpp index 69c0b21aa65..0b82b9ddc87 100644 --- a/examples/cpp/custom_payload_pool/PublisherApp.cpp +++ b/examples/cpp/custom_payload_pool/PublisherApp.cpp @@ -17,8 +17,6 @@ * */ -#include "PublisherApp.hpp" - #include #include @@ -28,6 +26,9 @@ #include #include +#include "HelloWorldPubSubTypes.hpp" +#include "PublisherApp.hpp" + using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/custom_payload_pool/PublisherApp.hpp b/examples/cpp/custom_payload_pool/PublisherApp.hpp index 8c57893c643..ff113eb7b15 100644 --- a/examples/cpp/custom_payload_pool/PublisherApp.hpp +++ b/examples/cpp/custom_payload_pool/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_CUSTOM_PAYLOAD_POOL_PUBLISHER_HPP_ -#define _FASTDDS_CUSTOM_PAYLOAD_POOL_PUBLISHER_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__PUBLISHER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__PUBLISHER_APP_HPP #include #include @@ -30,7 +30,7 @@ #include "Application.hpp" #include "CLIParser.hpp" #include "CustomPayloadPool.hpp" -#include "HelloWorldPubSubTypes.hpp" +#include "HelloWorld.hpp" using namespace eprosima::fastdds::dds; @@ -103,4 +103,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_CUSTOM_PAYLOAD_POOL_PUBLISHER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__PUBLISHER_APP_HPP */ diff --git a/examples/cpp/custom_payload_pool/SubscriberApp.cpp b/examples/cpp/custom_payload_pool/SubscriberApp.cpp index 9bd398cffc8..7ac4600d1c2 100644 --- a/examples/cpp/custom_payload_pool/SubscriberApp.cpp +++ b/examples/cpp/custom_payload_pool/SubscriberApp.cpp @@ -17,8 +17,6 @@ * */ -#include "SubscriberApp.hpp" - #include #include @@ -30,6 +28,9 @@ #include #include +#include "HelloWorldPubSubTypes.hpp" +#include "SubscriberApp.hpp" + using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { diff --git a/examples/cpp/custom_payload_pool/SubscriberApp.hpp b/examples/cpp/custom_payload_pool/SubscriberApp.hpp index f83483b9089..1b7cfb05946 100644 --- a/examples/cpp/custom_payload_pool/SubscriberApp.hpp +++ b/examples/cpp/custom_payload_pool/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_CUSTOM_PAYLOAD_POOL_SUBSCRIBER_HPP_ -#define _FASTDDS_CUSTOM_PAYLOAD_POOL_SUBSCRIBER_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__SUBSCRIBER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__SUBSCRIBER_APP_HPP #include #include @@ -31,7 +31,7 @@ #include "Application.hpp" #include "CLIParser.hpp" #include "CustomPayloadPool.hpp" -#include "HelloWorldPubSubTypes.hpp" +#include "HelloWorld.hpp" using namespace eprosima::fastdds::dds; namespace eprosima { @@ -101,4 +101,4 @@ class SubscriberApp : public Application, public DataReaderListener } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_CUSTOM_PAYLOAD_POOL_SUBSCRIBER_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__SUBSCRIBER_APP_HPP */ diff --git a/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerPublisher.h b/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerPublisher.h new file mode 100644 index 00000000000..2a53c12d38a --- /dev/null +++ b/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerPublisher.h @@ -0,0 +1,127 @@ +// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DiscoveryServerPublisher.h + * + */ + +#ifndef FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_PUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_PUBLISHER_H + +#include + +#include +#include +#include + +#include "common.h" +#include "types/HelloWorld.hpp" + +/** + * Class used to group into a single working unit a Publisher with a DataWriter, its listener, and a TypeSupport member + * corresponding to the HelloWorld datatype + */ +class HelloWorldPublisher +{ +public: + + HelloWorldPublisher(); + + virtual ~HelloWorldPublisher(); + + //! Initialize the publisher + bool init( + const std::string& topic_name, + const std::string& server_address, + unsigned short server_port, + unsigned short server_id, + TransportKind transport); + + //! Publish a sample + void publish(); + + //! Run for number samples, publish every sleep seconds + void run( + uint32_t number, + uint32_t sleep); + + //! Return the current state of execution + static bool is_stopped(); + + //! Trigger the end of execution + static void stop(); + +private: + + HelloWorld hello_; + + eprosima::fastdds::dds::DomainParticipant* participant_; + + eprosima::fastdds::dds::Publisher* publisher_; + + eprosima::fastdds::dds::Topic* topic_; + + eprosima::fastdds::dds::DataWriter* writer_; + + eprosima::fastdds::dds::TypeSupport type_; + + /** + * Class handling discovery events + */ + class PubListener : public eprosima::fastdds::dds::DomainParticipantListener + { + public: + + PubListener() + : matched_(0) + { + } + + ~PubListener() override + { + } + + //! Callback executed when a DataReader is matched or unmatched + void on_publication_matched( + eprosima::fastdds::dds::DataWriter* writer, + const eprosima::fastdds::dds::PublicationMatchedStatus& info) override; + + //! Callback executed when a DomainParticipant is discovered, dropped or removed + void on_participant_discovery( + eprosima::fastdds::dds::DomainParticipant* /*participant*/, + eprosima::fastdds::rtps::ParticipantDiscoveryInfo&& info, + bool& should_be_ignored) override; + + private: + + using eprosima::fastdds::dds::DomainParticipantListener::on_participant_discovery; + + //! Number of DataReaders matched to the associated DataWriter + std::atomic matched_; + } + listener_; + + //! Run thread for number samples, publish every sleep seconds + void runThread( + uint32_t number, + uint32_t sleep); + + //! Member used for control flow purposes + static std::atomic stop_; +}; + + + +#endif /* FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_PUBLISHER_H */ diff --git a/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerServer.h b/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerServer.h new file mode 100644 index 00000000000..ee59c2d0a5e --- /dev/null +++ b/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerServer.h @@ -0,0 +1,107 @@ +// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DiscoveryServerServer.h + * + */ + +#ifndef FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_SERVER_H +#define FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_SERVER_H + +#include +#include +#include + +#include +#include + +#include "common.h" + +/** + * Class with a partipant configured to function as server in the Discovery Server mechanism + */ +class DiscoveryServer +{ +public: + + DiscoveryServer(); + + virtual ~DiscoveryServer(); + + //! Initialize the server + bool init( + const std::string& server_address, + unsigned short server_port, + unsigned short server_id, + TransportKind transport, + bool has_connection_server, + const std::string& connection_server_address, + unsigned short connection_server_port, + unsigned short connection_server_id); + + //! Run + void run( + unsigned int timeout); + + //! Return the current state of execution + static bool is_stopped(); + + //! Trigger the end of execution + static void stop(); + +private: + + eprosima::fastdds::dds::DomainParticipant* participant_; + + /** + * Class handling discovery events + */ + class ServerListener : public eprosima::fastdds::dds::DomainParticipantListener + { + public: + + ServerListener() + { + } + + ~ServerListener() override + { + } + + //! Callback executed when a DomainParticipant is discovered, dropped or removed + void on_participant_discovery( + eprosima::fastdds::dds::DomainParticipant* /*participant*/, + eprosima::fastdds::rtps::ParticipantDiscoveryInfo&& info, + bool& should_be_ignored) override; + + private: + + using eprosima::fastdds::dds::DomainParticipantListener::on_participant_discovery; + } + listener_; + + //! Member used for control flow purposes + static std::atomic stop_; + + //! Protects terminate condition variable + static std::mutex terminate_cv_mtx_; + + //! Waits during execution until SIGINT or max_messages_ samples are received + static std::condition_variable terminate_cv_; +}; + + + +#endif /* FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_SERVER_H */ diff --git a/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerSubscriber.h b/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerSubscriber.h new file mode 100644 index 00000000000..071249e7e66 --- /dev/null +++ b/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerSubscriber.h @@ -0,0 +1,141 @@ +// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DiscoveryServerSubscriber.h + * + */ + +#ifndef FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_SUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_SUBSCRIBER_H + +#include +#include +#include + +#include +#include +#include + +#include "common.h" +#include "types/HelloWorld.hpp" + +/** + * Class used to group into a single working unit a Subscriber with a DataReader, its listener, and a TypeSupport member + * corresponding to the HelloWorld datatype + */ +class HelloWorldSubscriber +{ +public: + + HelloWorldSubscriber(); + + virtual ~HelloWorldSubscriber(); + + //! Initialize the subscriber + bool init( + const std::string& topic_name, + uint32_t max_messages, + const std::string& server_address, + unsigned short server_port, + unsigned short server_id, + TransportKind transport); + + //! RUN the subscriber until number samples are received + void run( + uint32_t number); + + //! Return the current state of execution + static bool is_stopped(); + + //! Trigger the end of execution + static void stop(); + +private: + + eprosima::fastdds::dds::DomainParticipant* participant_; + + eprosima::fastdds::dds::Subscriber* subscriber_; + + eprosima::fastdds::dds::Topic* topic_; + + eprosima::fastdds::dds::DataReader* reader_; + + eprosima::fastdds::dds::TypeSupport type_; + + /** + * Class handling discovery and dataflow events + */ + class SubListener : public eprosima::fastdds::dds::DomainParticipantListener + { + public: + + SubListener() + : matched_(0) + , samples_(0) + , max_messages_(0) + { + } + + ~SubListener() override + { + } + + //! Set the maximum number of messages to receive before exiting + void set_max_messages( + uint32_t max_messages); + + //! Callback executed when a new sample is received + void on_data_available( + eprosima::fastdds::dds::DataReader* reader) override; + + //! Callback executed when a DataWriter is matched or unmatched + void on_subscription_matched( + eprosima::fastdds::dds::DataReader* reader, + const eprosima::fastdds::dds::SubscriptionMatchedStatus& info) override; + + //! Callback executed when a DomainParticipant is discovered, dropped or removed + void on_participant_discovery( + eprosima::fastdds::dds::DomainParticipant* /*participant*/, + eprosima::fastdds::rtps::ParticipantDiscoveryInfo&& info, + bool& should_be_ignored) override; + + private: + + using eprosima::fastdds::dds::DomainParticipantListener::on_participant_discovery; + + HelloWorld hello_; + + //! Number of DataWriters matched to the associated DataReader + int matched_; + + //! Number of samples received + uint32_t samples_; + + //! Number of messages to be received before triggering termination of execution + uint32_t max_messages_; + } + listener_; + + //! Member used for control flow purposes + static std::atomic stop_; + + //! Protects terminate condition variable + static std::mutex terminate_cv_mtx_; + + //! Waits during execution until SIGINT or max_messages_ samples are received + static std::condition_variable terminate_cv_; +}; + +#endif /* FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_SUBSCRIBER_H */ diff --git a/examples/cpp/dds/DiscoveryServerExample/arg_configuration.h b/examples/cpp/dds/DiscoveryServerExample/arg_configuration.h new file mode 100644 index 00000000000..6d8b43b10b8 --- /dev/null +++ b/examples/cpp/dds/DiscoveryServerExample/arg_configuration.h @@ -0,0 +1,382 @@ +// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file arg_configuration.h + * + */ + +#ifndef FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__ARG_CONFIGURATION_H +#define FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__ARG_CONFIGURATION_H + +#include +#include +#include + +#include +#include + +#include "common.h" + +namespace option = eprosima::option; + +const std::regex IPv4_REGEX(R"(^((?:[0-9]{1,3}\.){3}[0-9]{1,3})?:?(?:(\d+))?$)"); + +struct Arg : public option::Arg +{ + static void print_error( + const char* msg1, + const option::Option& opt, + const char* msg2) + { + fprintf(stderr, "%s", msg1); + fwrite(opt.name, opt.namelen, 1, stderr); + fprintf(stderr, "%s", msg2); + } + + static option::ArgStatus Unknown( + const option::Option& option, + bool msg) + { + if (msg) + { + print_error("Unknown option '", option, "'\n"); + } + return option::ARG_ILLEGAL; + } + + static option::ArgStatus Required( + const option::Option& option, + bool msg) + { + if (option.arg != 0 && option.arg[0] != 0) + { + return option::ARG_OK; + } + + if (msg) + { + print_error("Option '", option, "' requires an argument\n"); + } + return option::ARG_ILLEGAL; + } + + static option::ArgStatus Numeric( + const option::Option& option, + bool msg) + { + char* endptr = 0; + if (option.arg != 0 && strtol(option.arg, &endptr, 10)) + { + } + if (endptr != option.arg && *endptr == 0) + { + return option::ARG_OK; + } + + if (msg) + { + print_error("Option '", option, "' requires a numeric argument\n"); + } + return option::ARG_ILLEGAL; + } + + static option::ArgStatus String( + const option::Option& option, + bool msg) + { + if (option.arg != 0) + { + return option::ARG_OK; + } + if (msg) + { + print_error("Option '", option, "' requires a string argument\n"); + } + return option::ARG_ILLEGAL; + } + + static option::ArgStatus Locator( + const option::Option& option, + bool msg) + { + if (option.arg != 0) + { + // we must check if it is a correct ip address plus port number + std::string ip_str(option.arg); + if ( + eprosima::fastdds::rtps::IPLocator::isIPv4(ip_str) || + eprosima::fastdds::rtps::IPLocator::isIPv6(ip_str)) + { + return option::ARG_OK; + } + } + if (msg) + { + print_error("Option '", option, "' requires an v4 or v6 argument\n"); + } + return option::ARG_ILLEGAL; + } + + static option::ArgStatus Transport( + const option::Option& option, + bool msg) + { + if (option.arg != 0) + { + // we must check if it is a correct ip address plus port number + std::string transport = std::string(option.arg); + if ( + // transport == "shm" || + transport == "udpv4" || + transport == "udpv6" || + transport == "tcpv4" || + transport == "tcpv6" + ) + { + return option::ARG_OK; + } + } + if (msg) + { + print_error("Option '", option, "' requires a string argument\n"); + } + return option::ARG_ILLEGAL; + } + +}; + +enum optionIndex +{ + UNKNOWN_OPT, + HELP, + + TOPIC, + SAMPLES, + INTERVAL, + TRANSPORT, + + CONNECTION_ADDRESS, + CONNECTION_PORT, + CONNECTION_DISCOVERY_SERVER_ID, + + LISTENING_ADDRESS, + LISTENING_PORT, + LISTENING_DISCOVERY_SERVER_ID, + TIMEOUT, +}; + +const option::Descriptor usage[] = { + {UNKNOWN_OPT, 0, "", "", Arg::None, + "Usage: DiscoveryServerExample \n\nGeneral options:" }, + { + HELP, + 0, + "h", + "help", + Arg::None, + " -h \t--help \tProduce help message." + }, + + /// PUBLISHER OPTIONS + {UNKNOWN_OPT, 0, "", "", Arg::None, "\nPublisher options:"}, + { + TOPIC, + 0, + "t", + "topic", + Arg::String, + " -t \t--topic= \tTopic name (Default: HelloWorldTopic)." + }, + { + SAMPLES, + 0, + "s", + "samples", + Arg::Numeric, + " -s \t--samples= \tNumber of samples to send (Default: 0 => infinite samples)." + }, + { + INTERVAL, + 0, + "i", + "interval", + Arg::Numeric, + " -i \t--interval= \tTime between samples in milliseconds (Default: 100)." + }, + { + CONNECTION_ADDRESS, + 0, + "c", + "connection-address", + Arg::String, + " -c \t--connection-address= \tServer address (Default address: 127.0.0.1)." + }, + { + CONNECTION_PORT, + 0, + "p", + "connection-port", + Arg::Numeric, + " -p \t--connection-port= \tServer listening port (Default port: 16166)." + }, + { + TRANSPORT, + 0, + "", + "transport", + Arg::Transport, + " \t--transport \tUse Transport Protocol [udpv4|udpv6|tcpv4|tcpv6] (UDPv4 by default)." + }, + { + CONNECTION_DISCOVERY_SERVER_ID, + 0, + "d", + "discovery-server-id", + Arg::Numeric, + " -d \t--connection-discovery-server-id \tId of the Discovery Server to connect with. " + "GUID will be calculated from id (0 by default)." + }, + + /// SUBSCRIBER OPTIONS + {UNKNOWN_OPT, 0, "", "", Arg::None, "\nSubscriber options:"}, + { + TOPIC, + 0, + "t", + "topic", + Arg::String, + " -t \t--topic= \tTopic name (Default: HelloWorldTopic)." + }, + { + SAMPLES, + 0, + "s", + "samples", + Arg::Numeric, + " -s \t--samples= \tNumber of samples to send (Default: 0 => infinite samples)." + }, + { + CONNECTION_ADDRESS, + 0, + "c", + "connection-address", + Arg::String, + " -c \t--connection-address= \tServer address (Default address: 127.0.0.1)." + }, + { + CONNECTION_PORT, + 0, + "p", + "connection-port", + Arg::Numeric, + " -p \t--connection-port= \tServer listening port (Default port: 16166)." + }, + { + TRANSPORT, + 0, + "", + "transport", + Arg::Transport, + " \t--transport \tUse Transport Protocol [udpv4|udpv6|tcpv4|tcpv6] (UDPv4 by default)." + }, + { + CONNECTION_DISCOVERY_SERVER_ID, + 0, + "d", + "discovery-server-id", + Arg::Numeric, + " -d \t--connection-discovery-server-id \tId of the Discovery Server to connect with. " + "GUID will be calculated from id (0 by default)." + }, + + /// SERVER OPTIONS + {UNKNOWN_OPT, 0, "", "", Arg::None, "\nDiscovery Server options:"}, + { + LISTENING_ADDRESS, + 0, + "", + "listening-address", + Arg::String, + " \t--listening-address= \tServer address (Default address: 127.0.0.1)." + }, + { + LISTENING_DISCOVERY_SERVER_ID, + 0, + "", + "id", + Arg::Numeric, + " \t--id \tId of this Discovery Server. GUID will be calculated from id (0 by default)." + }, + { + LISTENING_PORT, + 0, + "", + "listening-port", + Arg::Numeric, + " \t--listening-port= \tServer listening port (Default port: 16166)." + }, + { + TRANSPORT, + 0, + "", + "transport", + Arg::Transport, + " \t--transport \tUse Transport Protocol [udpv4|udpv6|tcpv4|tcpv6] (UDPv4 by default)." + }, + { + CONNECTION_PORT, + 0, + "p", + "connection-port", + Arg::Numeric, + " -p \t--connection-port= \tServer listening port (Default port: 16166)." + }, + { + CONNECTION_ADDRESS, + 0, + "c", + "connection-address", + Arg::String, + " -c \t--connection-address= \tServer address (Default address: 127.0.0.1)." + }, + { + CONNECTION_DISCOVERY_SERVER_ID, + 0, + "d", + "connection-discovery-server-id", + Arg::Numeric, + " -d \t--connection-discovery-server-id \tId of the Discovery Server to connect with. " + "GUID will be calculated from id (if not set, this DS will not connect to other server)." + }, + { + TIMEOUT, + 0, + "z", + "timeout", + Arg::Numeric, + " -z \t--timeout \tNumber of seconds before finish the process (Default: 0 = till ^C). " + }, + + { 0, 0, 0, 0, 0, 0 } +}; + +void print_warning( + std::string type, + const char* opt) +{ + std::cerr << "WARNING: " << opt << " is a " << type << " option, ignoring argument." << std::endl; +} + +#endif /* FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__ARG_CONFIGURATION_H */ diff --git a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp index c91b27a4c30..49b6ecee547 100644 --- a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp +++ b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp @@ -17,8 +17,6 @@ * */ -#include "HelloWorldPublisher.h" - #include #include @@ -29,6 +27,8 @@ #include #include +#include "HelloWorldPublisher.h" + using namespace eprosima::fastdds::dds; HelloWorldPublisher::HelloWorldPublisher() diff --git a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.h b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.h index 03f734e35aa..380e8447535 100644 --- a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.h +++ b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.h @@ -17,11 +17,10 @@ * */ -#ifndef HELLOWORLDPUBLISHER_H_ -#define HELLOWORLDPUBLISHER_H_ +#ifndef FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_PUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_PUBLISHER_H #include - #include #include @@ -90,4 +89,4 @@ class HelloWorldPublisher -#endif /* HELLOWORLDPUBLISHER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_PUBLISHER_H */ diff --git a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp index f65d324a2cf..852af105bbf 100644 --- a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp +++ b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp @@ -16,9 +16,6 @@ * @file HelloWorldSubscriber.cpp * */ - -#include "HelloWorldSubscriber.h" - #include #include #include @@ -30,6 +27,8 @@ #include #include +#include "HelloWorldSubscriber.h" + using namespace eprosima::fastdds::dds; HelloWorldSubscriber::HelloWorldSubscriber() diff --git a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.h b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.h index 447d8685e9f..1dfd166341b 100644 --- a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.h +++ b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.h @@ -17,8 +17,8 @@ * */ -#ifndef HELLOWORLDSUBSCRIBER_H_ -#define HELLOWORLDSUBSCRIBER_H_ +#ifndef FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_SUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_SUBSCRIBER_H #include #include @@ -112,4 +112,4 @@ class HelloWorldSubscriber }; -#endif /* HELLOWORLDSUBSCRIBER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_SUBSCRIBER_H */ diff --git a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorld_main.cpp b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorld_main.cpp index 582908edb44..6f28f7e5d64 100644 --- a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorld_main.cpp +++ b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorld_main.cpp @@ -17,11 +17,11 @@ * */ +#include + #include "HelloWorldPublisher.h" #include "HelloWorldSubscriber.h" -#include - using eprosima::fastdds::dds::Log; int main( diff --git a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.cpp b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.cpp index 24b6a033e9e..0bf073f6bc6 100644 --- a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.cpp +++ b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.cpp @@ -17,8 +17,6 @@ * */ -#include "HelloWorldPublisher.h" - #include #include @@ -27,6 +25,9 @@ #include #include +#include "HelloWorldPublisher.h" +#include "HelloWorldPubSubTypes.hpp" + using namespace eprosima::fastdds::dds; HelloWorldPublisher::HelloWorldPublisher() diff --git a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.h b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.h index 0d2fb051fa0..b82241a34df 100644 --- a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.h +++ b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.h @@ -17,15 +17,14 @@ * */ -#ifndef HELLOWORLDPUBLISHER_H_ -#define HELLOWORLDPUBLISHER_H_ - -#include "HelloWorldPubSubTypes.hpp" +#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLO_WORLD_PUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLO_WORLD_PUBLISHER_H #include #include #include +#include "HelloWorld.hpp" class HelloWorldPublisher { public: @@ -93,4 +92,4 @@ class HelloWorldPublisher -#endif /* HELLOWORLDPUBLISHER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLO_WORLD_PUBLISHER_H */ diff --git a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.cpp b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.cpp index 690cdfdab64..358783b0df6 100644 --- a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.cpp +++ b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.cpp @@ -17,8 +17,6 @@ * */ -#include "HelloWorldSubscriber.h" - #include #include @@ -28,6 +26,9 @@ #include #include +#include "HelloWorldPubSubTypes.hpp" +#include "HelloWorldSubscriber.h" + using namespace eprosima::fastdds::dds; HelloWorldSubscriber::HelloWorldSubscriber() diff --git a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.h b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.h index 719c08a6be6..fdb05f15e11 100644 --- a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.h +++ b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.h @@ -17,15 +17,15 @@ * */ -#ifndef HELLOWORLDSUBSCRIBER_H_ -#define HELLOWORLDSUBSCRIBER_H_ +#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLO_WORLD_SUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLO_WORLD_SUBSCRIBER_H #include #include #include #include -#include "HelloWorldPubSubTypes.hpp" +#include "HelloWorld.hpp" class HelloWorldSubscriber { @@ -87,4 +87,4 @@ class HelloWorldSubscriber listener_; }; -#endif /* HELLOWORLDSUBSCRIBER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLO_WORLD_SUBSCRIBER_H */ diff --git a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.cpp b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.cpp index 3715765847f..5d7596583eb 100644 --- a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.cpp +++ b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.cpp @@ -17,13 +17,14 @@ * */ -#include "HelloWorldPublisher.h" +#include #include #include #include -#include +#include "HelloWorldPublisher.h" +#include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.h b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.h index 71a55ef8837..6d70d284f79 100644 --- a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.h +++ b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.h @@ -17,10 +17,8 @@ * */ -#ifndef HELLOWORLDPUBLISHER_H_ -#define HELLOWORLDPUBLISHER_H_ - -#include "HelloWorldPubSubTypes.hpp" +#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLO_WORLD_PUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLO_WORLD_PUBLISHER_H #include #include @@ -97,4 +95,4 @@ class HelloWorldPublisher eprosima::fastdds::dds::TypeSupport type_; }; -#endif /* HELLOWORLDPUBLISHER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLO_WORLD_PUBLISHER_H */ diff --git a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.cpp b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.cpp index ba580eb12da..b7bbfc9e92e 100644 --- a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.cpp +++ b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.cpp @@ -17,7 +17,6 @@ * */ -#include "HelloWorldSubscriber.h" #include #include @@ -27,6 +26,9 @@ #include #include +#include "HelloWorldPubSubTypes.hpp" +#include "HelloWorldSubscriber.h" + using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.h b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.h index 4dfeadd6a5e..da9b4ba2bb3 100644 --- a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.h +++ b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.h @@ -17,10 +17,8 @@ * */ -#ifndef HELLOWORLDSUBSCRIBER_H_ -#define HELLOWORLDSUBSCRIBER_H_ - -#include "HelloWorldPubSubTypes.hpp" +#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLO_WORLD_SUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLO_WORLD_SUBSCRIBER_H #include #include @@ -93,4 +91,4 @@ class HelloWorldSubscriber listener_; }; -#endif /* HELLOWORLDSUBSCRIBER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLO_WORLD_SUBSCRIBER_H */ diff --git a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.cpp b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.cpp index 315af25244a..96c5c872e49 100644 --- a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.cpp +++ b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.cpp @@ -17,12 +17,14 @@ * */ -#include "HelloWorldPublisher.h" +#include + #include #include #include -#include +#include "HelloWorldPublisher.h" +#include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.h b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.h index d719ad13b97..fc9b99469ac 100644 --- a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.h +++ b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.h @@ -17,10 +17,8 @@ * */ -#ifndef HELLOWORLDPUBLISHER_H_ -#define HELLOWORLDPUBLISHER_H_ - -#include "HelloWorldPubSubTypes.hpp" +#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLO_WORLD_PUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLO_WORLD_PUBLISHER_H #include #include @@ -102,4 +100,4 @@ class HelloWorldPublisher -#endif /* HELLOWORLDPUBLISHER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLO_WORLD_PUBLISHER_H */ diff --git a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.cpp b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.cpp index 90fbac5eab6..e04394a8e20 100644 --- a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.cpp +++ b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.cpp @@ -17,7 +17,6 @@ * */ -#include "HelloWorldSubscriber.h" #include #include @@ -27,6 +26,9 @@ #include #include +#include "HelloWorldSubscriber.h" +#include "HelloWorldPubSubTypes.hpp" + using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.h b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.h index 1d488371131..ca65e34fec6 100644 --- a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.h +++ b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.h @@ -17,10 +17,8 @@ * */ -#ifndef HELLOWORLDSUBSCRIBER_H_ -#define HELLOWORLDSUBSCRIBER_H_ - -#include "HelloWorldPubSubTypes.hpp" +#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLO_WORLD_SUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLO_WORLD_SUBSCRIBER_H #include #include @@ -95,4 +93,4 @@ class HelloWorldSubscriber uint32_t number); }; -#endif /* HELLOWORLDSUBSCRIBER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLO_WORLD_SUBSCRIBER_H */ diff --git a/examples/cpp/dds/RequestReplyExample/CalculatorClient.cpp b/examples/cpp/dds/RequestReplyExample/CalculatorClient.cpp index aaa3ca1df24..84d4334d519 100644 --- a/examples/cpp/dds/RequestReplyExample/CalculatorClient.cpp +++ b/examples/cpp/dds/RequestReplyExample/CalculatorClient.cpp @@ -16,8 +16,6 @@ #include #include -#include "CalculatorPubSubTypes.hpp" - #include #include #include @@ -27,6 +25,8 @@ #include #include +#include "CalculatorPubSubTypes.hpp" + class CalculatorClient { class Listener : public eprosima::fastdds::dds::DataReaderListener diff --git a/examples/cpp/dds/RequestReplyExample/CalculatorServer.cpp b/examples/cpp/dds/RequestReplyExample/CalculatorServer.cpp index c8ba52d1359..a7ee65d9e5e 100644 --- a/examples/cpp/dds/RequestReplyExample/CalculatorServer.cpp +++ b/examples/cpp/dds/RequestReplyExample/CalculatorServer.cpp @@ -16,8 +16,6 @@ #include #include -#include "CalculatorPubSubTypes.hpp" - #include #include #include @@ -27,6 +25,8 @@ #include #include +#include "CalculatorPubSubTypes.hpp" + class CalculatorServer { class Listener : public eprosima::fastdds::dds::DataReaderListener diff --git a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.cpp b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.cpp index dd47e64be7c..97684f1682e 100644 --- a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.cpp +++ b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.cpp @@ -17,8 +17,6 @@ * */ -#include "HelloWorldPublisher.h" - #include #include @@ -26,6 +24,9 @@ #include #include +#include "HelloWorldPublisher.h" +#include "HelloWorldPubSubTypes.hpp" + using namespace eprosima::fastdds::dds; HelloWorldPublisher::HelloWorldPublisher() diff --git a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.h b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.h index 90f3a114fd6..4d72c2ff120 100644 --- a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.h +++ b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.h @@ -17,10 +17,8 @@ * */ -#ifndef HELLOWORLDPUBLISHER_H_ -#define HELLOWORLDPUBLISHER_H_ - -#include "HelloWorldPubSubTypes.hpp" +#ifndef FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_PUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_PUBLISHER_H #include #include @@ -87,4 +85,4 @@ class HelloWorldPublisher -#endif /* HELLOWORLDPUBLISHER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_PUBLISHER_H */ diff --git a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.cpp b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.cpp index 7b38e634fd5..446da024f66 100644 --- a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.cpp +++ b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.cpp @@ -17,8 +17,6 @@ * */ -#include "HelloWorldSubscriber.h" - #include #include @@ -26,6 +24,9 @@ #include #include +#include "HelloWorldPubSubTypes.hpp" +#include "HelloWorldSubscriber.h" + using namespace eprosima::fastdds::dds; HelloWorldSubscriber::HelloWorldSubscriber() diff --git a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.h b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.h index b3f2be7d2fd..828b4a9a7a4 100644 --- a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.h +++ b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.h @@ -17,10 +17,8 @@ * */ -#ifndef HELLOWORLDSUBSCRIBER_H_ -#define HELLOWORLDSUBSCRIBER_H_ - -#include "HelloWorldPubSubTypes.hpp" +#ifndef FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_SUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_SUBSCRIBER_H #include #include @@ -92,4 +90,4 @@ class HelloWorldSubscriber }; -#endif /* HELLOWORLDSUBSCRIBER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_SUBSCRIBER_H */ diff --git a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPublisher.cxx b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPublisher.cxx index 4db4a8e26ef..de9f654cd7f 100644 --- a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPublisher.cxx +++ b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPublisher.cxx @@ -19,9 +19,8 @@ * This file was generated by the tool fastcdrgen. */ - -#include "LoanableHelloWorldPublisher.h" -#include "LoanableHelloWorldPubSubTypes.hpp" +#include +#include #include #include @@ -29,8 +28,8 @@ #include #include -#include -#include +#include "LoanableHelloWorldPublisher.h" +#include "LoanableHelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPublisher.h b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPublisher.h index 9f8071f7e70..bf54b57a7c5 100644 --- a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPublisher.h +++ b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPublisher.h @@ -20,8 +20,8 @@ */ -#ifndef _LOANABLEHELLOWORLD_PUBLISHER_H_ -#define _LOANABLEHELLOWORLD_PUBLISHER_H_ +#ifndef FASTDDS_EXAMPLES_CPP_DDS_WRITER_LOANS_EXAMPLE__LOANABLE_HELLO_WORLD_PUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_WRITER_LOANS_EXAMPLE__LOANABLE_HELLO_WORLD_PUBLISHER_H #include #include @@ -66,4 +66,4 @@ class LoanableHelloWorldPublisher listener_; }; -#endif // _LOANABLEHELLOWORLD_PUBLISHER_H_ \ No newline at end of file +#endif // FASTDDS_EXAMPLES_CPP_DDS_WRITER_LOANS_EXAMPLE__LOANABLE_HELLO_WORLD_PUBLISHER_H \ No newline at end of file diff --git a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldSubscriber.h b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldSubscriber.h index cd6488e8527..6428472be63 100644 --- a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldSubscriber.h +++ b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldSubscriber.h @@ -20,8 +20,8 @@ */ -#ifndef _LOANABLEHELLOWORLD_SUBSCRIBER_H_ -#define _LOANABLEHELLOWORLD_SUBSCRIBER_H_ +#ifndef FASTDDS_EXAMPLES_CPP_DDS_WRITER_LOANS_EXAMPLE__LOANABLE_HELLO_WORLD_SUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_WRITER_LOANS_EXAMPLE__LOANABLE_HELLO_WORLD_SUBSCRIBER_H #include #include @@ -69,4 +69,4 @@ class LoanableHelloWorldSubscriber listener_; }; -#endif // _LOANABLEHELLOWORLD_SUBSCRIBER_H_ \ No newline at end of file +#endif // FASTDDS_EXAMPLES_CPP_DDS_WRITER_LOANS_EXAMPLE__LOANABLE_HELLO_WORLD_SUBSCRIBER_H \ No newline at end of file diff --git a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.cxx b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.cxx index a98cff060a3..3a4ae49cb9c 100644 --- a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.cxx +++ b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.cxx @@ -19,9 +19,8 @@ * This file was generated by the tool fastcdrgen. */ - -#include "LoanableHelloWorldPublisher.h" -#include "LoanableHelloWorldPubSubTypes.hpp" +#include +#include #include #include @@ -29,8 +28,8 @@ #include #include -#include -#include +#include "LoanableHelloWorldPublisher.h" +#include "LoanableHelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.h b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.h index b7045f55b38..7afb516ef3f 100644 --- a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.h +++ b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.h @@ -20,8 +20,8 @@ */ -#ifndef _LOANABLEHELLOWORLD_PUBLISHER_H_ -#define _LOANABLEHELLOWORLD_PUBLISHER_H_ +#ifndef FASTDDS_EXAMPLES_CPP_DDS_ZERO_COPY_EXAMPLE__LOANABLE_HELLO_WORLD_PUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_ZERO_COPY_EXAMPLE__LOANABLE_HELLO_WORLD_PUBLISHER_H #include #include @@ -66,4 +66,4 @@ class LoanableHelloWorldPublisher listener_; }; -#endif // _LOANABLEHELLOWORLD_PUBLISHER_H_ \ No newline at end of file +#endif // FASTDDS_EXAMPLES_CPP_DDS_ZERO_COPY_EXAMPLE__LOANABLE_HELLO_WORLD_PUBLISHER_H \ No newline at end of file diff --git a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldSubscriber.h b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldSubscriber.h index 40acb6278cd..3d45fbd724d 100644 --- a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldSubscriber.h +++ b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldSubscriber.h @@ -20,8 +20,8 @@ */ -#ifndef _LOANABLEHELLOWORLD_SUBSCRIBER_H_ -#define _LOANABLEHELLOWORLD_SUBSCRIBER_H_ +#ifndef FASTDDS_EXAMPLES_CPP_DDS_ZERO_COPY_EXAMPLE__LOANABLE_HELLO_WORLD_SUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_ZERO_COPY_EXAMPLE__LOANABLE_HELLO_WORLD_SUBSCRIBER_H #include #include @@ -69,4 +69,4 @@ class LoanableHelloWorldSubscriber listener_; }; -#endif // _LOANABLEHELLOWORLD_SUBSCRIBER_H_ \ No newline at end of file +#endif // FASTDDS_EXAMPLES_CPP_DDS_ZERO_COPY_EXAMPLE__LOANABLE_HELLO_WORLD_SUBSCRIBER_H \ No newline at end of file diff --git a/examples/cpp/delivery_mechanisms/Application.hpp b/examples/cpp/delivery_mechanisms/Application.hpp index 5977ab444e9..71e6734df67 100644 --- a/examples/cpp/delivery_mechanisms/Application.hpp +++ b/examples/cpp/delivery_mechanisms/Application.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_DELIVERY_MECHANISMS_APPLICATION_HPP_ -#define _FASTDDS_DELIVERY_MECHANISMS_APPLICATION_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__APPLICATION_HPP +#define FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__APPLICATION_HPP #include @@ -53,4 +53,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_DELIVERY_MECHANISMS_APPLICATION_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__APPLICATION_HPP */ diff --git a/examples/cpp/delivery_mechanisms/CLIParser.hpp b/examples/cpp/delivery_mechanisms/CLIParser.hpp index 5796491847a..328081fcd76 100644 --- a/examples/cpp/delivery_mechanisms/CLIParser.hpp +++ b/examples/cpp/delivery_mechanisms/CLIParser.hpp @@ -20,8 +20,8 @@ #include #include -#ifndef _FASTDDS_DELIVERY_MECHANISMS_CLI_PARSER_HPP_ -#define _FASTDDS_DELIVERY_MECHANISMS_CLI_PARSER_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__CLIPARSERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__CLIPARSERAPP_HPP namespace eprosima { namespace fastdds { @@ -415,4 +415,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // _FASTDDS_DELIVERY_MECHANISMS_CLI_PARSER_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__CLIPARSERAPP_HPP diff --git a/examples/cpp/delivery_mechanisms/PubSubApp.hpp b/examples/cpp/delivery_mechanisms/PubSubApp.hpp index fab60d8be29..d8924fc4050 100644 --- a/examples/cpp/delivery_mechanisms/PubSubApp.hpp +++ b/examples/cpp/delivery_mechanisms/PubSubApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_DISCOVERY_MECHANISMS_PUBSUB_APP_HPP_ -#define _FASTDDS_DISCOVERY_MECHANISMS_PUBSUB_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__PUBSUBAPP_HPP +#define FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__PUBSUBAPP_HPP #include #include @@ -118,4 +118,4 @@ class PubSubApp : public Application, public DataReaderListener, public DataWrit } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_DISCOVERY_MECHANISMS_PUBSUB_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__PUBSUBAPP_HPP */ diff --git a/examples/cpp/delivery_mechanisms/PublisherApp.cpp b/examples/cpp/delivery_mechanisms/PublisherApp.cpp index ee8a9e8b224..40ec97f9cee 100644 --- a/examples/cpp/delivery_mechanisms/PublisherApp.cpp +++ b/examples/cpp/delivery_mechanisms/PublisherApp.cpp @@ -17,8 +17,6 @@ * */ -#include "PublisherApp.hpp" - #include #include #include @@ -37,6 +35,10 @@ #include #include +#include "PublisherApp.hpp" +#include "DeliveryMechanisms.hpp" +#include "DeliveryMechanismsPubSubTypes.hpp" + using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/delivery_mechanisms/PublisherApp.hpp b/examples/cpp/delivery_mechanisms/PublisherApp.hpp index 729a7012cce..7a507341687 100644 --- a/examples/cpp/delivery_mechanisms/PublisherApp.hpp +++ b/examples/cpp/delivery_mechanisms/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_DISCOVERY_MECHANISMS_PUBLISHER_APP_HPP_ -#define _FASTDDS_DISCOVERY_MECHANISMS_PUBLISHER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__PUBLISHERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__PUBLISHERAPP_HPP #include @@ -97,4 +97,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_DISCOVERY_MECHANISMS_PUBLISHER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__PUBLISHERAPP_HPP */ diff --git a/examples/cpp/delivery_mechanisms/SubscriberApp.hpp b/examples/cpp/delivery_mechanisms/SubscriberApp.hpp index fdb3a5c81f1..2f5d5e9de38 100644 --- a/examples/cpp/delivery_mechanisms/SubscriberApp.hpp +++ b/examples/cpp/delivery_mechanisms/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_DISCOVERY_MECHANISMS_SUBSCRIBER_APP_HPP_ -#define _FASTDDS_DISCOVERY_MECHANISMS_SUBSCRIBER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__SUBSCRIBERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__SUBSCRIBERAPP_HPP #include #include @@ -97,4 +97,4 @@ class SubscriberApp : public Application, public DataReaderListener } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_DISCOVERY_MECHANISMS_SUBSCRIBER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__SUBSCRIBERAPP_HPP */ diff --git a/examples/cpp/discovery_server/ClientPublisherApp.cpp b/examples/cpp/discovery_server/ClientPublisherApp.cpp index 8fe63d5cef8..d0361791247 100644 --- a/examples/cpp/discovery_server/ClientPublisherApp.cpp +++ b/examples/cpp/discovery_server/ClientPublisherApp.cpp @@ -21,6 +21,8 @@ #include #include +#include +#include #include #include @@ -33,6 +35,9 @@ #include #include +#include "DiscoveryServerPublisher.h" +#include "types/HelloWorldPubSubTypes.hpp" + using namespace eprosima::fastdds::dds; namespace eprosima { diff --git a/examples/cpp/discovery_server/ClientSubscriberApp.cpp b/examples/cpp/discovery_server/ClientSubscriberApp.cpp index 8918f708df7..c4e5ce2c478 100644 --- a/examples/cpp/discovery_server/ClientSubscriberApp.cpp +++ b/examples/cpp/discovery_server/ClientSubscriberApp.cpp @@ -38,6 +38,9 @@ #include "CLIParser.hpp" #include "Application.hpp" +#include "DiscoveryServerSubscriber.h" +#include "types/HelloWorldPubSubTypes.hpp" + using namespace eprosima::fastdds::dds; namespace eprosima { diff --git a/examples/cpp/discovery_server/Helpers.hpp b/examples/cpp/discovery_server/Helpers.hpp index c4603c69a9a..6b62890395a 100644 --- a/examples/cpp/discovery_server/Helpers.hpp +++ b/examples/cpp/discovery_server/Helpers.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__HELPERS_HPP -#define FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__HELPERS_HPP +#ifndef FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__COMMON_H +#define FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__COMMON_H #include #include @@ -78,4 +78,4 @@ inline std::string get_ip_from_dns( return domain_name; } -#endif /* FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__HELPERS_HPP */ +#endif /* FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__COMMON_H */ diff --git a/examples/cpp/discovery_server/ServerApp.cpp b/examples/cpp/discovery_server/ServerApp.cpp index 3df45a1ba5c..47ceb19b2fd 100644 --- a/examples/cpp/discovery_server/ServerApp.cpp +++ b/examples/cpp/discovery_server/ServerApp.cpp @@ -17,7 +17,10 @@ * */ +<<<<<<< HEAD:examples/cpp/discovery_server/ServerApp.cpp #include "ServerApp.hpp" +======= +>>>>>>> cb54401dd (Refs #21266: Update fastdds examples guards and namespaces):examples/cpp/dds/DiscoveryServerExample/DiscoveryServerServer.cpp #include #include @@ -33,6 +36,8 @@ #include #include +#include "DiscoveryServerServer.h" + using namespace eprosima::fastdds::dds; namespace eprosima { diff --git a/examples/cpp/hello_world/Application.cpp b/examples/cpp/hello_world/Application.cpp index fb42f74aafc..8242de34545 100644 --- a/examples/cpp/hello_world/Application.cpp +++ b/examples/cpp/hello_world/Application.cpp @@ -17,8 +17,8 @@ * */ -#include "Application.hpp" +#include "Application.hpp" #include "CLIParser.hpp" #include "ListenerSubscriberApp.hpp" #include "PublisherApp.hpp" diff --git a/examples/cpp/hello_world/Application.hpp b/examples/cpp/hello_world/Application.hpp index 9d1f01b214b..333273d826d 100644 --- a/examples/cpp/hello_world/Application.hpp +++ b/examples/cpp/hello_world/Application.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_HELLO_WORLD_APPLICATION_HPP_ -#define _FASTDDS_HELLO_WORLD_APPLICATION_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__APPLICATION_HPP +#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__APPLICATION_HPP #include @@ -53,4 +53,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_HELLO_WORLD_APPLICATION_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_HELLO_WORLD__APPLICATION_HPP */ diff --git a/examples/cpp/hello_world/CLIParser.hpp b/examples/cpp/hello_world/CLIParser.hpp index 8aebfacde8d..47a658bc83d 100644 --- a/examples/cpp/hello_world/CLIParser.hpp +++ b/examples/cpp/hello_world/CLIParser.hpp @@ -18,8 +18,8 @@ #include -#ifndef _FASTDDS_HELLO_WORLD_CLI_PARSER_HPP_ -#define _FASTDDS_HELLO_WORLD_CLI_PARSER_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__CLI_PARSER_HPP +#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__CLI_PARSER_HPP namespace eprosima { namespace fastdds { @@ -258,4 +258,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // _FASTDDS_HELLO_WORLD_CLI_PARSER_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_HELLO_WORLD__CLI_PARSER_HPP diff --git a/examples/cpp/hello_world/ListenerSubscriberApp.hpp b/examples/cpp/hello_world/ListenerSubscriberApp.hpp index 7813cf4487b..d39dcc4c31e 100644 --- a/examples/cpp/hello_world/ListenerSubscriberApp.hpp +++ b/examples/cpp/hello_world/ListenerSubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_HELLO_WORLD_LISTENER_SUBSCRIBER_APP_HPP_ -#define _FASTDDS_HELLO_WORLD_LISTENER_SUBSCRIBER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__LISTENER_SUBSCRIBER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__LISTENER_SUBSCRIBER_APP_HPP #include @@ -27,7 +27,7 @@ #include #include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.hpp" +#include "HelloWorld.hpp" #include "Application.hpp" using namespace eprosima::fastdds::dds; @@ -95,4 +95,4 @@ class ListenerSubscriberApp : public Application, public DataReaderListener } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_HELLO_WORLD_LISTENER_SUBSCRIBER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_HELLO_WORLD__LISTENER_SUBSCRIBER_APP_HPP */ diff --git a/examples/cpp/hello_world/PublisherApp.cpp b/examples/cpp/hello_world/PublisherApp.cpp index d2ec4140767..63b4331137e 100644 --- a/examples/cpp/hello_world/PublisherApp.cpp +++ b/examples/cpp/hello_world/PublisherApp.cpp @@ -28,6 +28,8 @@ #include #include +#include "HelloWorldPubSubTypes.hpp" + using namespace eprosima::fastdds::dds; namespace eprosima { diff --git a/examples/cpp/hello_world/PublisherApp.hpp b/examples/cpp/hello_world/PublisherApp.hpp index c2520a97a1c..cfcdcf70ba7 100644 --- a/examples/cpp/hello_world/PublisherApp.hpp +++ b/examples/cpp/hello_world/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_HELLO_WORLD_PUBLISHER_APP_HPP_ -#define _FASTDDS_HELLO_WORLD_PUBLISHER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__PUBLISHER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__PUBLISHER_APP_HPP #include @@ -28,7 +28,7 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.hpp" +#include "HelloWorld.hpp" using namespace eprosima::fastdds::dds; @@ -96,4 +96,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_HELLO_WORLD_PUBLISHER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_HELLO_WORLD__PUBLISHER_APP_HPP */ diff --git a/examples/cpp/hello_world/WaitsetSubscriberApp.cpp b/examples/cpp/hello_world/WaitsetSubscriberApp.cpp index 9bf670e5c9c..bedda669990 100644 --- a/examples/cpp/hello_world/WaitsetSubscriberApp.cpp +++ b/examples/cpp/hello_world/WaitsetSubscriberApp.cpp @@ -32,9 +32,9 @@ #include #include -#include "HelloWorldPubSubTypes.hpp" -#include "CLIParser.hpp" #include "Application.hpp" +#include "CLIParser.hpp" +#include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/hello_world/WaitsetSubscriberApp.hpp b/examples/cpp/hello_world/WaitsetSubscriberApp.hpp index 507d00ad6ba..ad290bf64b4 100644 --- a/examples/cpp/hello_world/WaitsetSubscriberApp.hpp +++ b/examples/cpp/hello_world/WaitsetSubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_HELLO_WORLD_WAITSET_SUBSCRIBER_APP_HPP_ -#define _FASTDDS_HELLO_WORLD_WAITSET_SUBSCRIBER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__WAITSET_SUBSCRIBER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__WAITSET_SUBSCRIBER_APP_HPP #include #include @@ -28,9 +28,9 @@ #include #include -#include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.hpp" #include "Application.hpp" +#include "CLIParser.hpp" +#include "HelloWorld.hpp" using namespace eprosima::fastdds::dds; @@ -88,4 +88,4 @@ class WaitsetSubscriberApp : public Application } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_HELLO_WORLD_WAITSET_SUBSCRIBER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_HELLO_WORLD__WAITSET_SUBSCRIBER_APP_HPP */ diff --git a/examples/cpp/rtps/AsSocket/TestReaderSocket.h b/examples/cpp/rtps/AsSocket/TestReaderSocket.h index 3151590c154..fce29a1211e 100644 --- a/examples/cpp/rtps/AsSocket/TestReaderSocket.h +++ b/examples/cpp/rtps/AsSocket/TestReaderSocket.h @@ -17,8 +17,8 @@ * */ -#ifndef TESTREADERSOCKET_H_ -#define TESTREADERSOCKET_H_ +#ifndef FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TEST_READER_SOCKET_H +#define FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TEST_READER_SOCKET_H #include @@ -75,4 +75,4 @@ class TestReaderSocket }; -#endif /* TESTREADER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TEST_READER_SOCKET_H */ diff --git a/examples/cpp/rtps/AsSocket/TestWriterSocket.h b/examples/cpp/rtps/AsSocket/TestWriterSocket.h index b427f872ebc..e9b21b2dbd8 100644 --- a/examples/cpp/rtps/AsSocket/TestWriterSocket.h +++ b/examples/cpp/rtps/AsSocket/TestWriterSocket.h @@ -17,8 +17,8 @@ * */ -#ifndef TESTWRITERSOCKET_H_ -#define TESTWRITERSOCKET_H_ +#ifndef FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TEST_WRITER_SOCKET_H +#define FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TEST_WRITER_SOCKET_H #include #include @@ -57,4 +57,4 @@ class TestWriterSocket uint16_t nmsgs); }; -#endif /* TESTWRITER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TEST_WRITER_SOCKET_H */ diff --git a/examples/cpp/rtps/Persistent/TestReaderPersistent.h b/examples/cpp/rtps/Persistent/TestReaderPersistent.h index 53a6ee5d729..33e5e73d49c 100644 --- a/examples/cpp/rtps/Persistent/TestReaderPersistent.h +++ b/examples/cpp/rtps/Persistent/TestReaderPersistent.h @@ -17,8 +17,8 @@ * */ -#ifndef TESTREADERPERSISTENT_H_ -#define TESTREADERPERSISTENT_H_ +#ifndef FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TEST_READER_PERSISTENT_H +#define FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TEST_READER_PERSISTENT_H #include @@ -78,4 +78,4 @@ class TestReaderPersistent m_listener; }; -#endif /* TESTREADERPERSISTENT_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TEST_READER_PERSISTENT_H */ diff --git a/examples/cpp/rtps/Persistent/TestWriterPersistent.h b/examples/cpp/rtps/Persistent/TestWriterPersistent.h index 39022ddb614..5e9c813259c 100644 --- a/examples/cpp/rtps/Persistent/TestWriterPersistent.h +++ b/examples/cpp/rtps/Persistent/TestWriterPersistent.h @@ -17,8 +17,8 @@ * */ -#ifndef TESTWRITERPERSISTENT_H_ -#define TESTWRITERPERSISTENT_H_ +#ifndef FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TEST_WRITER_PERSISTENT_H +#define FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TEST_WRITER_PERSISTENT_H #include @@ -74,4 +74,4 @@ class TestWriterPersistent m_listener; }; -#endif /* TESTWRITERPERSISTENT_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TEST_WRITER_PERSISTENT_H */ diff --git a/examples/cpp/rtps/Registered/TestReaderRegistered.h b/examples/cpp/rtps/Registered/TestReaderRegistered.h index 219823955ed..8483256cc08 100644 --- a/examples/cpp/rtps/Registered/TestReaderRegistered.h +++ b/examples/cpp/rtps/Registered/TestReaderRegistered.h @@ -17,8 +17,8 @@ * */ -#ifndef TESTREADERREGISTERED_H_ -#define TESTREADERREGISTERED_H_ +#ifndef FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TEST_READER_REGISTERED_H +#define FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TEST_READER_REGISTERED_H #include @@ -79,4 +79,4 @@ class TestReaderRegistered m_listener; }; -#endif /* TESTREADER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TEST_READER_REGISTERED_H */ diff --git a/examples/cpp/rtps/Registered/TestWriterRegistered.h b/examples/cpp/rtps/Registered/TestWriterRegistered.h index e9c62c13406..7edb224f860 100644 --- a/examples/cpp/rtps/Registered/TestWriterRegistered.h +++ b/examples/cpp/rtps/Registered/TestWriterRegistered.h @@ -17,8 +17,8 @@ * */ -#ifndef TESTWRITERREGISTERED_H_ -#define TESTWRITERREGISTERED_H_ +#ifndef FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TEST_WRITER_REGISTERED_H +#define FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TEST_WRITER_REGISTERED_H #include @@ -73,4 +73,4 @@ class TestWriterRegistered m_listener; }; -#endif /* TESTWRITER_H_ */ +#endif /* FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TEST_WRITER_REGISTERED_H */ diff --git a/examples/cpp/xtypes/Application.hpp b/examples/cpp/xtypes/Application.hpp index 94ad75ac43c..8fbb766cda4 100644 --- a/examples/cpp/xtypes/Application.hpp +++ b/examples/cpp/xtypes/Application.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_EXAMPLES_XTYPES_APPLICATION_HPP_ -#define _FASTDDS_EXAMPLES_XTYPES_APPLICATION_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_XTYPES__APPLICATION_HPP +#define FASTDDS_EXAMPLES_CPP_XTYPES__APPLICATION_HPP #include @@ -53,4 +53,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_EXAMPLES_XTYPES_APPLICATION_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_XTYPES__APPLICATION_HPP */ diff --git a/examples/cpp/xtypes/CLIParser.hpp b/examples/cpp/xtypes/CLIParser.hpp index 0dd75aa08ec..09efafe898c 100644 --- a/examples/cpp/xtypes/CLIParser.hpp +++ b/examples/cpp/xtypes/CLIParser.hpp @@ -18,8 +18,8 @@ #include -#ifndef _FASTDDS_EXAMPLES_XTYPES_CLI_PARSER_HPP_ -#define _FASTDDS_EXAMPLES_XTYPES_CLI_PARSER_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_XTYPES__CLI_PARSER_HPP +#define FASTDDS_EXAMPLES_CPP_XTYPES__CLI_PARSER_HPP namespace eprosima { namespace fastdds { @@ -246,4 +246,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // _FASTDDS_EXAMPLES_XTYPES_CLI_PARSER_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_XTYPES__CLI_PARSER_HPP diff --git a/examples/cpp/xtypes/PublisherApp.hpp b/examples/cpp/xtypes/PublisherApp.hpp index 37bf8ca4563..e93ee4f2e49 100644 --- a/examples/cpp/xtypes/PublisherApp.hpp +++ b/examples/cpp/xtypes/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_EXAMPLES_XTYPES_PUBLISHER_APP_HPP_ -#define _FASTDDS_EXAMPLES_XTYPES_PUBLISHER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_XTYPES__PUBLISHER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_XTYPES__PUBLISHER_APP_HPP #include @@ -115,4 +115,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_EXAMPLES_XTYPES_PUBLISHER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_XTYPES__PUBLISHER_APP_HPP */ diff --git a/examples/cpp/xtypes/SubscriberApp.hpp b/examples/cpp/xtypes/SubscriberApp.hpp index 3b6be9b0480..73e21d80538 100644 --- a/examples/cpp/xtypes/SubscriberApp.hpp +++ b/examples/cpp/xtypes/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_EXAMPLES_XTYPES_SUBSCRIBER_APP_HPP_ -#define _FASTDDS_EXAMPLES_XTYPES_SUBSCRIBER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_XTYPES__SUBSCRIBER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_XTYPES__SUBSCRIBER_APP_HPP #include @@ -112,4 +112,4 @@ class SubscriberApp : public Application, public DomainParticipantListener } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_EXAMPLES_XTYPES_SUBSCRIBER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_XTYPES__SUBSCRIBER_APP_HPP */ From 1ecda05ce25aa54e2818268965c7e936a82f25ab Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Wed, 3 Jul 2024 10:25:18 +0200 Subject: [PATCH 06/12] Refs #21266: Delete namespace used in delivery_mechanism example Signed-off-by: Carlosespicur --- .../cpp/delivery_mechanisms/Application.cpp | 2 -- .../cpp/delivery_mechanisms/CLIParser.hpp | 1 - .../cpp/delivery_mechanisms/PubSubApp.cpp | 22 +++++++------- .../cpp/delivery_mechanisms/PubSubApp.hpp | 29 +++++++++---------- .../cpp/delivery_mechanisms/PublisherApp.cpp | 20 ++++++------- .../cpp/delivery_mechanisms/PublisherApp.hpp | 19 +++++------- .../cpp/delivery_mechanisms/SubscriberApp.cpp | 9 +++--- .../cpp/delivery_mechanisms/SubscriberApp.hpp | 21 ++++++-------- 8 files changed, 54 insertions(+), 69 deletions(-) diff --git a/examples/cpp/delivery_mechanisms/Application.cpp b/examples/cpp/delivery_mechanisms/Application.cpp index ab87cf2ed3b..6c6965dc206 100644 --- a/examples/cpp/delivery_mechanisms/Application.cpp +++ b/examples/cpp/delivery_mechanisms/Application.cpp @@ -24,8 +24,6 @@ #include "SubscriberApp.hpp" #include "PubSubApp.hpp" -using namespace eprosima::fastdds::dds; - namespace eprosima { namespace fastdds { namespace examples { diff --git a/examples/cpp/delivery_mechanisms/CLIParser.hpp b/examples/cpp/delivery_mechanisms/CLIParser.hpp index 328081fcd76..721c9df5fc3 100644 --- a/examples/cpp/delivery_mechanisms/CLIParser.hpp +++ b/examples/cpp/delivery_mechanisms/CLIParser.hpp @@ -28,7 +28,6 @@ namespace fastdds { namespace examples { namespace delivery_mechanisms { -using namespace eprosima::fastdds::dds; using dds::Log; class CLIParser diff --git a/examples/cpp/delivery_mechanisms/PubSubApp.cpp b/examples/cpp/delivery_mechanisms/PubSubApp.cpp index d2769564239..09e5f1d0e1a 100644 --- a/examples/cpp/delivery_mechanisms/PubSubApp.cpp +++ b/examples/cpp/delivery_mechanisms/PubSubApp.cpp @@ -43,8 +43,8 @@ #include "CLIParser.hpp" #include "DeliveryMechanismsPubSubTypes.hpp" -using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; +using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { @@ -119,7 +119,7 @@ PubSubApp::PubSubApp( { // Large Data is a builtin transport pqos.transport().use_builtin_transports = true; - pqos.setup_transports(eprosima::fastdds::rtps::BuiltinTransports::LARGE_DATA); + pqos.setup_transports(::BuiltinTransports::LARGE_DATA); break; } case CLIParser::DeliveryMechanismKind::TCPv4: @@ -135,10 +135,10 @@ PubSubApp::PubSubApp( tcp_ip_address = config.tcp_ip_address; } // Set unicast locators - eprosima::fastdds::rtps::Locator_t tcp_v4_locator_; + Locator_t tcp_v4_locator_; tcp_v4_locator_.kind = LOCATOR_KIND_TCPv4; - eprosima::fastdds::rtps::IPLocator::setIPv4(tcp_v4_locator_, tcp_ip_address); - eprosima::fastdds::rtps::IPLocator::setPhysicalPort(tcp_v4_locator_, 5100); + IPLocator::setIPv4(tcp_v4_locator_, tcp_ip_address); + IPLocator::setPhysicalPort(tcp_v4_locator_, 5100); pqos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(tcp_v4_locator_); pqos.wire_protocol().default_unicast_locator_list.push_back(tcp_v4_locator_); tcp_v4_transport_->set_WAN_address(tcp_ip_address); @@ -147,7 +147,7 @@ PubSubApp::PubSubApp( Locator tcp_v4_initial_peers_locator_; tcp_v4_initial_peers_locator_.kind = LOCATOR_KIND_TCPv4; tcp_v4_initial_peers_locator_.port = 5100; - eprosima::fastdds::rtps::IPLocator::setIPv4(tcp_v4_initial_peers_locator_, tcp_ip_address); + IPLocator::setIPv4(tcp_v4_initial_peers_locator_, tcp_ip_address); pqos.wire_protocol().builtin.initialPeersList.push_back(tcp_v4_initial_peers_locator_); break; } @@ -164,10 +164,10 @@ PubSubApp::PubSubApp( tcp_ip_address = config.tcp_ip_address; } // Set unicast locators - eprosima::fastdds::rtps::Locator_t tcp_v6_locator_; + Locator_t tcp_v6_locator_; tcp_v6_locator_.kind = LOCATOR_KIND_TCPv6; - eprosima::fastdds::rtps::IPLocator::setIPv6(tcp_v6_locator_, tcp_ip_address); - eprosima::fastdds::rtps::IPLocator::setPhysicalPort(tcp_v6_locator_, 5100); + IPLocator::setIPv6(tcp_v6_locator_, tcp_ip_address); + IPLocator::setPhysicalPort(tcp_v6_locator_, 5100); pqos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(tcp_v6_locator_); pqos.wire_protocol().default_unicast_locator_list.push_back(tcp_v6_locator_); tcp_v6_transport_->add_listener_port(5100); @@ -175,7 +175,7 @@ PubSubApp::PubSubApp( Locator tcp_v6_initial_peers_locator_; tcp_v6_initial_peers_locator_.kind = LOCATOR_KIND_TCPv6; tcp_v6_initial_peers_locator_.port = 5100; - eprosima::fastdds::rtps::IPLocator::setIPv6(tcp_v6_initial_peers_locator_, tcp_ip_address); + IPLocator::setIPv6(tcp_v6_initial_peers_locator_, tcp_ip_address); pqos.wire_protocol().builtin.initialPeersList.push_back(tcp_v6_initial_peers_locator_); break; } @@ -286,7 +286,7 @@ PubSubApp::~PubSubApp() } void PubSubApp::on_publication_matched( - eprosima::fastdds::dds::DataWriter* /*writer*/, + DataWriter* /*writer*/, const PublicationMatchedStatus& info) { if (info.current_count_change == 1) diff --git a/examples/cpp/delivery_mechanisms/PubSubApp.hpp b/examples/cpp/delivery_mechanisms/PubSubApp.hpp index d8924fc4050..9ee917c505d 100644 --- a/examples/cpp/delivery_mechanisms/PubSubApp.hpp +++ b/examples/cpp/delivery_mechanisms/PubSubApp.hpp @@ -35,16 +35,13 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "DeliveryMechanismsPubSubTypes.hpp" - -using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { namespace delivery_mechanisms { -class PubSubApp : public Application, public DataReaderListener, public DataWriterListener +class PubSubApp : public Application, public dds::DataReaderListener, public dds::DataWriterListener { public: @@ -56,17 +53,17 @@ class PubSubApp : public Application, public DataReaderListener, public DataWrit //! Subscription callback void on_data_available( - DataReader* reader) override; + dds::DataReader* reader) override; //! Publisher matched method void on_publication_matched( - DataWriter* writer, - const PublicationMatchedStatus& info) override; + dds::DataWriter* writer, + const dds::PublicationMatchedStatus& info) override; //! Subscriber matched method void on_subscription_matched( - DataReader* reader, - const SubscriptionMatchedStatus& info) override; + dds::DataReader* reader, + const dds::SubscriptionMatchedStatus& info) override; //! Run the subscriber void run() override; @@ -82,19 +79,19 @@ class PubSubApp : public Application, public DataReaderListener, public DataWrit //! Publish a sample bool publish(); - DomainParticipant* participant_; + dds::DomainParticipant* participant_; - Publisher* publisher_; + dds::Publisher* publisher_; - Subscriber* subscriber_; + dds::Subscriber* subscriber_; - Topic* topic_; + dds::Topic* topic_; - DataReader* reader_; + dds::DataReader* reader_; - DataWriter* writer_; + dds::DataWriter* writer_; - TypeSupport type_; + dds::TypeSupport type_; std::condition_variable cv_; diff --git a/examples/cpp/delivery_mechanisms/PublisherApp.cpp b/examples/cpp/delivery_mechanisms/PublisherApp.cpp index 40ec97f9cee..5a225357a86 100644 --- a/examples/cpp/delivery_mechanisms/PublisherApp.cpp +++ b/examples/cpp/delivery_mechanisms/PublisherApp.cpp @@ -36,12 +36,10 @@ #include #include "PublisherApp.hpp" -#include "DeliveryMechanisms.hpp" #include "DeliveryMechanismsPubSubTypes.hpp" -using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; - +using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { @@ -104,7 +102,7 @@ PublisherApp::PublisherApp( { // Large Data is a builtin transport pqos.transport().use_builtin_transports = true; - pqos.setup_transports(eprosima::fastdds::rtps::BuiltinTransports::LARGE_DATA); + pqos.setup_transports(BuiltinTransports::LARGE_DATA); break; } case CLIParser::DeliveryMechanismKind::TCPv4: @@ -120,10 +118,10 @@ PublisherApp::PublisherApp( tcp_ip_address = config.tcp_ip_address; } // Set unicast locators - eprosima::fastdds::rtps::Locator_t tcp_v4_locator_; + Locator_t tcp_v4_locator_; tcp_v4_locator_.kind = LOCATOR_KIND_TCPv4; - eprosima::fastdds::rtps::IPLocator::setIPv4(tcp_v4_locator_, tcp_ip_address); - eprosima::fastdds::rtps::IPLocator::setPhysicalPort(tcp_v4_locator_, 5100); + IPLocator::setIPv4(tcp_v4_locator_, tcp_ip_address); + IPLocator::setPhysicalPort(tcp_v4_locator_, 5100); pqos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(tcp_v4_locator_); pqos.wire_protocol().default_unicast_locator_list.push_back(tcp_v4_locator_); tcp_v4_transport_->set_WAN_address(tcp_ip_address); @@ -144,10 +142,10 @@ PublisherApp::PublisherApp( tcp_ip_address = config.tcp_ip_address; } // Set unicast locators - eprosima::fastdds::rtps::Locator_t tcp_v6_locator_; + Locator_t tcp_v6_locator_; tcp_v6_locator_.kind = LOCATOR_KIND_TCPv6; - eprosima::fastdds::rtps::IPLocator::setIPv6(tcp_v6_locator_, tcp_ip_address); - eprosima::fastdds::rtps::IPLocator::setPhysicalPort(tcp_v6_locator_, 5100); + IPLocator::setIPv6(tcp_v6_locator_, tcp_ip_address); + IPLocator::setPhysicalPort(tcp_v6_locator_, 5100); pqos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(tcp_v6_locator_); pqos.wire_protocol().default_unicast_locator_list.push_back(tcp_v6_locator_); tcp_v6_transport_->add_listener_port(5100); @@ -237,7 +235,7 @@ PublisherApp::~PublisherApp() } void PublisherApp::on_publication_matched( - eprosima::fastdds::dds::DataWriter* /*writer*/, + DataWriter* /*writer*/, const PublicationMatchedStatus& info) { if (info.current_count_change == 1) diff --git a/examples/cpp/delivery_mechanisms/PublisherApp.hpp b/examples/cpp/delivery_mechanisms/PublisherApp.hpp index 7a507341687..acb09e4e0ad 100644 --- a/examples/cpp/delivery_mechanisms/PublisherApp.hpp +++ b/examples/cpp/delivery_mechanisms/PublisherApp.hpp @@ -29,16 +29,13 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "DeliveryMechanismsPubSubTypes.hpp" - -using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { namespace delivery_mechanisms { -class PublisherApp : public Application, public DataWriterListener +class PublisherApp : public Application, public dds::DataWriterListener { public: @@ -50,8 +47,8 @@ class PublisherApp : public Application, public DataWriterListener //! Publisher matched method void on_publication_matched( - DataWriter* writer, - const PublicationMatchedStatus& info) override; + dds::DataWriter* writer, + const dds::PublicationMatchedStatus& info) override; //! Run publisher void run() override; @@ -67,15 +64,15 @@ class PublisherApp : public Application, public DataWriterListener //! Publish a sample bool publish(); - DomainParticipant* participant_; + dds::DomainParticipant* participant_; - Publisher* publisher_; + dds::Publisher* publisher_; - Topic* topic_; + dds::Topic* topic_; - DataWriter* writer_; + dds::DataWriter* writer_; - TypeSupport type_; + dds::TypeSupport type_; std::condition_variable cv_; diff --git a/examples/cpp/delivery_mechanisms/SubscriberApp.cpp b/examples/cpp/delivery_mechanisms/SubscriberApp.cpp index aae3b111a51..1c2a7d4d520 100644 --- a/examples/cpp/delivery_mechanisms/SubscriberApp.cpp +++ b/examples/cpp/delivery_mechanisms/SubscriberApp.cpp @@ -39,9 +39,8 @@ #include "CLIParser.hpp" #include "DeliveryMechanismsPubSubTypes.hpp" -using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; - +using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { @@ -104,7 +103,7 @@ SubscriberApp::SubscriberApp( { // Large Data is a builtin transport pqos.transport().use_builtin_transports = true; - pqos.setup_transports(eprosima::fastdds::rtps::BuiltinTransports::LARGE_DATA); + pqos.setup_transports(BuiltinTransports::LARGE_DATA); break; } case CLIParser::DeliveryMechanismKind::TCPv4: @@ -117,7 +116,7 @@ SubscriberApp::SubscriberApp( { tcp_ip_address = config.tcp_ip_address; } - eprosima::fastdds::rtps::IPLocator::setIPv4(tcp_v4_initial_peers_locator_, tcp_ip_address); + IPLocator::setIPv4(tcp_v4_initial_peers_locator_, tcp_ip_address); pqos.wire_protocol().builtin.initialPeersList.push_back(tcp_v4_initial_peers_locator_); pqos.wire_protocol().builtin.discovery_config.leaseDuration = eprosima::fastdds::c_TimeInfinite; pqos.wire_protocol().builtin.discovery_config.leaseDuration_announcementperiod = Duration_t(5, 0); @@ -134,7 +133,7 @@ SubscriberApp::SubscriberApp( { tcp_ip_address = config.tcp_ip_address; } - eprosima::fastdds::rtps::IPLocator::setIPv6(tcp_v6_initial_peers_locator_, tcp_ip_address); + IPLocator::setIPv6(tcp_v6_initial_peers_locator_, tcp_ip_address); pqos.wire_protocol().builtin.initialPeersList.push_back(tcp_v6_initial_peers_locator_); pqos.wire_protocol().builtin.discovery_config.leaseDuration = eprosima::fastdds::c_TimeInfinite; pqos.wire_protocol().builtin.discovery_config.leaseDuration_announcementperiod = Duration_t(5, 0); diff --git a/examples/cpp/delivery_mechanisms/SubscriberApp.hpp b/examples/cpp/delivery_mechanisms/SubscriberApp.hpp index 2f5d5e9de38..7f61dbacdb5 100644 --- a/examples/cpp/delivery_mechanisms/SubscriberApp.hpp +++ b/examples/cpp/delivery_mechanisms/SubscriberApp.hpp @@ -32,16 +32,13 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "DeliveryMechanismsPubSubTypes.hpp" - -using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { namespace delivery_mechanisms { -class SubscriberApp : public Application, public DataReaderListener +class SubscriberApp : public Application, public dds::DataReaderListener { public: @@ -53,12 +50,12 @@ class SubscriberApp : public Application, public DataReaderListener //! Subscription callback void on_data_available( - DataReader* reader) override; + dds::DataReader* reader) override; //! Subscriber matched method void on_subscription_matched( - DataReader* reader, - const SubscriptionMatchedStatus& info) override; + dds::DataReader* reader, + const dds::SubscriptionMatchedStatus& info) override; //! Run the subscriber void run() override; @@ -71,15 +68,15 @@ class SubscriberApp : public Application, public DataReaderListener //! Return the current state of execution bool is_stopped(); - DomainParticipant* participant_; + dds::DomainParticipant* participant_; - Subscriber* subscriber_; + dds::Subscriber* subscriber_; - Topic* topic_; + dds::Topic* topic_; - DataReader* reader_; + dds::DataReader* reader_; - TypeSupport type_; + dds::TypeSupport type_; std::condition_variable cv_; From f7bb785fe3190ce118dc280eab6fd812578c7ec8 Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Mon, 8 Jul 2024 07:38:26 +0200 Subject: [PATCH 07/12] Refs #21266: Add corrections Signed-off-by: Carlosespicur --- examples/CMakeLists.txt | 2 +- .../cpp/discovery_server/ClientPublisherApp.cpp | 3 +-- .../cpp/discovery_server/ClientSubscriberApp.cpp | 3 +-- examples/cpp/discovery_server/ServerApp.cpp | 5 ----- examples/cpp/security/CLIParser.hpp | 9 ++++++--- examples/cpp/security/CMakeLists.txt | 2 +- examples/cpp/security/PublisherApp.cpp | 2 +- examples/cpp/security/PublisherApp.hpp | 8 ++++---- examples/cpp/security/README.md | 7 +++---- examples/cpp/security/SubscriberApp.cpp | 2 +- examples/cpp/security/SubscriberApp.hpp | 6 +++--- examples/cpp/security/hello_world_profile.xml | 14 +++++++------- test/examples/security.compose.yml | 13 +++++++++++++ versions.md | 2 +- 14 files changed, 43 insertions(+), 35 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9e10992efc5..cd617f0a616 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -20,7 +20,7 @@ add_subdirectory(cpp/custom_payload_pool) add_subdirectory(cpp/dds) add_subdirectory(cpp/delivery_mechanisms) add_subdirectory(cpp/discovery_server) -add_subdirectory(cpp/dds_security) +add_subdirectory(cpp/security) add_subdirectory(cpp/hello_world) add_subdirectory(cpp/rtps) add_subdirectory(cpp/xtypes) diff --git a/examples/cpp/discovery_server/ClientPublisherApp.cpp b/examples/cpp/discovery_server/ClientPublisherApp.cpp index d0361791247..a291171372b 100644 --- a/examples/cpp/discovery_server/ClientPublisherApp.cpp +++ b/examples/cpp/discovery_server/ClientPublisherApp.cpp @@ -35,8 +35,7 @@ #include #include -#include "DiscoveryServerPublisher.h" -#include "types/HelloWorldPubSubTypes.hpp" +#include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/discovery_server/ClientSubscriberApp.cpp b/examples/cpp/discovery_server/ClientSubscriberApp.cpp index c4e5ce2c478..a026455eb66 100644 --- a/examples/cpp/discovery_server/ClientSubscriberApp.cpp +++ b/examples/cpp/discovery_server/ClientSubscriberApp.cpp @@ -38,8 +38,7 @@ #include "CLIParser.hpp" #include "Application.hpp" -#include "DiscoveryServerSubscriber.h" -#include "types/HelloWorldPubSubTypes.hpp" +#include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/discovery_server/ServerApp.cpp b/examples/cpp/discovery_server/ServerApp.cpp index 47ceb19b2fd..3df45a1ba5c 100644 --- a/examples/cpp/discovery_server/ServerApp.cpp +++ b/examples/cpp/discovery_server/ServerApp.cpp @@ -17,10 +17,7 @@ * */ -<<<<<<< HEAD:examples/cpp/discovery_server/ServerApp.cpp #include "ServerApp.hpp" -======= ->>>>>>> cb54401dd (Refs #21266: Update fastdds examples guards and namespaces):examples/cpp/dds/DiscoveryServerExample/DiscoveryServerServer.cpp #include #include @@ -36,8 +33,6 @@ #include #include -#include "DiscoveryServerServer.h" - using namespace eprosima::fastdds::dds; namespace eprosima { diff --git a/examples/cpp/security/CLIParser.hpp b/examples/cpp/security/CLIParser.hpp index 7bbe8fe0e80..c41aaf1fa86 100644 --- a/examples/cpp/security/CLIParser.hpp +++ b/examples/cpp/security/CLIParser.hpp @@ -47,14 +47,17 @@ class CLIParser struct entity_config { uint16_t samples = 0; - uint32_t interval = 100; // milliseconds + }; + struct publisher_config : entity_config + { + uint32_t interval = 1000; }; //! Configuration structure for the application struct security_config { CLIParser::EntityKind entity = CLIParser::EntityKind::UNDEFINED; - entity_config pub_config; + publisher_config pub_config; entity_config sub_config; }; @@ -68,7 +71,7 @@ class CLIParser static void print_help( uint8_t return_code) { - std::cout << "Usage: security [options]" << std::endl; + std::cout << "Usage: security [options]" << std::endl; std::cout << "" << std::endl; std::cout << "Entities:" << std::endl; std::cout << " publisher Run a publisher entity" << std::endl; diff --git a/examples/cpp/security/CMakeLists.txt b/examples/cpp/security/CMakeLists.txt index 5e7ac34ed0a..ec130eb3f5e 100644 --- a/examples/cpp/security/CMakeLists.txt +++ b/examples/cpp/security/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.20) -project(fastdds_secure_hello_world_example VERSION 1 LANGUAGES CXX) +project(fastdds_security_example VERSION 1 LANGUAGES CXX) # Find requirements if(NOT fastcdr_FOUND) diff --git a/examples/cpp/security/PublisherApp.cpp b/examples/cpp/security/PublisherApp.cpp index d918d162559..dbaf7581541 100644 --- a/examples/cpp/security/PublisherApp.cpp +++ b/examples/cpp/security/PublisherApp.cpp @@ -37,7 +37,7 @@ namespace examples { namespace security { PublisherApp::PublisherApp( - const CLIParser::entity_config& config, + const CLIParser::publisher_config& config, const std::string& topic_name) : participant_(nullptr) , publisher_(nullptr) diff --git a/examples/cpp/security/PublisherApp.hpp b/examples/cpp/security/PublisherApp.hpp index 0ff5efdeedd..18edbd483de 100644 --- a/examples/cpp/security/PublisherApp.hpp +++ b/examples/cpp/security/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_PUBLISHER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_PUBLISHER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__PUBLISHER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__PUBLISHER_APP_HPP #include @@ -42,7 +42,7 @@ class PublisherApp : public Application, public DataWriterListener public: PublisherApp( - const CLIParser::entity_config& config, + const CLIParser::publisher_config& config, const std::string& topic_name); ~PublisherApp(); @@ -97,4 +97,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_PUBLISHER_APP_HPP */ +#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__PUBLISHER_APP_HPP */ diff --git a/examples/cpp/security/README.md b/examples/cpp/security/README.md index ab311ab61c3..7f22448a528 100644 --- a/examples/cpp/security/README.md +++ b/examples/cpp/security/README.md @@ -1,14 +1,13 @@ -# Secure Hello world example +# Security example -The *eProsima Fast DDS hello world* example is a simple application intended to demonstrate a basic DDS deployment with security builtin plugins. +The *eProsima Fast DDS security* example is a simple application intended to demonstrate a basic DDS deployment with security builtin plugins. This example is part of the suite of examples designed by eProsima that aims to illustrate the features and possible configurations of DDS deployments through *eProsima Fast DDS*. -In this case, the *secure hello world* example describes the simplest deployment of a Fast DDS publisher and subscriber using the DDS Security specification. +In this case, the *security* example describes the simplest deployment of a Fast DDS publisher and subscriber using the DDS Security specification. * [Description of the example](#description-of-the-example) * [Run the example](#run-the-example) -* [Wait-set subscriber](#wait-set-subscriber) * [XML profile playground](#xml-profile-playground) ## Description of the example diff --git a/examples/cpp/security/SubscriberApp.cpp b/examples/cpp/security/SubscriberApp.cpp index 0152942c982..03b498ec7c6 100644 --- a/examples/cpp/security/SubscriberApp.cpp +++ b/examples/cpp/security/SubscriberApp.cpp @@ -13,7 +13,7 @@ // limitations under the License. /** - * @file ListenerSubscriber.cpp + * @file SubscriberApp.cpp * */ diff --git a/examples/cpp/security/SubscriberApp.hpp b/examples/cpp/security/SubscriberApp.hpp index 4e3751e8cfb..a24b913bd59 100644 --- a/examples/cpp/security/SubscriberApp.hpp +++ b/examples/cpp/security/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_SUBSCRIBER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_SUBSCRIBER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__SUBSCRIBER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__SUBSCRIBER_APP_HPP #include @@ -95,4 +95,4 @@ class SubscriberApp : public Application, public DataReaderListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_SUBSCRIBER_APP_HPP */ +#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__SUBSCRIBER_APP_HPP */ diff --git a/examples/cpp/security/hello_world_profile.xml b/examples/cpp/security/hello_world_profile.xml index 646643e64f5..fe750d71c64 100644 --- a/examples/cpp/security/hello_world_profile.xml +++ b/examples/cpp/security/hello_world_profile.xml @@ -15,19 +15,19 @@ dds.sec.auth.builtin.PKI-DH.identity_ca - file://maincacert.pem + file://certs/maincacert.pem dds.sec.auth.builtin.PKI-DH.identity_certificate - file://partcert.pem + file://certs/partcert.pem dds.sec.auth.builtin.PKI-DH.identity_crl - file://crl.pem + file://certs/crl.pem dds.sec.auth.builtin.PKI-DH.private_key - file://partkey.pem + file://certs/partkey.pem dds.sec.auth.builtin.PKI-DH.password @@ -45,15 +45,15 @@ dds.sec.access.builtin.Access-Permissions.permissions_ca - file://maincacet.pem + file://certs/maincacet.pem dds.sec.access.builtin.Access-Permissions.governance - file://governance.smime + file://certs/governance.smime dds.sec.access.builtin.Access-Permissions.permissions - file://permissions.smime + file://certs/permissions.smime diff --git a/test/examples/security.compose.yml b/test/examples/security.compose.yml index 76c97afb25d..994fe6a25c8 100644 --- a/test/examples/security.compose.yml +++ b/test/examples/security.compose.yml @@ -14,6 +14,19 @@ version: "3" services: + subscriber: + image: @DOCKER_IMAGE_NAME@ + volumes: + - @PROJECT_BINARY_DIR@:@PROJECT_BINARY_DIR@ + - @fastcdr_LIB_DIR@:@fastcdr_LIB_DIR@ + @TINYXML2_LIB_DIR_COMPOSE_VOLUME@ + environment: + # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows + LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ + EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/security + FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/security/hello_world_profile.xml + command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/security@FILE_EXTENSION@ subscriber --samples 10" + subscriber-publisher: image: @DOCKER_IMAGE_NAME@ volumes: diff --git a/versions.md b/versions.md index de0ce875016..2482d2e68ea 100644 --- a/versions.md +++ b/versions.md @@ -48,7 +48,7 @@ Forthcoming * Calling `DataReader::return_loan` returns `ReturnCode_t::RETCODE_OK` both for empty sequences and for sequences that were not loaned. * Refactor examples: * Hello world example with wait-sets and environment XML profiles. - * Secured hello world example with environment XML profiles. + * Security example with environment XML profiles. * Configuration example that condenses multiple QoS examples. Multiple configurations allowed through argument parsing. * Custom payload pool example that uses a user-defined payload pool instead of the default * X-Types example with dynamic type discovery and Hello world example compatibility. From 51375d3d398909e575a4a0a3815439cb582d006e Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Tue, 9 Jul 2024 14:52:10 +0200 Subject: [PATCH 08/12] Refs #21266: Change XML profiles and modify README Signed-off-by: Carlosespicur --- examples/cpp/security/README.md | 33 +++++++- examples/cpp/security/main.cpp | 2 +- .../cpp/security/secure_publisher_profile.xml | 76 +++++++++++++++++++ ...file.xml => secure_subscriber_profile.xml} | 71 ++--------------- test/examples/security.compose.yml | 14 ++-- test/examples/test_security.py | 4 +- 6 files changed, 125 insertions(+), 75 deletions(-) create mode 100644 examples/cpp/security/secure_publisher_profile.xml rename examples/cpp/security/{hello_world_profile.xml => secure_subscriber_profile.xml} (51%) diff --git a/examples/cpp/security/README.md b/examples/cpp/security/README.md index 7f22448a528..29489c232a4 100644 --- a/examples/cpp/security/README.md +++ b/examples/cpp/security/README.md @@ -23,7 +23,20 @@ For simplicity, in this example, the subscriber class inherits from the listener ## Run the example To launch this example, two different terminals are required. -One of them will run the publisher example application, and the other will run the subscriber application. +One of them will run the publisher example application, and the other will run the subscriber application. Before running both applications, it is necessary to export the path of the folder where the certificates are located in the environment variable ``CERTS_PATH``: + +* Ubuntu ( / MacOS ) + + ```shell + user@machine:example_path$ export CERTS_PATH= + ``` + +* Windows + + ```powershell + example_path> set CERTS_PATH= + ``` + ### Secure Hello world publisher @@ -104,15 +117,29 @@ This is accomplished by setting the environment variable ``FASTDDS_DEFAULT_PROFI * Ubuntu ( / MacOS ) +- Publisher profile: + ```shell - user@machine:example_path$ export FASTDDS_DEFAULT_PROFILES_FILE=hello_world_profile.xml + user@machine:example_path$ export FASTDDS_DEFAULT_PROFILES_FILE=secure_publisher_profile.xml + ``` +- Subscriber profile: + + ```shell + user@machine:example_path$ export FASTDDS_DEFAULT_PROFILES_FILE=secure_subscriber_profile.xml ``` * Windows +- Publisher profile: + ```powershell - example_path> set FASTDDS_DEFAULT_PROFILES_FILE=hello_world_profile.xml + example_path> set FASTDDS_DEFAULT_PROFILES_FILE=secure_publisher_profile.xml ``` +- Subscriber profile: + + ```powershell + example_path> set FASTDDS_DEFAULT_PROFILES_FILE=secure_subscriber_profile.xml + ``` The example provides with an XML profiles files with certain QoS: diff --git a/examples/cpp/security/main.cpp b/examples/cpp/security/main.cpp index 702a77ccf3f..12f013074ec 100644 --- a/examples/cpp/security/main.cpp +++ b/examples/cpp/security/main.cpp @@ -43,7 +43,7 @@ int main( char** argv) { auto ret = EXIT_SUCCESS; - const std::string topic_name = "security_topic"; + const std::string topic_name = "HelloWorldTopic"; CLIParser::security_config config = CLIParser::parse_cli_options(argc, argv); uint16_t samples = 0; switch (config.entity) diff --git a/examples/cpp/security/secure_publisher_profile.xml b/examples/cpp/security/secure_publisher_profile.xml new file mode 100644 index 00000000000..ef41b920b60 --- /dev/null +++ b/examples/cpp/security/secure_publisher_profile.xml @@ -0,0 +1,76 @@ + + + + 0 + + hello_world_participant + + + + + + dds.sec.auth.plugin + builtin.PKI-DH + + + + dds.sec.auth.builtin.PKI-DH.identity_ca + file://${CERTS_PATH}/maincacert.pem + + + dds.sec.auth.builtin.PKI-DH.identity_certificate + file://${CERTS_PATH}/mainpubcert.pem + + + dds.sec.auth.builtin.PKI-DH.private_key + file://${CERTS_PATH}/mainpubkey.pem + + + + dds.sec.access.plugin + builtin.Access-Permissions + + + + dds.sec.access.builtin.Access-Permissions.permissions_ca + file://${CERTS_PATH}/maincacert.pem + + + dds.sec.access.builtin.Access-Permissions.governance + file://${CERTS_PATH}/governance.smime + + + dds.sec.access.builtin.Access-Permissions.permissions + file://${CERTS_PATH}/permissions.smime + + + + dds.sec.crypto.plugin + builtin.AES-GCM-GMAC + + + + + + + + + TRANSIENT_LOCAL + + + RELIABLE + + + + + KEEP_LAST + 100 + + + 100 + 1 + 100 + + + + diff --git a/examples/cpp/security/hello_world_profile.xml b/examples/cpp/security/secure_subscriber_profile.xml similarity index 51% rename from examples/cpp/security/hello_world_profile.xml rename to examples/cpp/security/secure_subscriber_profile.xml index fe750d71c64..e1483c328ad 100644 --- a/examples/cpp/security/hello_world_profile.xml +++ b/examples/cpp/security/secure_subscriber_profile.xml @@ -15,28 +15,16 @@ dds.sec.auth.builtin.PKI-DH.identity_ca - file://certs/maincacert.pem + file://${CERTS_PATH}/maincacert.pem dds.sec.auth.builtin.PKI-DH.identity_certificate - file://certs/partcert.pem - - - dds.sec.auth.builtin.PKI-DH.identity_crl - file://certs/crl.pem + file://${CERTS_PATH}/mainsubcert.pem dds.sec.auth.builtin.PKI-DH.private_key - file://certs/partkey.pem + file://${CERTS_PATH}/mainsubkey.pem - - dds.sec.auth.builtin.PKI-DH.password - domainParticipantPassword - - - - - dds.sec.access.plugin @@ -45,68 +33,25 @@ dds.sec.access.builtin.Access-Permissions.permissions_ca - file://certs/maincacet.pem + file://${CERTS_PATH}/maincacert.pem dds.sec.access.builtin.Access-Permissions.governance - file://certs/governance.smime + file://${CERTS_PATH}/governance.smime dds.sec.access.builtin.Access-Permissions.permissions - file://certs/permissions.smime + file://${CERTS_PATH}/permissions.smime - - - - - + dds.sec.crypto.plugin builtin.AES-GCM-GMAC - - - - - - dds.sec.log.plugin - builtin.DDS_LogTopic - - - - dds.sec.log.builtin.DDS_LogTopic.logging_level - EMERGENCY_LEVEL - - - dds.sec.log.builtin.DDS_LogTopic.log_file - myLogFile.log - - - + - - - - TRANSIENT_LOCAL - - - RELIABLE - - - - - KEEP_LAST - 100 - - - 100 - 1 - 100 - - - diff --git a/test/examples/security.compose.yml b/test/examples/security.compose.yml index 994fe6a25c8..1abf5eddb90 100644 --- a/test/examples/security.compose.yml +++ b/test/examples/security.compose.yml @@ -24,10 +24,11 @@ services: # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/security - FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/security/hello_world_profile.xml + CERTS_PATH: @PROJECT_BINARY_DIR@/examples/cpp/security/certs + FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/security/secure_subscriber_profile.xml command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/security@FILE_EXTENSION@ subscriber --samples 10" - - subscriber-publisher: + + publisher: image: @DOCKER_IMAGE_NAME@ volumes: - @PROJECT_BINARY_DIR@:@PROJECT_BINARY_DIR@ @@ -37,6 +38,7 @@ services: # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/security - FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/security/hello_world_profile.xml - command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/security@FILE_EXTENSION@ subscriber --samples 10 & $${EXAMPLE_DIR}/security@FILE_EXTENSION@ publisher --samples 10" - + CERTS_PATH: @PROJECT_BINARY_DIR@/examples/cpp/security/certs + FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/security/secure_publisher_profile.xml + command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/security@FILE_EXTENSION@ publisher --samples 10" + diff --git a/test/examples/test_security.py b/test/examples/test_security.py index 63e4b93cd87..b2bcc2c02a4 100644 --- a/test/examples/test_security.py +++ b/test/examples/test_security.py @@ -37,11 +37,11 @@ def test_security(): received += 1 continue - if sent != 0 and received != 0 and sent * 2 == received: + if sent != 0 and received != 0 and sent == received: ret = True else: print('ERROR: sent: ' + str(sent) + ', but received: ' + str(received) + - ' (expected: ' + str(sent * 2) + ')') + ' (expected: ' + str(sent) + ')') raise subprocess.CalledProcessError(1, '') except subprocess.CalledProcessError: From e4f58e3b6c4cd7c7daeca469bed53ffd9ad61bcc Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Wed, 10 Jul 2024 07:36:20 +0200 Subject: [PATCH 09/12] Refs #21266: Delete unnecesary headers and old DiscoveryServerExample Signed-off-by: Carlosespicur --- .../DiscoveryServerPublisher.h | 127 ------ .../DiscoveryServerServer.h | 107 ----- .../DiscoveryServerSubscriber.h | 141 ------- .../arg_configuration.h | 382 ------------------ .../discovery_server/ClientPublisherApp.cpp | 2 - .../discovery_server/ClientPublisherApp.hpp | 2 +- .../discovery_server/ClientSubscriberApp.hpp | 2 +- 7 files changed, 2 insertions(+), 761 deletions(-) delete mode 100644 examples/cpp/dds/DiscoveryServerExample/DiscoveryServerPublisher.h delete mode 100644 examples/cpp/dds/DiscoveryServerExample/DiscoveryServerServer.h delete mode 100644 examples/cpp/dds/DiscoveryServerExample/DiscoveryServerSubscriber.h delete mode 100644 examples/cpp/dds/DiscoveryServerExample/arg_configuration.h diff --git a/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerPublisher.h b/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerPublisher.h deleted file mode 100644 index 2a53c12d38a..00000000000 --- a/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerPublisher.h +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file DiscoveryServerPublisher.h - * - */ - -#ifndef FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_PUBLISHER_H -#define FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_PUBLISHER_H - -#include - -#include -#include -#include - -#include "common.h" -#include "types/HelloWorld.hpp" - -/** - * Class used to group into a single working unit a Publisher with a DataWriter, its listener, and a TypeSupport member - * corresponding to the HelloWorld datatype - */ -class HelloWorldPublisher -{ -public: - - HelloWorldPublisher(); - - virtual ~HelloWorldPublisher(); - - //! Initialize the publisher - bool init( - const std::string& topic_name, - const std::string& server_address, - unsigned short server_port, - unsigned short server_id, - TransportKind transport); - - //! Publish a sample - void publish(); - - //! Run for number samples, publish every sleep seconds - void run( - uint32_t number, - uint32_t sleep); - - //! Return the current state of execution - static bool is_stopped(); - - //! Trigger the end of execution - static void stop(); - -private: - - HelloWorld hello_; - - eprosima::fastdds::dds::DomainParticipant* participant_; - - eprosima::fastdds::dds::Publisher* publisher_; - - eprosima::fastdds::dds::Topic* topic_; - - eprosima::fastdds::dds::DataWriter* writer_; - - eprosima::fastdds::dds::TypeSupport type_; - - /** - * Class handling discovery events - */ - class PubListener : public eprosima::fastdds::dds::DomainParticipantListener - { - public: - - PubListener() - : matched_(0) - { - } - - ~PubListener() override - { - } - - //! Callback executed when a DataReader is matched or unmatched - void on_publication_matched( - eprosima::fastdds::dds::DataWriter* writer, - const eprosima::fastdds::dds::PublicationMatchedStatus& info) override; - - //! Callback executed when a DomainParticipant is discovered, dropped or removed - void on_participant_discovery( - eprosima::fastdds::dds::DomainParticipant* /*participant*/, - eprosima::fastdds::rtps::ParticipantDiscoveryInfo&& info, - bool& should_be_ignored) override; - - private: - - using eprosima::fastdds::dds::DomainParticipantListener::on_participant_discovery; - - //! Number of DataReaders matched to the associated DataWriter - std::atomic matched_; - } - listener_; - - //! Run thread for number samples, publish every sleep seconds - void runThread( - uint32_t number, - uint32_t sleep); - - //! Member used for control flow purposes - static std::atomic stop_; -}; - - - -#endif /* FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_PUBLISHER_H */ diff --git a/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerServer.h b/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerServer.h deleted file mode 100644 index ee59c2d0a5e..00000000000 --- a/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerServer.h +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file DiscoveryServerServer.h - * - */ - -#ifndef FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_SERVER_H -#define FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_SERVER_H - -#include -#include -#include - -#include -#include - -#include "common.h" - -/** - * Class with a partipant configured to function as server in the Discovery Server mechanism - */ -class DiscoveryServer -{ -public: - - DiscoveryServer(); - - virtual ~DiscoveryServer(); - - //! Initialize the server - bool init( - const std::string& server_address, - unsigned short server_port, - unsigned short server_id, - TransportKind transport, - bool has_connection_server, - const std::string& connection_server_address, - unsigned short connection_server_port, - unsigned short connection_server_id); - - //! Run - void run( - unsigned int timeout); - - //! Return the current state of execution - static bool is_stopped(); - - //! Trigger the end of execution - static void stop(); - -private: - - eprosima::fastdds::dds::DomainParticipant* participant_; - - /** - * Class handling discovery events - */ - class ServerListener : public eprosima::fastdds::dds::DomainParticipantListener - { - public: - - ServerListener() - { - } - - ~ServerListener() override - { - } - - //! Callback executed when a DomainParticipant is discovered, dropped or removed - void on_participant_discovery( - eprosima::fastdds::dds::DomainParticipant* /*participant*/, - eprosima::fastdds::rtps::ParticipantDiscoveryInfo&& info, - bool& should_be_ignored) override; - - private: - - using eprosima::fastdds::dds::DomainParticipantListener::on_participant_discovery; - } - listener_; - - //! Member used for control flow purposes - static std::atomic stop_; - - //! Protects terminate condition variable - static std::mutex terminate_cv_mtx_; - - //! Waits during execution until SIGINT or max_messages_ samples are received - static std::condition_variable terminate_cv_; -}; - - - -#endif /* FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_SERVER_H */ diff --git a/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerSubscriber.h b/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerSubscriber.h deleted file mode 100644 index 071249e7e66..00000000000 --- a/examples/cpp/dds/DiscoveryServerExample/DiscoveryServerSubscriber.h +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file DiscoveryServerSubscriber.h - * - */ - -#ifndef FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_SUBSCRIBER_H -#define FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_SUBSCRIBER_H - -#include -#include -#include - -#include -#include -#include - -#include "common.h" -#include "types/HelloWorld.hpp" - -/** - * Class used to group into a single working unit a Subscriber with a DataReader, its listener, and a TypeSupport member - * corresponding to the HelloWorld datatype - */ -class HelloWorldSubscriber -{ -public: - - HelloWorldSubscriber(); - - virtual ~HelloWorldSubscriber(); - - //! Initialize the subscriber - bool init( - const std::string& topic_name, - uint32_t max_messages, - const std::string& server_address, - unsigned short server_port, - unsigned short server_id, - TransportKind transport); - - //! RUN the subscriber until number samples are received - void run( - uint32_t number); - - //! Return the current state of execution - static bool is_stopped(); - - //! Trigger the end of execution - static void stop(); - -private: - - eprosima::fastdds::dds::DomainParticipant* participant_; - - eprosima::fastdds::dds::Subscriber* subscriber_; - - eprosima::fastdds::dds::Topic* topic_; - - eprosima::fastdds::dds::DataReader* reader_; - - eprosima::fastdds::dds::TypeSupport type_; - - /** - * Class handling discovery and dataflow events - */ - class SubListener : public eprosima::fastdds::dds::DomainParticipantListener - { - public: - - SubListener() - : matched_(0) - , samples_(0) - , max_messages_(0) - { - } - - ~SubListener() override - { - } - - //! Set the maximum number of messages to receive before exiting - void set_max_messages( - uint32_t max_messages); - - //! Callback executed when a new sample is received - void on_data_available( - eprosima::fastdds::dds::DataReader* reader) override; - - //! Callback executed when a DataWriter is matched or unmatched - void on_subscription_matched( - eprosima::fastdds::dds::DataReader* reader, - const eprosima::fastdds::dds::SubscriptionMatchedStatus& info) override; - - //! Callback executed when a DomainParticipant is discovered, dropped or removed - void on_participant_discovery( - eprosima::fastdds::dds::DomainParticipant* /*participant*/, - eprosima::fastdds::rtps::ParticipantDiscoveryInfo&& info, - bool& should_be_ignored) override; - - private: - - using eprosima::fastdds::dds::DomainParticipantListener::on_participant_discovery; - - HelloWorld hello_; - - //! Number of DataWriters matched to the associated DataReader - int matched_; - - //! Number of samples received - uint32_t samples_; - - //! Number of messages to be received before triggering termination of execution - uint32_t max_messages_; - } - listener_; - - //! Member used for control flow purposes - static std::atomic stop_; - - //! Protects terminate condition variable - static std::mutex terminate_cv_mtx_; - - //! Waits during execution until SIGINT or max_messages_ samples are received - static std::condition_variable terminate_cv_; -}; - -#endif /* FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__DISCOVERY_SERVER_SUBSCRIBER_H */ diff --git a/examples/cpp/dds/DiscoveryServerExample/arg_configuration.h b/examples/cpp/dds/DiscoveryServerExample/arg_configuration.h deleted file mode 100644 index 6d8b43b10b8..00000000000 --- a/examples/cpp/dds/DiscoveryServerExample/arg_configuration.h +++ /dev/null @@ -1,382 +0,0 @@ -// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file arg_configuration.h - * - */ - -#ifndef FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__ARG_CONFIGURATION_H -#define FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__ARG_CONFIGURATION_H - -#include -#include -#include - -#include -#include - -#include "common.h" - -namespace option = eprosima::option; - -const std::regex IPv4_REGEX(R"(^((?:[0-9]{1,3}\.){3}[0-9]{1,3})?:?(?:(\d+))?$)"); - -struct Arg : public option::Arg -{ - static void print_error( - const char* msg1, - const option::Option& opt, - const char* msg2) - { - fprintf(stderr, "%s", msg1); - fwrite(opt.name, opt.namelen, 1, stderr); - fprintf(stderr, "%s", msg2); - } - - static option::ArgStatus Unknown( - const option::Option& option, - bool msg) - { - if (msg) - { - print_error("Unknown option '", option, "'\n"); - } - return option::ARG_ILLEGAL; - } - - static option::ArgStatus Required( - const option::Option& option, - bool msg) - { - if (option.arg != 0 && option.arg[0] != 0) - { - return option::ARG_OK; - } - - if (msg) - { - print_error("Option '", option, "' requires an argument\n"); - } - return option::ARG_ILLEGAL; - } - - static option::ArgStatus Numeric( - const option::Option& option, - bool msg) - { - char* endptr = 0; - if (option.arg != 0 && strtol(option.arg, &endptr, 10)) - { - } - if (endptr != option.arg && *endptr == 0) - { - return option::ARG_OK; - } - - if (msg) - { - print_error("Option '", option, "' requires a numeric argument\n"); - } - return option::ARG_ILLEGAL; - } - - static option::ArgStatus String( - const option::Option& option, - bool msg) - { - if (option.arg != 0) - { - return option::ARG_OK; - } - if (msg) - { - print_error("Option '", option, "' requires a string argument\n"); - } - return option::ARG_ILLEGAL; - } - - static option::ArgStatus Locator( - const option::Option& option, - bool msg) - { - if (option.arg != 0) - { - // we must check if it is a correct ip address plus port number - std::string ip_str(option.arg); - if ( - eprosima::fastdds::rtps::IPLocator::isIPv4(ip_str) || - eprosima::fastdds::rtps::IPLocator::isIPv6(ip_str)) - { - return option::ARG_OK; - } - } - if (msg) - { - print_error("Option '", option, "' requires an v4 or v6 argument\n"); - } - return option::ARG_ILLEGAL; - } - - static option::ArgStatus Transport( - const option::Option& option, - bool msg) - { - if (option.arg != 0) - { - // we must check if it is a correct ip address plus port number - std::string transport = std::string(option.arg); - if ( - // transport == "shm" || - transport == "udpv4" || - transport == "udpv6" || - transport == "tcpv4" || - transport == "tcpv6" - ) - { - return option::ARG_OK; - } - } - if (msg) - { - print_error("Option '", option, "' requires a string argument\n"); - } - return option::ARG_ILLEGAL; - } - -}; - -enum optionIndex -{ - UNKNOWN_OPT, - HELP, - - TOPIC, - SAMPLES, - INTERVAL, - TRANSPORT, - - CONNECTION_ADDRESS, - CONNECTION_PORT, - CONNECTION_DISCOVERY_SERVER_ID, - - LISTENING_ADDRESS, - LISTENING_PORT, - LISTENING_DISCOVERY_SERVER_ID, - TIMEOUT, -}; - -const option::Descriptor usage[] = { - {UNKNOWN_OPT, 0, "", "", Arg::None, - "Usage: DiscoveryServerExample \n\nGeneral options:" }, - { - HELP, - 0, - "h", - "help", - Arg::None, - " -h \t--help \tProduce help message." - }, - - /// PUBLISHER OPTIONS - {UNKNOWN_OPT, 0, "", "", Arg::None, "\nPublisher options:"}, - { - TOPIC, - 0, - "t", - "topic", - Arg::String, - " -t \t--topic= \tTopic name (Default: HelloWorldTopic)." - }, - { - SAMPLES, - 0, - "s", - "samples", - Arg::Numeric, - " -s \t--samples= \tNumber of samples to send (Default: 0 => infinite samples)." - }, - { - INTERVAL, - 0, - "i", - "interval", - Arg::Numeric, - " -i \t--interval= \tTime between samples in milliseconds (Default: 100)." - }, - { - CONNECTION_ADDRESS, - 0, - "c", - "connection-address", - Arg::String, - " -c \t--connection-address= \tServer address (Default address: 127.0.0.1)." - }, - { - CONNECTION_PORT, - 0, - "p", - "connection-port", - Arg::Numeric, - " -p \t--connection-port= \tServer listening port (Default port: 16166)." - }, - { - TRANSPORT, - 0, - "", - "transport", - Arg::Transport, - " \t--transport \tUse Transport Protocol [udpv4|udpv6|tcpv4|tcpv6] (UDPv4 by default)." - }, - { - CONNECTION_DISCOVERY_SERVER_ID, - 0, - "d", - "discovery-server-id", - Arg::Numeric, - " -d \t--connection-discovery-server-id \tId of the Discovery Server to connect with. " - "GUID will be calculated from id (0 by default)." - }, - - /// SUBSCRIBER OPTIONS - {UNKNOWN_OPT, 0, "", "", Arg::None, "\nSubscriber options:"}, - { - TOPIC, - 0, - "t", - "topic", - Arg::String, - " -t \t--topic= \tTopic name (Default: HelloWorldTopic)." - }, - { - SAMPLES, - 0, - "s", - "samples", - Arg::Numeric, - " -s \t--samples= \tNumber of samples to send (Default: 0 => infinite samples)." - }, - { - CONNECTION_ADDRESS, - 0, - "c", - "connection-address", - Arg::String, - " -c \t--connection-address= \tServer address (Default address: 127.0.0.1)." - }, - { - CONNECTION_PORT, - 0, - "p", - "connection-port", - Arg::Numeric, - " -p \t--connection-port= \tServer listening port (Default port: 16166)." - }, - { - TRANSPORT, - 0, - "", - "transport", - Arg::Transport, - " \t--transport \tUse Transport Protocol [udpv4|udpv6|tcpv4|tcpv6] (UDPv4 by default)." - }, - { - CONNECTION_DISCOVERY_SERVER_ID, - 0, - "d", - "discovery-server-id", - Arg::Numeric, - " -d \t--connection-discovery-server-id \tId of the Discovery Server to connect with. " - "GUID will be calculated from id (0 by default)." - }, - - /// SERVER OPTIONS - {UNKNOWN_OPT, 0, "", "", Arg::None, "\nDiscovery Server options:"}, - { - LISTENING_ADDRESS, - 0, - "", - "listening-address", - Arg::String, - " \t--listening-address= \tServer address (Default address: 127.0.0.1)." - }, - { - LISTENING_DISCOVERY_SERVER_ID, - 0, - "", - "id", - Arg::Numeric, - " \t--id \tId of this Discovery Server. GUID will be calculated from id (0 by default)." - }, - { - LISTENING_PORT, - 0, - "", - "listening-port", - Arg::Numeric, - " \t--listening-port= \tServer listening port (Default port: 16166)." - }, - { - TRANSPORT, - 0, - "", - "transport", - Arg::Transport, - " \t--transport \tUse Transport Protocol [udpv4|udpv6|tcpv4|tcpv6] (UDPv4 by default)." - }, - { - CONNECTION_PORT, - 0, - "p", - "connection-port", - Arg::Numeric, - " -p \t--connection-port= \tServer listening port (Default port: 16166)." - }, - { - CONNECTION_ADDRESS, - 0, - "c", - "connection-address", - Arg::String, - " -c \t--connection-address= \tServer address (Default address: 127.0.0.1)." - }, - { - CONNECTION_DISCOVERY_SERVER_ID, - 0, - "d", - "connection-discovery-server-id", - Arg::Numeric, - " -d \t--connection-discovery-server-id \tId of the Discovery Server to connect with. " - "GUID will be calculated from id (if not set, this DS will not connect to other server)." - }, - { - TIMEOUT, - 0, - "z", - "timeout", - Arg::Numeric, - " -z \t--timeout \tNumber of seconds before finish the process (Default: 0 = till ^C). " - }, - - { 0, 0, 0, 0, 0, 0 } -}; - -void print_warning( - std::string type, - const char* opt) -{ - std::cerr << "WARNING: " << opt << " is a " << type << " option, ignoring argument." << std::endl; -} - -#endif /* FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__ARG_CONFIGURATION_H */ diff --git a/examples/cpp/discovery_server/ClientPublisherApp.cpp b/examples/cpp/discovery_server/ClientPublisherApp.cpp index a291171372b..953259d07c1 100644 --- a/examples/cpp/discovery_server/ClientPublisherApp.cpp +++ b/examples/cpp/discovery_server/ClientPublisherApp.cpp @@ -21,8 +21,6 @@ #include #include -#include -#include #include #include diff --git a/examples/cpp/discovery_server/ClientPublisherApp.hpp b/examples/cpp/discovery_server/ClientPublisherApp.hpp index bfdd291e2b4..0f88b6c0219 100644 --- a/examples/cpp/discovery_server/ClientPublisherApp.hpp +++ b/examples/cpp/discovery_server/ClientPublisherApp.hpp @@ -28,7 +28,7 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.hpp" +#include "HelloWorld.hpp" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/discovery_server/ClientSubscriberApp.hpp b/examples/cpp/discovery_server/ClientSubscriberApp.hpp index 2d1ddae1fca..82dd38d5f1c 100644 --- a/examples/cpp/discovery_server/ClientSubscriberApp.hpp +++ b/examples/cpp/discovery_server/ClientSubscriberApp.hpp @@ -27,7 +27,7 @@ #include #include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.hpp" +#include "HelloWorld.hpp" #include "Application.hpp" using namespace eprosima::fastdds::dds; From eb4dc8bec8add3357df36c4356de93b232e3310e Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Wed, 10 Jul 2024 10:07:51 +0200 Subject: [PATCH 10/12] Refs #21266: Fix header position and README Signed-off-by: Carlosespicur --- examples/cpp/configuration/Application.hpp | 2 +- examples/cpp/configuration/CLIParser.hpp | 6 +++--- examples/cpp/configuration/PublisherApp.cpp | 3 ++- examples/cpp/configuration/PublisherApp.hpp | 6 +++--- examples/cpp/configuration/SubscriberApp.cpp | 3 ++- examples/cpp/configuration/SubscriberApp.hpp | 6 +++--- examples/cpp/content_filter/Application.hpp | 2 +- examples/cpp/content_filter/CLIParser.hpp | 6 +++--- examples/cpp/content_filter/CustomContentFilter.hpp | 6 +++--- .../cpp/content_filter/CustomContentFilterFactory.hpp | 6 +++--- examples/cpp/content_filter/PublisherApp.cpp | 3 ++- examples/cpp/content_filter/PublisherApp.hpp | 6 +++--- examples/cpp/content_filter/SubscriberApp.cpp | 3 ++- examples/cpp/content_filter/SubscriberApp.hpp | 6 +++--- examples/cpp/custom_payload_pool/Application.hpp | 2 +- examples/cpp/custom_payload_pool/CLIParser.hpp | 6 +++--- examples/cpp/custom_payload_pool/CustomPayloadPool.hpp | 6 +++--- examples/cpp/custom_payload_pool/PublisherApp.cpp | 3 ++- examples/cpp/custom_payload_pool/PublisherApp.hpp | 6 +++--- examples/cpp/custom_payload_pool/SubscriberApp.cpp | 3 ++- examples/cpp/custom_payload_pool/SubscriberApp.hpp | 6 +++--- .../dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp | 4 ++-- .../dds/DynamicHelloWorldExample/HelloWorldPublisher.h | 6 +++--- .../dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp | 5 +++-- .../dds/DynamicHelloWorldExample/HelloWorldSubscriber.h | 6 +++--- .../HelloWorldExampleDataSharing/HelloWorldPublisher.cpp | 3 ++- .../HelloWorldExampleDataSharing/HelloWorldPublisher.h | 6 +++--- .../HelloWorldExampleDataSharing/HelloWorldSubscriber.cpp | 3 ++- .../HelloWorldExampleDataSharing/HelloWorldSubscriber.h | 6 +++--- .../HelloWorldExampleSharedMem/HelloWorldPublisher.cpp | 3 ++- .../dds/HelloWorldExampleSharedMem/HelloWorldPublisher.h | 6 +++--- .../HelloWorldExampleSharedMem/HelloWorldSubscriber.cpp | 2 +- .../dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.h | 6 +++--- .../cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.cpp | 3 ++- .../cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.h | 6 +++--- .../cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.cpp | 2 +- .../cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.h | 6 +++--- .../dds/SecureHelloWorldExample/HelloWorldPublisher.cpp | 3 +++ .../cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.h | 7 +++---- .../dds/SecureHelloWorldExample/HelloWorldSubscriber.cpp | 2 ++ .../dds/SecureHelloWorldExample/HelloWorldSubscriber.h | 8 +++----- .../dds/StaticHelloWorldExample/HelloWorldPublisher.cpp | 3 ++- .../cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.h | 6 +++--- .../dds/StaticHelloWorldExample/HelloWorldSubscriber.cpp | 3 ++- .../dds/StaticHelloWorldExample/HelloWorldSubscriber.h | 6 +++--- .../dds/WriterLoansExample/LoanableHelloWorldPublisher.h | 2 +- .../dds/WriterLoansExample/LoanableHelloWorldSubscriber.h | 2 +- .../cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.h | 2 +- .../dds/ZeroCopyExample/LoanableHelloWorldSubscriber.h | 2 +- examples/cpp/delivery_mechanisms/Application.hpp | 2 +- examples/cpp/delivery_mechanisms/CLIParser.hpp | 6 +++--- examples/cpp/delivery_mechanisms/PubSubApp.cpp | 4 ++-- examples/cpp/delivery_mechanisms/PubSubApp.hpp | 2 +- examples/cpp/delivery_mechanisms/PublisherApp.cpp | 3 ++- examples/cpp/delivery_mechanisms/PublisherApp.hpp | 2 +- examples/cpp/delivery_mechanisms/SubscriberApp.hpp | 2 +- examples/cpp/discovery_server/Application.hpp | 2 +- examples/cpp/discovery_server/ClientPublisherApp.hpp | 2 +- examples/cpp/discovery_server/ClientSubscriberApp.hpp | 2 +- examples/cpp/discovery_server/Helpers.hpp | 6 +++--- examples/cpp/discovery_server/ServerApp.hpp | 2 +- examples/cpp/hello_world/Application.cpp | 1 + examples/cpp/hello_world/Application.hpp | 2 +- examples/cpp/hello_world/CLIParser.hpp | 6 +++--- examples/cpp/hello_world/ListenerSubscriberApp.hpp | 6 +++--- examples/cpp/hello_world/PublisherApp.hpp | 6 +++--- examples/cpp/hello_world/WaitsetSubscriberApp.hpp | 6 +++--- examples/cpp/rtps/AsSocket/TestReaderSocket.h | 6 +++--- examples/cpp/rtps/AsSocket/TestWriterSocket.h | 6 +++--- examples/cpp/rtps/Persistent/TestReaderPersistent.h | 6 +++--- examples/cpp/rtps/Persistent/TestWriterPersistent.h | 6 +++--- examples/cpp/rtps/Registered/TestReaderRegistered.h | 6 +++--- examples/cpp/rtps/Registered/TestWriterRegistered.h | 6 +++--- examples/cpp/security/Application.hpp | 2 +- examples/cpp/security/CLIParser.hpp | 6 +++--- examples/cpp/security/PublisherApp.cpp | 3 ++- examples/cpp/security/PublisherApp.hpp | 6 +++--- examples/cpp/security/README.md | 2 +- examples/cpp/security/SubscriberApp.hpp | 6 +++--- examples/cpp/xtypes/Application.hpp | 2 +- examples/cpp/xtypes/CLIParser.hpp | 6 +++--- examples/cpp/xtypes/PublisherApp.hpp | 6 +++--- examples/cpp/xtypes/SubscriberApp.hpp | 6 +++--- 83 files changed, 188 insertions(+), 170 deletions(-) diff --git a/examples/cpp/configuration/Application.hpp b/examples/cpp/configuration/Application.hpp index 34679fd3dda..eb92a49c6ec 100644 --- a/examples/cpp/configuration/Application.hpp +++ b/examples/cpp/configuration/Application.hpp @@ -52,4 +52,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_CONFIGURATION__APPLICATION_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_CONFIGURATION__APPLICATION_HPP diff --git a/examples/cpp/configuration/CLIParser.hpp b/examples/cpp/configuration/CLIParser.hpp index 4fe1fa61f40..676e20ae090 100644 --- a/examples/cpp/configuration/CLIParser.hpp +++ b/examples/cpp/configuration/CLIParser.hpp @@ -21,8 +21,8 @@ #include #include -#ifndef FASTDDS_EXAMPLES_CPP_CONFIGURATION__CLI_PARSER_HPP -#define FASTDDS_EXAMPLES_CPP_CONFIGURATION__CLI_PARSER_HPP +#ifndef FASTDDS_EXAMPLES_CPP_CONFIGURATION__CLIPARSER_HPP +#define FASTDDS_EXAMPLES_CPP_CONFIGURATION__CLIPARSER_HPP namespace eprosima { namespace fastdds { @@ -1137,4 +1137,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_EXAMPLES_CPP_CONFIGURATION__CLI_PARSER_HPP +#endif // FASTDDS_EXAMPLES_CPP_CONFIGURATION__CLIPARSER_HPP diff --git a/examples/cpp/configuration/PublisherApp.cpp b/examples/cpp/configuration/PublisherApp.cpp index f8f7c7bb1de..96ce454b0e4 100644 --- a/examples/cpp/configuration/PublisherApp.cpp +++ b/examples/cpp/configuration/PublisherApp.cpp @@ -17,6 +17,8 @@ * */ +#include "PublisherApp.hpp" + #include #include #include @@ -34,7 +36,6 @@ #include #include "ConfigurationPubSubTypes.hpp" -#include "PublisherApp.hpp" using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/configuration/PublisherApp.hpp b/examples/cpp/configuration/PublisherApp.hpp index 8e2d520cbbd..7a31e61a34b 100644 --- a/examples/cpp/configuration/PublisherApp.hpp +++ b/examples/cpp/configuration/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_CONFIGURATION__PUBLISHER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_CONFIGURATION__PUBLISHER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_CONFIGURATION__PUBLISHERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_CONFIGURATION__PUBLISHERAPP_HPP #include @@ -118,4 +118,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_CONFIGURATION__PUBLISHER_APP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_CONFIGURATION__PUBLISHERAPP_HPP diff --git a/examples/cpp/configuration/SubscriberApp.cpp b/examples/cpp/configuration/SubscriberApp.cpp index 353f29e87ed..9bf1347b4af 100644 --- a/examples/cpp/configuration/SubscriberApp.cpp +++ b/examples/cpp/configuration/SubscriberApp.cpp @@ -17,6 +17,8 @@ * */ +#include "SubscriberApp.hpp" + #include #include @@ -34,7 +36,6 @@ #include "Application.hpp" #include "CLIParser.hpp" #include "ConfigurationPubSubTypes.hpp" -#include "SubscriberApp.hpp" using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/configuration/SubscriberApp.hpp b/examples/cpp/configuration/SubscriberApp.hpp index 3951e2addf9..b6d71ed198d 100644 --- a/examples/cpp/configuration/SubscriberApp.hpp +++ b/examples/cpp/configuration/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_CONFIGURATION__SUBSCRIBER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_CONFIGURATION__SUBSCRIBER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_CONFIGURATION__SUBSCRIBERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_CONFIGURATION__SUBSCRIBERAPP_HPP #include #include @@ -123,4 +123,4 @@ class SubscriberApp : public Application, public DataReaderListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_CONFIGURATION__SUBSCRIBER_APP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_CONFIGURATION__SUBSCRIBERAPP_HPP diff --git a/examples/cpp/content_filter/Application.hpp b/examples/cpp/content_filter/Application.hpp index d457ffa013a..02c4ab9db5e 100644 --- a/examples/cpp/content_filter/Application.hpp +++ b/examples/cpp/content_filter/Application.hpp @@ -53,4 +53,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__APPLICATION_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__APPLICATION_HPP diff --git a/examples/cpp/content_filter/CLIParser.hpp b/examples/cpp/content_filter/CLIParser.hpp index 7d3845fd4c3..291ce9a2d22 100644 --- a/examples/cpp/content_filter/CLIParser.hpp +++ b/examples/cpp/content_filter/CLIParser.hpp @@ -19,8 +19,8 @@ #include -#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CLI_PARSER_HPP -#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CLI_PARSER_HPP +#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CLIPARSER_HPP +#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CLIPARSER_HPP namespace eprosima { namespace fastdds { @@ -465,4 +465,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CLI_PARSER_HPP +#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CLIPARSER_HPP diff --git a/examples/cpp/content_filter/CustomContentFilter.hpp b/examples/cpp/content_filter/CustomContentFilter.hpp index 661459ab9f2..ae63b9759f3 100644 --- a/examples/cpp/content_filter/CustomContentFilter.hpp +++ b/examples/cpp/content_filter/CustomContentFilter.hpp @@ -1,5 +1,5 @@ -#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOM_CONTENT_FILTER_HPP -#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOM_CONTENT_FILTER_HPP +#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOMCONTENTFILTER_HPP +#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOMCONTENTFILTER_HPP #include @@ -78,4 +78,4 @@ class CustomContentFilter : public eprosima::fastdds::dds::IContentFilter }; -#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOM_CONTENT_FILTER_HPP +#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOMCONTENTFILTER_HPP diff --git a/examples/cpp/content_filter/CustomContentFilterFactory.hpp b/examples/cpp/content_filter/CustomContentFilterFactory.hpp index 1ad1ffb13b5..aed72191c01 100644 --- a/examples/cpp/content_filter/CustomContentFilterFactory.hpp +++ b/examples/cpp/content_filter/CustomContentFilterFactory.hpp @@ -1,5 +1,5 @@ -#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOM_CONTENT_FILTER_FACTORY_HPP -#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOM_CONTENT_FILTER_FACTORY_HPP +#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOMCONTENTFILTERFACTORY_HPP +#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOMCONTENTFILTERFACTORY_HPP #include #include @@ -88,4 +88,4 @@ class CustomContentFilterFactory : public eprosima::fastdds::dds::IContentFilter } }; -#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOM_CONTENT_FILTER_FACTORY_HPP +#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__CUSTOMCONTENTFILTERFACTORY_HPP diff --git a/examples/cpp/content_filter/PublisherApp.cpp b/examples/cpp/content_filter/PublisherApp.cpp index 536518296c2..22d23ff2370 100644 --- a/examples/cpp/content_filter/PublisherApp.cpp +++ b/examples/cpp/content_filter/PublisherApp.cpp @@ -17,6 +17,8 @@ * */ +#include "PublisherApp.hpp" + #include #include @@ -31,7 +33,6 @@ #include "HelloWorldPubSubTypes.hpp" #include "HelloWorldTypeObjectSupport.hpp" -#include "PublisherApp.hpp" namespace eprosima { namespace fastdds { diff --git a/examples/cpp/content_filter/PublisherApp.hpp b/examples/cpp/content_filter/PublisherApp.hpp index c2cf1ccab2b..acc48d63885 100644 --- a/examples/cpp/content_filter/PublisherApp.hpp +++ b/examples/cpp/content_filter/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__PUBLISHER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__PUBLISHER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__PUBLISHERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__PUBLISHERAPP_HPP #include @@ -95,4 +95,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__PUBLISHER_APP_HPP +#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__PUBLISHERAPP_HPP diff --git a/examples/cpp/content_filter/SubscriberApp.cpp b/examples/cpp/content_filter/SubscriberApp.cpp index bbfc7300d4e..9c3dc62cdf9 100644 --- a/examples/cpp/content_filter/SubscriberApp.cpp +++ b/examples/cpp/content_filter/SubscriberApp.cpp @@ -17,6 +17,8 @@ * */ +#include "SubscriberApp.hpp" + #include #include @@ -31,7 +33,6 @@ #include "HelloWorldPubSubTypes.hpp" #include "HelloWorldTypeObjectSupport.hpp" -#include "SubscriberApp.hpp" namespace eprosima { namespace fastdds { diff --git a/examples/cpp/content_filter/SubscriberApp.hpp b/examples/cpp/content_filter/SubscriberApp.hpp index ccbf3e5c32f..256864bead4 100644 --- a/examples/cpp/content_filter/SubscriberApp.hpp +++ b/examples/cpp/content_filter/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__SUBSCRIBER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__SUBSCRIBER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__SUBSCRIBERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__SUBSCRIBERAPP_HPP #include #include @@ -107,4 +107,4 @@ class SubscriberApp : public Application, public DataReaderListener } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__SUBSCRIBER_APP_HPP +#endif // FASTDDS_EXAMPLES_CPP_CONTENT_FILTER__SUBSCRIBERAPP_HPP diff --git a/examples/cpp/custom_payload_pool/Application.hpp b/examples/cpp/custom_payload_pool/Application.hpp index 55c3bf60a3d..fb47bf6810b 100644 --- a/examples/cpp/custom_payload_pool/Application.hpp +++ b/examples/cpp/custom_payload_pool/Application.hpp @@ -53,4 +53,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__APPLICATION_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__APPLICATION_HPP diff --git a/examples/cpp/custom_payload_pool/CLIParser.hpp b/examples/cpp/custom_payload_pool/CLIParser.hpp index b0aea0c03e8..1ad01dc6288 100644 --- a/examples/cpp/custom_payload_pool/CLIParser.hpp +++ b/examples/cpp/custom_payload_pool/CLIParser.hpp @@ -18,8 +18,8 @@ #include -#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CLI_PARSER_HPP -#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CLI_PARSER_HPP +#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CLIPARSER_HPP +#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CLIPARSER_HPP namespace eprosima { namespace fastdds { @@ -329,4 +329,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CLI_PARSER_HPP +#endif // FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CLIPARSER_HPP diff --git a/examples/cpp/custom_payload_pool/CustomPayloadPool.hpp b/examples/cpp/custom_payload_pool/CustomPayloadPool.hpp index 3c1457ea599..22dd6a92cdb 100644 --- a/examples/cpp/custom_payload_pool/CustomPayloadPool.hpp +++ b/examples/cpp/custom_payload_pool/CustomPayloadPool.hpp @@ -16,8 +16,8 @@ * @file CustomPayloadPool.hpp */ -#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CUSTOM_PAYLOAD_POOL_HPP -#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CUSTOM_PAYLOAD_POOL_HPP +#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CUSTOMPAYLOADPOOL_HPP +#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CUSTOMPAYLOADPOOL_HPP #include #include @@ -97,4 +97,4 @@ class CustomPayloadPool : public eprosima::fastdds::rtps::IPayloadPool }; -#endif // FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CUSTOM_PAYLOAD_POOL_HPP +#endif // FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__CUSTOMPAYLOADPOOL_HPP diff --git a/examples/cpp/custom_payload_pool/PublisherApp.cpp b/examples/cpp/custom_payload_pool/PublisherApp.cpp index 0b82b9ddc87..8353c5b3f8d 100644 --- a/examples/cpp/custom_payload_pool/PublisherApp.cpp +++ b/examples/cpp/custom_payload_pool/PublisherApp.cpp @@ -17,6 +17,8 @@ * */ +#include "PublisherApp.hpp" + #include #include @@ -27,7 +29,6 @@ #include #include "HelloWorldPubSubTypes.hpp" -#include "PublisherApp.hpp" using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/custom_payload_pool/PublisherApp.hpp b/examples/cpp/custom_payload_pool/PublisherApp.hpp index ff113eb7b15..3dd31206bc9 100644 --- a/examples/cpp/custom_payload_pool/PublisherApp.hpp +++ b/examples/cpp/custom_payload_pool/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__PUBLISHER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__PUBLISHER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__PUBLISHERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__PUBLISHERAPP_HPP #include #include @@ -103,4 +103,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__PUBLISHER_APP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__PUBLISHERAPP_HPP diff --git a/examples/cpp/custom_payload_pool/SubscriberApp.cpp b/examples/cpp/custom_payload_pool/SubscriberApp.cpp index 7ac4600d1c2..0372b6fa641 100644 --- a/examples/cpp/custom_payload_pool/SubscriberApp.cpp +++ b/examples/cpp/custom_payload_pool/SubscriberApp.cpp @@ -17,6 +17,8 @@ * */ +#include "SubscriberApp.hpp" + #include #include @@ -29,7 +31,6 @@ #include #include "HelloWorldPubSubTypes.hpp" -#include "SubscriberApp.hpp" using namespace eprosima::fastdds::dds; namespace eprosima { diff --git a/examples/cpp/custom_payload_pool/SubscriberApp.hpp b/examples/cpp/custom_payload_pool/SubscriberApp.hpp index 1b7cfb05946..9dc13fa16f3 100644 --- a/examples/cpp/custom_payload_pool/SubscriberApp.hpp +++ b/examples/cpp/custom_payload_pool/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__SUBSCRIBER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__SUBSCRIBER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__SUBSCRIBERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__SUBSCRIBERAPP_HPP #include #include @@ -101,4 +101,4 @@ class SubscriberApp : public Application, public DataReaderListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__SUBSCRIBER_APP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_CUSTOM_PAYLOAD_POOL__SUBSCRIBERAPP_HPP diff --git a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp index 49b6ecee547..c91b27a4c30 100644 --- a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp +++ b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp @@ -17,6 +17,8 @@ * */ +#include "HelloWorldPublisher.h" + #include #include @@ -27,8 +29,6 @@ #include #include -#include "HelloWorldPublisher.h" - using namespace eprosima::fastdds::dds; HelloWorldPublisher::HelloWorldPublisher() diff --git a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.h b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.h index 380e8447535..190b3e28b95 100644 --- a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.h +++ b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_PUBLISHER_H -#define FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_PUBLISHER_H +#ifndef FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLOWORLDPUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLOWORLDPUBLISHER_H #include #include @@ -89,4 +89,4 @@ class HelloWorldPublisher -#endif /* FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_PUBLISHER_H */ +#endif // FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLOWORLDPUBLISHER_H diff --git a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp index 852af105bbf..f65d324a2cf 100644 --- a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp +++ b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp @@ -16,6 +16,9 @@ * @file HelloWorldSubscriber.cpp * */ + +#include "HelloWorldSubscriber.h" + #include #include #include @@ -27,8 +30,6 @@ #include #include -#include "HelloWorldSubscriber.h" - using namespace eprosima::fastdds::dds; HelloWorldSubscriber::HelloWorldSubscriber() diff --git a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.h b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.h index 1dfd166341b..21ad956f5ae 100644 --- a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.h +++ b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_SUBSCRIBER_H -#define FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_SUBSCRIBER_H +#ifndef FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLOWORLDSUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLOWORLDSUBSCRIBER_H #include #include @@ -112,4 +112,4 @@ class HelloWorldSubscriber }; -#endif /* FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_SUBSCRIBER_H */ +#endif // FASTDDS_EXAMPLES_CPP_DDS_DYNAMIC_HELLO_WORLD_EXAMPLE__HELLOWORLDSUBSCRIBER_H diff --git a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.cpp b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.cpp index 0bf073f6bc6..354ca892290 100644 --- a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.cpp +++ b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.cpp @@ -17,6 +17,8 @@ * */ +#include "HelloWorldPublisher.h" + #include #include @@ -25,7 +27,6 @@ #include #include -#include "HelloWorldPublisher.h" #include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.h b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.h index b82241a34df..9b5e4f3135d 100644 --- a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.h +++ b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPublisher.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLO_WORLD_PUBLISHER_H -#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLO_WORLD_PUBLISHER_H +#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLOWORLDPUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLOWORLDPUBLISHER_H #include #include @@ -92,4 +92,4 @@ class HelloWorldPublisher -#endif /* FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLO_WORLD_PUBLISHER_H */ +#endif // FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLOWORLDPUBLISHER_H diff --git a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.cpp b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.cpp index 358783b0df6..aa47451609b 100644 --- a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.cpp +++ b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.cpp @@ -17,6 +17,8 @@ * */ +#include "HelloWorldSubscriber.h" + #include #include @@ -27,7 +29,6 @@ #include #include "HelloWorldPubSubTypes.hpp" -#include "HelloWorldSubscriber.h" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.h b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.h index fdb05f15e11..2aab6e8191a 100644 --- a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.h +++ b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldSubscriber.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLO_WORLD_SUBSCRIBER_H -#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLO_WORLD_SUBSCRIBER_H +#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLOWORLDSUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLOWORLDSUBSCRIBER_H #include #include @@ -87,4 +87,4 @@ class HelloWorldSubscriber listener_; }; -#endif /* FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLO_WORLD_SUBSCRIBER_H */ +#endif // FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_DATA_SHARING__HELLOWORLDSUBSCRIBER_H diff --git a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.cpp b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.cpp index 5d7596583eb..3a538254980 100644 --- a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.cpp +++ b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.cpp @@ -17,13 +17,14 @@ * */ +#include "HelloWorldPublisher.h" + #include #include #include #include -#include "HelloWorldPublisher.h" #include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.h b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.h index 6d70d284f79..0737504e980 100644 --- a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.h +++ b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPublisher.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLO_WORLD_PUBLISHER_H -#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLO_WORLD_PUBLISHER_H +#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLOWORLDPUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLOWORLDPUBLISHER_H #include #include @@ -95,4 +95,4 @@ class HelloWorldPublisher eprosima::fastdds::dds::TypeSupport type_; }; -#endif /* FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLO_WORLD_PUBLISHER_H */ +#endif // FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLOWORLDPUBLISHER_H diff --git a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.cpp b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.cpp index b7bbfc9e92e..d10208fcb27 100644 --- a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.cpp +++ b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.cpp @@ -17,6 +17,7 @@ * */ +#include "HelloWorldSubscriber.h" #include #include @@ -27,7 +28,6 @@ #include #include "HelloWorldPubSubTypes.hpp" -#include "HelloWorldSubscriber.h" using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.h b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.h index da9b4ba2bb3..70e5fee145b 100644 --- a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.h +++ b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldSubscriber.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLO_WORLD_SUBSCRIBER_H -#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLO_WORLD_SUBSCRIBER_H +#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLOWORLDSUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLOWORLDSUBSCRIBER_H #include #include @@ -91,4 +91,4 @@ class HelloWorldSubscriber listener_; }; -#endif /* FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLO_WORLD_SUBSCRIBER_H */ +#endif // FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_SHARED_MEM__HELLOWORLDSUBSCRIBER_H diff --git a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.cpp b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.cpp index 96c5c872e49..a0b8425fbe6 100644 --- a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.cpp +++ b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.cpp @@ -17,13 +17,14 @@ * */ +#include "HelloWorldPublisher.h" + #include #include #include #include -#include "HelloWorldPublisher.h" #include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.h b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.h index fc9b99469ac..915ead5e66d 100644 --- a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.h +++ b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLO_WORLD_PUBLISHER_H -#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLO_WORLD_PUBLISHER_H +#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLOWORLDPUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLOWORLDPUBLISHER_H #include #include @@ -100,4 +100,4 @@ class HelloWorldPublisher -#endif /* FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLO_WORLD_PUBLISHER_H */ +#endif // FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLOWORLDPUBLISHER_H diff --git a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.cpp b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.cpp index e04394a8e20..e7bfbb6f5b2 100644 --- a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.cpp +++ b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.cpp @@ -17,6 +17,7 @@ * */ +#include "HelloWorldSubscriber.h" #include #include @@ -26,7 +27,6 @@ #include #include -#include "HelloWorldSubscriber.h" #include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.h b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.h index ca65e34fec6..30435da8ced 100644 --- a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.h +++ b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldSubscriber.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLO_WORLD_SUBSCRIBER_H -#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLO_WORLD_SUBSCRIBER_H +#ifndef FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLOWORLDSUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLOWORLDSUBSCRIBER_H #include #include @@ -93,4 +93,4 @@ class HelloWorldSubscriber uint32_t number); }; -#endif /* FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLO_WORLD_SUBSCRIBER_H */ +#endif // FASTDDS_EXAMPLES_CPP_DDS_HELLO_WORLD_EXAMPLE_TCP__HELLOWORLDSUBSCRIBER_H diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.cpp b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.cpp index cdeb0036204..b6db716b7f0 100644 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.cpp +++ b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.cpp @@ -18,9 +18,12 @@ */ #include "HelloWorldPublisher.h" + #include #include +#include "HelloWorldPubSubTypes.hpp" + using namespace eprosima::fastdds::dds; HelloWorldPublisher::HelloWorldPublisher() diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.h b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.h index e6a6319826a..e1376bd9191 100644 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.h +++ b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.h @@ -17,10 +17,9 @@ * */ -#ifndef HELLOWORLDPUBLISHER_H_ -#define HELLOWORLDPUBLISHER_H_ +#ifndef FASTDDS_EXAMPLES_CPP_DDS_SECURE_HELLO_WORLD_EXAMPLE__HELLOWORLDPUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_SECURE_HELLO_WORLD_EXAMPLE__HELLOWORLDPUBLISHER_H -#include "HelloWorldPubSubTypes.hpp" #include #include @@ -90,4 +89,4 @@ class HelloWorldPublisher -#endif /* HELLOWORLDPUBLISHER_H_ */ +#endif // FASTDDS_EXAMPLES_CPP_DDS_SECURE_HELLO_WORLD_EXAMPLE__HELLOWORLDPUBLISHER_H diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.cpp b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.cpp index 5d505897f4d..46008b7bfe7 100644 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.cpp +++ b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.cpp @@ -25,6 +25,8 @@ #include #include +#include "HelloWorldPubSubTypes.hpp" + using namespace eprosima::fastdds::dds; HelloWorldSubscriber::HelloWorldSubscriber() diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.h b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.h index e189e33fe0d..da1455248a9 100644 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.h +++ b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.h @@ -17,10 +17,8 @@ * */ -#ifndef HELLOWORLDSUBSCRIBER_H_ -#define HELLOWORLDSUBSCRIBER_H_ - -#include "HelloWorldPubSubTypes.hpp" +#ifndef FASTDDS_EXAMPLES_CPP_DDS_SECURE_HELLO_WORLD_EXAMPLE__HELLOWORLDSUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_SECURE_HELLO_WORLD_EXAMPLE__HELLOWORLDSUBSCRIBER_H #include #include @@ -94,4 +92,4 @@ class HelloWorldSubscriber }; -#endif /* HELLOWORLDSUBSCRIBER_H_ */ +#endif // FASTDDS_EXAMPLES_CPP_DDS_SECURE_HELLO_WORLD_EXAMPLE__HELLOWORLDSUBSCRIBER_H diff --git a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.cpp b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.cpp index 97684f1682e..6a5b40c9ccc 100644 --- a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.cpp +++ b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.cpp @@ -17,6 +17,8 @@ * */ +#include "HelloWorldPublisher.h" + #include #include @@ -24,7 +26,6 @@ #include #include -#include "HelloWorldPublisher.h" #include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.h b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.h index 4d72c2ff120..baa2cc8d917 100644 --- a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.h +++ b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldPublisher.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_PUBLISHER_H -#define FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_PUBLISHER_H +#ifndef FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLOWORLDPUBLISHER_H +#define FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLOWORLDPUBLISHER_H #include #include @@ -85,4 +85,4 @@ class HelloWorldPublisher -#endif /* FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_PUBLISHER_H */ +#endif // FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLOWORLDPUBLISHER_H diff --git a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.cpp b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.cpp index 446da024f66..a133fc30c28 100644 --- a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.cpp +++ b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.cpp @@ -17,6 +17,8 @@ * */ +#include "HelloWorldSubscriber.h" + #include #include @@ -25,7 +27,6 @@ #include #include "HelloWorldPubSubTypes.hpp" -#include "HelloWorldSubscriber.h" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.h b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.h index 828b4a9a7a4..a45e079a2b0 100644 --- a/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.h +++ b/examples/cpp/dds/StaticHelloWorldExample/HelloWorldSubscriber.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_SUBSCRIBER_H -#define FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_SUBSCRIBER_H +#ifndef FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLOWORLDSUBSCRIBER_H +#define FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLOWORLDSUBSCRIBER_H #include #include @@ -90,4 +90,4 @@ class HelloWorldSubscriber }; -#endif /* FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLO_WORLD_SUBSCRIBER_H */ +#endif // FASTDDS_EXAMPLES_CPP_DDS_STATIC_HELLO_WORLD_EXAMPLE__HELLOWORLDSUBSCRIBER_H diff --git a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPublisher.h b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPublisher.h index bf54b57a7c5..ff3aed9410d 100644 --- a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPublisher.h +++ b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPublisher.h @@ -66,4 +66,4 @@ class LoanableHelloWorldPublisher listener_; }; -#endif // FASTDDS_EXAMPLES_CPP_DDS_WRITER_LOANS_EXAMPLE__LOANABLE_HELLO_WORLD_PUBLISHER_H \ No newline at end of file +#endif // FASTDDS_EXAMPLES_CPP_DDS_WRITER_LOANS_EXAMPLE__LOANABLE_HELLO_WORLD_PUBLISHER_H diff --git a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldSubscriber.h b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldSubscriber.h index 6428472be63..bf805fe6469 100644 --- a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldSubscriber.h +++ b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldSubscriber.h @@ -69,4 +69,4 @@ class LoanableHelloWorldSubscriber listener_; }; -#endif // FASTDDS_EXAMPLES_CPP_DDS_WRITER_LOANS_EXAMPLE__LOANABLE_HELLO_WORLD_SUBSCRIBER_H \ No newline at end of file +#endif // FASTDDS_EXAMPLES_CPP_DDS_WRITER_LOANS_EXAMPLE__LOANABLE_HELLO_WORLD_SUBSCRIBER_H diff --git a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.h b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.h index 7afb516ef3f..94b7386ba7e 100644 --- a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.h +++ b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPublisher.h @@ -66,4 +66,4 @@ class LoanableHelloWorldPublisher listener_; }; -#endif // FASTDDS_EXAMPLES_CPP_DDS_ZERO_COPY_EXAMPLE__LOANABLE_HELLO_WORLD_PUBLISHER_H \ No newline at end of file +#endif // FASTDDS_EXAMPLES_CPP_DDS_ZERO_COPY_EXAMPLE__LOANABLE_HELLO_WORLD_PUBLISHER_H diff --git a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldSubscriber.h b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldSubscriber.h index 3d45fbd724d..4b1afdde962 100644 --- a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldSubscriber.h +++ b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldSubscriber.h @@ -69,4 +69,4 @@ class LoanableHelloWorldSubscriber listener_; }; -#endif // FASTDDS_EXAMPLES_CPP_DDS_ZERO_COPY_EXAMPLE__LOANABLE_HELLO_WORLD_SUBSCRIBER_H \ No newline at end of file +#endif // FASTDDS_EXAMPLES_CPP_DDS_ZERO_COPY_EXAMPLE__LOANABLE_HELLO_WORLD_SUBSCRIBER_H diff --git a/examples/cpp/delivery_mechanisms/Application.hpp b/examples/cpp/delivery_mechanisms/Application.hpp index 71e6734df67..26066749693 100644 --- a/examples/cpp/delivery_mechanisms/Application.hpp +++ b/examples/cpp/delivery_mechanisms/Application.hpp @@ -53,4 +53,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__APPLICATION_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__APPLICATION_HPP diff --git a/examples/cpp/delivery_mechanisms/CLIParser.hpp b/examples/cpp/delivery_mechanisms/CLIParser.hpp index 721c9df5fc3..11649e3bb71 100644 --- a/examples/cpp/delivery_mechanisms/CLIParser.hpp +++ b/examples/cpp/delivery_mechanisms/CLIParser.hpp @@ -20,8 +20,8 @@ #include #include -#ifndef FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__CLIPARSERAPP_HPP -#define FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__CLIPARSERAPP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__CLIPARSER_HPP +#define FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__CLIPARSER_HPP namespace eprosima { namespace fastdds { @@ -414,4 +414,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__CLIPARSERAPP_HPP +#endif // FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__CLIPARSER_HPP diff --git a/examples/cpp/delivery_mechanisms/PubSubApp.cpp b/examples/cpp/delivery_mechanisms/PubSubApp.cpp index 09e5f1d0e1a..eab6be79312 100644 --- a/examples/cpp/delivery_mechanisms/PubSubApp.cpp +++ b/examples/cpp/delivery_mechanisms/PubSubApp.cpp @@ -43,8 +43,8 @@ #include "CLIParser.hpp" #include "DeliveryMechanismsPubSubTypes.hpp" -using namespace eprosima::fastdds::rtps; using namespace eprosima::fastdds::dds; +using namespace eprosima::fastdds::rtps; namespace eprosima { namespace fastdds { @@ -119,7 +119,7 @@ PubSubApp::PubSubApp( { // Large Data is a builtin transport pqos.transport().use_builtin_transports = true; - pqos.setup_transports(::BuiltinTransports::LARGE_DATA); + pqos.setup_transports(BuiltinTransports::LARGE_DATA); break; } case CLIParser::DeliveryMechanismKind::TCPv4: diff --git a/examples/cpp/delivery_mechanisms/PubSubApp.hpp b/examples/cpp/delivery_mechanisms/PubSubApp.hpp index 9ee917c505d..95a51f11ed9 100644 --- a/examples/cpp/delivery_mechanisms/PubSubApp.hpp +++ b/examples/cpp/delivery_mechanisms/PubSubApp.hpp @@ -115,4 +115,4 @@ class PubSubApp : public Application, public dds::DataReaderListener, public dds } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__PUBSUBAPP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__PUBSUBAPP_HPP diff --git a/examples/cpp/delivery_mechanisms/PublisherApp.cpp b/examples/cpp/delivery_mechanisms/PublisherApp.cpp index 5a225357a86..ea100372f94 100644 --- a/examples/cpp/delivery_mechanisms/PublisherApp.cpp +++ b/examples/cpp/delivery_mechanisms/PublisherApp.cpp @@ -17,6 +17,8 @@ * */ +#include "PublisherApp.hpp" + #include #include #include @@ -35,7 +37,6 @@ #include #include -#include "PublisherApp.hpp" #include "DeliveryMechanismsPubSubTypes.hpp" using namespace eprosima::fastdds::rtps; diff --git a/examples/cpp/delivery_mechanisms/PublisherApp.hpp b/examples/cpp/delivery_mechanisms/PublisherApp.hpp index acb09e4e0ad..279e03357f5 100644 --- a/examples/cpp/delivery_mechanisms/PublisherApp.hpp +++ b/examples/cpp/delivery_mechanisms/PublisherApp.hpp @@ -94,4 +94,4 @@ class PublisherApp : public Application, public dds::DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__PUBLISHERAPP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__PUBLISHERAPP_HPP diff --git a/examples/cpp/delivery_mechanisms/SubscriberApp.hpp b/examples/cpp/delivery_mechanisms/SubscriberApp.hpp index 7f61dbacdb5..96cc44817d8 100644 --- a/examples/cpp/delivery_mechanisms/SubscriberApp.hpp +++ b/examples/cpp/delivery_mechanisms/SubscriberApp.hpp @@ -94,4 +94,4 @@ class SubscriberApp : public Application, public dds::DataReaderListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__SUBSCRIBERAPP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_DELIVERY_MECHANISMS__SUBSCRIBERAPP_HPP diff --git a/examples/cpp/discovery_server/Application.hpp b/examples/cpp/discovery_server/Application.hpp index 14df294260e..fa966818b8f 100644 --- a/examples/cpp/discovery_server/Application.hpp +++ b/examples/cpp/discovery_server/Application.hpp @@ -52,4 +52,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__APPLICATION_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__APPLICATION_HPP diff --git a/examples/cpp/discovery_server/ClientPublisherApp.hpp b/examples/cpp/discovery_server/ClientPublisherApp.hpp index 0f88b6c0219..9857c4c90e3 100644 --- a/examples/cpp/discovery_server/ClientPublisherApp.hpp +++ b/examples/cpp/discovery_server/ClientPublisherApp.hpp @@ -95,4 +95,4 @@ class ClientPublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__CLIENTPUBLISHERAPP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__CLIENTPUBLISHERAPP_HPP diff --git a/examples/cpp/discovery_server/ClientSubscriberApp.hpp b/examples/cpp/discovery_server/ClientSubscriberApp.hpp index 82dd38d5f1c..6b237e8d776 100644 --- a/examples/cpp/discovery_server/ClientSubscriberApp.hpp +++ b/examples/cpp/discovery_server/ClientSubscriberApp.hpp @@ -94,4 +94,4 @@ class ClientSubscriberApp : public Application, public DataReaderListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__CLIENTSUBSCRIBERAPP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__CLIENTSUBSCRIBERAPP_HPP diff --git a/examples/cpp/discovery_server/Helpers.hpp b/examples/cpp/discovery_server/Helpers.hpp index 6b62890395a..d70b4a13779 100644 --- a/examples/cpp/discovery_server/Helpers.hpp +++ b/examples/cpp/discovery_server/Helpers.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__COMMON_H -#define FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__COMMON_H +#ifndef FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__HELPERS_HPP +#define FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__HELPERS_HPP #include #include @@ -78,4 +78,4 @@ inline std::string get_ip_from_dns( return domain_name; } -#endif /* FASTDDS_EXAMPLES_CPP_DDS_DISCOVERY_SERVER_EXAMPLE__COMMON_H */ +#endif // FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__HELPERS_HPP diff --git a/examples/cpp/discovery_server/ServerApp.hpp b/examples/cpp/discovery_server/ServerApp.hpp index f9eca825559..7e738cd06e7 100644 --- a/examples/cpp/discovery_server/ServerApp.hpp +++ b/examples/cpp/discovery_server/ServerApp.hpp @@ -83,4 +83,4 @@ class ServerApp : public Application, public DomainParticipantListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__SERVERAPP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_DISCOVERY_SERVER__SERVERAPP_HPP diff --git a/examples/cpp/hello_world/Application.cpp b/examples/cpp/hello_world/Application.cpp index 8242de34545..3db1a1ebaa8 100644 --- a/examples/cpp/hello_world/Application.cpp +++ b/examples/cpp/hello_world/Application.cpp @@ -19,6 +19,7 @@ #include "Application.hpp" + #include "CLIParser.hpp" #include "ListenerSubscriberApp.hpp" #include "PublisherApp.hpp" diff --git a/examples/cpp/hello_world/Application.hpp b/examples/cpp/hello_world/Application.hpp index 333273d826d..0978ffd938d 100644 --- a/examples/cpp/hello_world/Application.hpp +++ b/examples/cpp/hello_world/Application.hpp @@ -53,4 +53,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_HELLO_WORLD__APPLICATION_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_HELLO_WORLD__APPLICATION_HPP diff --git a/examples/cpp/hello_world/CLIParser.hpp b/examples/cpp/hello_world/CLIParser.hpp index 47a658bc83d..edd0863e321 100644 --- a/examples/cpp/hello_world/CLIParser.hpp +++ b/examples/cpp/hello_world/CLIParser.hpp @@ -18,8 +18,8 @@ #include -#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__CLI_PARSER_HPP -#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__CLI_PARSER_HPP +#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__CLIPARSER_HPP +#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__CLIPARSER_HPP namespace eprosima { namespace fastdds { @@ -258,4 +258,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_EXAMPLES_CPP_HELLO_WORLD__CLI_PARSER_HPP +#endif // FASTDDS_EXAMPLES_CPP_HELLO_WORLD__CLIPARSER_HPP diff --git a/examples/cpp/hello_world/ListenerSubscriberApp.hpp b/examples/cpp/hello_world/ListenerSubscriberApp.hpp index d39dcc4c31e..6d8978494dd 100644 --- a/examples/cpp/hello_world/ListenerSubscriberApp.hpp +++ b/examples/cpp/hello_world/ListenerSubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__LISTENER_SUBSCRIBER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__LISTENER_SUBSCRIBER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__LISTENERSUBSCRIBERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__LISTENERSUBSCRIBERAPP_HPP #include @@ -95,4 +95,4 @@ class ListenerSubscriberApp : public Application, public DataReaderListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_HELLO_WORLD__LISTENER_SUBSCRIBER_APP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_HELLO_WORLD__LISTENERSUBSCRIBERAPP_HPP diff --git a/examples/cpp/hello_world/PublisherApp.hpp b/examples/cpp/hello_world/PublisherApp.hpp index cfcdcf70ba7..ed62f856780 100644 --- a/examples/cpp/hello_world/PublisherApp.hpp +++ b/examples/cpp/hello_world/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__PUBLISHER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__PUBLISHER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__PUBLISHERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__PUBLISHERAPP_HPP #include @@ -96,4 +96,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_HELLO_WORLD__PUBLISHER_APP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_HELLO_WORLD__PUBLISHERAPP_HPP diff --git a/examples/cpp/hello_world/WaitsetSubscriberApp.hpp b/examples/cpp/hello_world/WaitsetSubscriberApp.hpp index ad290bf64b4..88894a324ae 100644 --- a/examples/cpp/hello_world/WaitsetSubscriberApp.hpp +++ b/examples/cpp/hello_world/WaitsetSubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__WAITSET_SUBSCRIBER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__WAITSET_SUBSCRIBER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_HELLO_WORLD__WAITSETSUBSCRIBERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_HELLO_WORLD__WAITSETSUBSCRIBERAPP_HPP #include #include @@ -88,4 +88,4 @@ class WaitsetSubscriberApp : public Application } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_HELLO_WORLD__WAITSET_SUBSCRIBER_APP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_HELLO_WORLD__WAITSETSUBSCRIBERAPP_HPP diff --git a/examples/cpp/rtps/AsSocket/TestReaderSocket.h b/examples/cpp/rtps/AsSocket/TestReaderSocket.h index fce29a1211e..665074146f1 100644 --- a/examples/cpp/rtps/AsSocket/TestReaderSocket.h +++ b/examples/cpp/rtps/AsSocket/TestReaderSocket.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TEST_READER_SOCKET_H -#define FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TEST_READER_SOCKET_H +#ifndef FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TESTREADERSOCKET_H +#define FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TESTREADERSOCKET_H #include @@ -75,4 +75,4 @@ class TestReaderSocket }; -#endif /* FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TEST_READER_SOCKET_H */ +#endif // FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TESTREADERSOCKET_H diff --git a/examples/cpp/rtps/AsSocket/TestWriterSocket.h b/examples/cpp/rtps/AsSocket/TestWriterSocket.h index e9b21b2dbd8..59c4ea042c7 100644 --- a/examples/cpp/rtps/AsSocket/TestWriterSocket.h +++ b/examples/cpp/rtps/AsSocket/TestWriterSocket.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TEST_WRITER_SOCKET_H -#define FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TEST_WRITER_SOCKET_H +#ifndef FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TESTWRITERSOCKET_H +#define FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TESTWRITERSOCKET_H #include #include @@ -57,4 +57,4 @@ class TestWriterSocket uint16_t nmsgs); }; -#endif /* FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TEST_WRITER_SOCKET_H */ +#endif // FASTDDS_EXAMPLES_CPP_RTPS_AS_SOCKET__TESTWRITERSOCKET_H diff --git a/examples/cpp/rtps/Persistent/TestReaderPersistent.h b/examples/cpp/rtps/Persistent/TestReaderPersistent.h index 33e5e73d49c..3a7b05047d5 100644 --- a/examples/cpp/rtps/Persistent/TestReaderPersistent.h +++ b/examples/cpp/rtps/Persistent/TestReaderPersistent.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TEST_READER_PERSISTENT_H -#define FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TEST_READER_PERSISTENT_H +#ifndef FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TESTREADERPERSISTENT_H +#define FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TESTREADERPERSISTENT_H #include @@ -78,4 +78,4 @@ class TestReaderPersistent m_listener; }; -#endif /* FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TEST_READER_PERSISTENT_H */ +#endif // FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TESTREADERPERSISTENT_H diff --git a/examples/cpp/rtps/Persistent/TestWriterPersistent.h b/examples/cpp/rtps/Persistent/TestWriterPersistent.h index 5e9c813259c..5d1e97a2f6d 100644 --- a/examples/cpp/rtps/Persistent/TestWriterPersistent.h +++ b/examples/cpp/rtps/Persistent/TestWriterPersistent.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TEST_WRITER_PERSISTENT_H -#define FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TEST_WRITER_PERSISTENT_H +#ifndef FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TESTWRITERPERSISTENT_H +#define FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TESTWRITERPERSISTENT_H #include @@ -74,4 +74,4 @@ class TestWriterPersistent m_listener; }; -#endif /* FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TEST_WRITER_PERSISTENT_H */ +#endif // FASTDDS_EXAMPLES_CPP_RTPS_PERSISTENT__TESTWRITERPERSISTENT_H diff --git a/examples/cpp/rtps/Registered/TestReaderRegistered.h b/examples/cpp/rtps/Registered/TestReaderRegistered.h index 8483256cc08..c177224ba3f 100644 --- a/examples/cpp/rtps/Registered/TestReaderRegistered.h +++ b/examples/cpp/rtps/Registered/TestReaderRegistered.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TEST_READER_REGISTERED_H -#define FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TEST_READER_REGISTERED_H +#ifndef FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TESTREADERREGISTERED_H +#define FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TESTREADERREGISTERED_H #include @@ -79,4 +79,4 @@ class TestReaderRegistered m_listener; }; -#endif /* FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TEST_READER_REGISTERED_H */ +#endif // FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TESTREADERREGISTERED_H diff --git a/examples/cpp/rtps/Registered/TestWriterRegistered.h b/examples/cpp/rtps/Registered/TestWriterRegistered.h index 7edb224f860..c9e10e3e6af 100644 --- a/examples/cpp/rtps/Registered/TestWriterRegistered.h +++ b/examples/cpp/rtps/Registered/TestWriterRegistered.h @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TEST_WRITER_REGISTERED_H -#define FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TEST_WRITER_REGISTERED_H +#ifndef FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TESTWRITERREGISTERED_H +#define FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TESTWRITERREGISTERED_H #include @@ -73,4 +73,4 @@ class TestWriterRegistered m_listener; }; -#endif /* FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TEST_WRITER_REGISTERED_H */ +#endif // FASTDDS_EXAMPLES_CPP_RTPS_REGISTERED__TESTWRITERREGISTERED_H diff --git a/examples/cpp/security/Application.hpp b/examples/cpp/security/Application.hpp index 535b84dad08..1fcf49403a8 100644 --- a/examples/cpp/security/Application.hpp +++ b/examples/cpp/security/Application.hpp @@ -53,4 +53,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__APPLICATION_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_SECURITY__APPLICATION_HPP diff --git a/examples/cpp/security/CLIParser.hpp b/examples/cpp/security/CLIParser.hpp index c41aaf1fa86..4e2484698d0 100644 --- a/examples/cpp/security/CLIParser.hpp +++ b/examples/cpp/security/CLIParser.hpp @@ -19,8 +19,8 @@ #include -#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__CLI_PARSER_HPP -#define FASTDDS_EXAMPLES_CPP_SECURITY__CLI_PARSER_HPP +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__CLIPARSER_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__CLIPARSER_HPP namespace eprosima { namespace fastdds { @@ -292,4 +292,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_EXAMPLES_CPP_SECURITY__CLI_PARSER_HPP +#endif // FASTDDS_EXAMPLES_CPP_SECURITY__CLIPARSER_HPP diff --git a/examples/cpp/security/PublisherApp.cpp b/examples/cpp/security/PublisherApp.cpp index dbaf7581541..2650d299509 100644 --- a/examples/cpp/security/PublisherApp.cpp +++ b/examples/cpp/security/PublisherApp.cpp @@ -17,6 +17,8 @@ * */ +#include "PublisherApp.hpp" + #include #include @@ -26,7 +28,6 @@ #include #include -#include "PublisherApp.hpp" #include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; diff --git a/examples/cpp/security/PublisherApp.hpp b/examples/cpp/security/PublisherApp.hpp index 18edbd483de..2b35ddedaf9 100644 --- a/examples/cpp/security/PublisherApp.hpp +++ b/examples/cpp/security/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__PUBLISHER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_SECURITY__PUBLISHER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__PUBLISHERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__PUBLISHERAPP_HPP #include @@ -97,4 +97,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__PUBLISHER_APP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_SECURITY__PUBLISHERAPP_HPP diff --git a/examples/cpp/security/README.md b/examples/cpp/security/README.md index 29489c232a4..c5a436e6ab9 100644 --- a/examples/cpp/security/README.md +++ b/examples/cpp/security/README.md @@ -23,7 +23,7 @@ For simplicity, in this example, the subscriber class inherits from the listener ## Run the example To launch this example, two different terminals are required. -One of them will run the publisher example application, and the other will run the subscriber application. Before running both applications, it is necessary to export the path of the folder where the certificates are located in the environment variable ``CERTS_PATH``: +One of them will run the publisher example application, and the other will run the subscriber application. Before running the applications, it is necessary to export both the path of the folder where the certificates are located in the environment variable ``CERTS_PATH`` and the path to the corresponding xml profile with ``FASTDDS_DEFAULT_PROFILES_FILE`` (see [XML playground](#xml-profile-playground)): * Ubuntu ( / MacOS ) diff --git a/examples/cpp/security/SubscriberApp.hpp b/examples/cpp/security/SubscriberApp.hpp index a24b913bd59..f4a11661a0c 100644 --- a/examples/cpp/security/SubscriberApp.hpp +++ b/examples/cpp/security/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__SUBSCRIBER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_SECURITY__SUBSCRIBER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__SUBSCRIBERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__SUBSCRIBERAPP_HPP #include @@ -95,4 +95,4 @@ class SubscriberApp : public Application, public DataReaderListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__SUBSCRIBER_APP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_SECURITY__SUBSCRIBERAPP_HPP diff --git a/examples/cpp/xtypes/Application.hpp b/examples/cpp/xtypes/Application.hpp index 8fbb766cda4..546e6ffff54 100644 --- a/examples/cpp/xtypes/Application.hpp +++ b/examples/cpp/xtypes/Application.hpp @@ -53,4 +53,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_XTYPES__APPLICATION_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_XTYPES__APPLICATION_HPP diff --git a/examples/cpp/xtypes/CLIParser.hpp b/examples/cpp/xtypes/CLIParser.hpp index 09efafe898c..6b006a0beb3 100644 --- a/examples/cpp/xtypes/CLIParser.hpp +++ b/examples/cpp/xtypes/CLIParser.hpp @@ -18,8 +18,8 @@ #include -#ifndef FASTDDS_EXAMPLES_CPP_XTYPES__CLI_PARSER_HPP -#define FASTDDS_EXAMPLES_CPP_XTYPES__CLI_PARSER_HPP +#ifndef FASTDDS_EXAMPLES_CPP_XTYPES__CLIPARSER_HPP +#define FASTDDS_EXAMPLES_CPP_XTYPES__CLIPARSER_HPP namespace eprosima { namespace fastdds { @@ -246,4 +246,4 @@ class CLIParser } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_EXAMPLES_CPP_XTYPES__CLI_PARSER_HPP +#endif // FASTDDS_EXAMPLES_CPP_XTYPES__CLIPARSER_HPP diff --git a/examples/cpp/xtypes/PublisherApp.hpp b/examples/cpp/xtypes/PublisherApp.hpp index e93ee4f2e49..664dd0e45fa 100644 --- a/examples/cpp/xtypes/PublisherApp.hpp +++ b/examples/cpp/xtypes/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_XTYPES__PUBLISHER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_XTYPES__PUBLISHER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_XTYPES__PUBLISHERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_XTYPES__PUBLISHERAPP_HPP #include @@ -115,4 +115,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_XTYPES__PUBLISHER_APP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_XTYPES__PUBLISHERAPP_HPP diff --git a/examples/cpp/xtypes/SubscriberApp.hpp b/examples/cpp/xtypes/SubscriberApp.hpp index 73e21d80538..c4e18ccda76 100644 --- a/examples/cpp/xtypes/SubscriberApp.hpp +++ b/examples/cpp/xtypes/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTDDS_EXAMPLES_CPP_XTYPES__SUBSCRIBER_APP_HPP -#define FASTDDS_EXAMPLES_CPP_XTYPES__SUBSCRIBER_APP_HPP +#ifndef FASTDDS_EXAMPLES_CPP_XTYPES__SUBSCRIBERAPP_HPP +#define FASTDDS_EXAMPLES_CPP_XTYPES__SUBSCRIBERAPP_HPP #include @@ -112,4 +112,4 @@ class SubscriberApp : public Application, public DomainParticipantListener } // namespace fastdds } // namespace eprosima -#endif /* FASTDDS_EXAMPLES_CPP_XTYPES__SUBSCRIBER_APP_HPP */ +#endif // FASTDDS_EXAMPLES_CPP_XTYPES__SUBSCRIBERAPP_HPP From 1f74591eebfb2ca5e556dd81863e7881e8d20c4c Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Thu, 11 Jul 2024 16:28:07 +0200 Subject: [PATCH 11/12] Refs #21266: Remove old SecureHelloWorldExample and modify examples CMakeLists Signed-off-by: Carlosespicur --- examples/CMakeLists.txt | 5 +- examples/cpp/dds/CMakeLists.txt | 4 - .../dds/SecureHelloWorldExample/.gitignore | 2 - .../SecureHelloWorldExample/CMakeLists.txt | 60 ----- .../SecureHelloWorldExample/HelloWorld.hpp | 227 ----------------- .../SecureHelloWorldExample/HelloWorld.idl | 5 - .../HelloWorldCdrAux.hpp | 46 ---- .../HelloWorldCdrAux.ipp | 126 ---------- .../HelloWorldPubSubTypes.cxx | 229 ------------------ .../HelloWorldPubSubTypes.hpp | 133 ---------- .../HelloWorldPublisher.cpp | 174 ------------- .../HelloWorldPublisher.h | 92 ------- .../HelloWorldSubscriber.cpp | 173 ------------- .../HelloWorldSubscriber.h | 95 -------- .../HelloWorldTypeObjectSupport.cxx | 138 ----------- .../HelloWorldTypeObjectSupport.hpp | 56 ----- .../HelloWorld_main.cpp | 77 ------ .../dds/SecureHelloWorldExample/README.txt | 10 - .../certs/governance.smime | 71 ------ .../certs/governance_dds_sec.xml | 30 --- .../certs/maincacert.pem | 14 -- .../certs/maincakey.pem | 5 - .../certs/mainpubcert.pem | 44 ---- .../certs/mainpubkey.pem | 5 - .../certs/mainsubcert.pem | 44 ---- .../certs/mainsubkey.pem | 5 - .../certs/permissions.smime | 88 ------- .../certs/permissions_dds_sec.xml | 47 ---- examples/cpp/hello_world/Application.cpp | 1 - test/examples/CMakeLists.txt | 5 + 30 files changed, 9 insertions(+), 2002 deletions(-) delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/.gitignore delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/CMakeLists.txt delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorld.hpp delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorld.idl delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorldCdrAux.hpp delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorldCdrAux.ipp delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorldPubSubTypes.hpp delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.cpp delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.h delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.cpp delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.h delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorldTypeObjectSupport.cxx delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/HelloWorld_main.cpp delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/README.txt delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/certs/governance.smime delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/certs/governance_dds_sec.xml delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/certs/maincacert.pem delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/certs/maincakey.pem delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/certs/mainpubcert.pem delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/certs/mainpubkey.pem delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/certs/mainsubcert.pem delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/certs/mainsubkey.pem delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/certs/permissions.smime delete mode 100644 examples/cpp/dds/SecureHelloWorldExample/certs/permissions_dds_sec.xml diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index cd617f0a616..0e302bf89dd 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -20,7 +20,10 @@ add_subdirectory(cpp/custom_payload_pool) add_subdirectory(cpp/dds) add_subdirectory(cpp/delivery_mechanisms) add_subdirectory(cpp/discovery_server) -add_subdirectory(cpp/security) add_subdirectory(cpp/hello_world) add_subdirectory(cpp/rtps) add_subdirectory(cpp/xtypes) + +if (SECURITY) + add_subdirectory(cpp/security) +endif() diff --git a/examples/cpp/dds/CMakeLists.txt b/examples/cpp/dds/CMakeLists.txt index 32ea44c1f70..19f83e1edea 100644 --- a/examples/cpp/dds/CMakeLists.txt +++ b/examples/cpp/dds/CMakeLists.txt @@ -22,7 +22,3 @@ add_subdirectory(RequestReplyExample) add_subdirectory(StaticHelloWorldExample) add_subdirectory(WriterLoansExample) add_subdirectory(ZeroCopyExample) - -if(SECURITY) - add_subdirectory(SecureHelloWorldExample) -endif() diff --git a/examples/cpp/dds/SecureHelloWorldExample/.gitignore b/examples/cpp/dds/SecureHelloWorldExample/.gitignore deleted file mode 100644 index ffc5570a9c3..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -bin -output diff --git a/examples/cpp/dds/SecureHelloWorldExample/CMakeLists.txt b/examples/cpp/dds/SecureHelloWorldExample/CMakeLists.txt deleted file mode 100644 index 237263af779..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cmake_minimum_required(VERSION 3.20) - -project(SecureHelloWorldExample VERSION 1 LANGUAGES CXX) - -# Find requirements -if(NOT fastcdr_FOUND) - find_package(fastcdr 2 REQUIRED) -endif() - -if(NOT foonathan_memory_FOUND) - find_package(foonathan_memory REQUIRED) -endif() - -if(NOT fastdds_FOUND) - find_package(fastdds 3 REQUIRED) -endif() - -#Check C++11 -include(CheckCXXCompilerFlag) -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - check_cxx_compiler_flag(-std=c++11 SUPPORTS_CXX11) - if(NOT SUPPORTS_CXX11) - message(FATAL_ERROR "Compiler doesn't support C++11") - endif() -endif() - -message(STATUS "Configuring DDSSecureHelloWorld example...") -file(GLOB DDS_SECURE_HELLOWORLD_EXAMPLE_SOURCES_CXX "*.cxx") -file(GLOB DDS_SECURE_HELLOWORLD_EXAMPLE_SOURCES_CPP "*.cpp") - -add_executable(DDSSecureHelloWorldExample ${DDS_SECURE_HELLOWORLD_EXAMPLE_SOURCES_CXX} ${DDS_SECURE_HELLOWORLD_EXAMPLE_SOURCES_CPP}) -target_compile_definitions(DDSSecureHelloWorldExample PRIVATE - $<$>,$>:__DEBUG> - $<$:__INTERNALDEBUG> # Internal debug activated. - ) -target_include_directories(DDSSecureHelloWorldExample PRIVATE) -target_link_libraries(DDSSecureHelloWorldExample fastdds fastcdr foonathan_memory) -install(TARGETS DDSSecureHelloWorldExample - RUNTIME DESTINATION examples/cpp/dds/SecureHelloWorldExample/${BIN_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_SOURCE_DIR}/certs - DESTINATION examples/cpp/dds/SecureHelloWorldExample/${BIN_INSTALL_DIR}) - -add_custom_command(TARGET DDSSecureHelloWorldExample POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${PROJECT_SOURCE_DIR}/certs - ${PROJECT_BINARY_DIR}/certs) diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorld.hpp b/examples/cpp/dds/SecureHelloWorldExample/HelloWorld.hpp deleted file mode 100644 index 46d0d7b5814..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorld.hpp +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * @file HelloWorld.hpp - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef FAST_DDS_GENERATED__HELLOWORLD_HPP -#define FAST_DDS_GENERATED__HELLOWORLD_HPP - -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(HELLOWORLD_SOURCE) -#define HELLOWORLD_DllAPI __declspec( dllexport ) -#else -#define HELLOWORLD_DllAPI __declspec( dllimport ) -#endif // HELLOWORLD_SOURCE -#else -#define HELLOWORLD_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define HELLOWORLD_DllAPI -#endif // _WIN32 - -/*! - * @brief This class represents the structure HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorld -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport HelloWorld() - { - } - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~HelloWorld() - { - } - - /*! - * @brief Copy constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - const HelloWorld& x) - { - m_index = x.m_index; - - m_message = x.m_message; - - } - - /*! - * @brief Move constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept - { - m_index = x.m_index; - m_message = std::move(x.m_message); - } - - /*! - * @brief Copy assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x) - { - - m_index = x.m_index; - - m_message = x.m_message; - - return *this; - } - - /*! - * @brief Move assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept - { - - m_index = x.m_index; - m_message = std::move(x.m_message); - return *this; - } - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const - { - return (m_index == x.m_index && - m_message == x.m_message); - } - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator !=( - const HelloWorld& x) const - { - return !(*this == x); - } - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index) - { - m_index = _index; - } - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const - { - return m_index; - } - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index() - { - return m_index; - } - - - /*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ - eProsima_user_DllExport void message( - const std::string& _message) - { - m_message = _message; - } - - /*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ - eProsima_user_DllExport void message( - std::string&& _message) - { - m_message = std::move(_message); - } - - /*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ - eProsima_user_DllExport const std::string& message() const - { - return m_message; - } - - /*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ - eProsima_user_DllExport std::string& message() - { - return m_message; - } - - - -private: - - uint32_t m_index{0}; - std::string m_message; - -}; - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_HPP_ - - diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorld.idl b/examples/cpp/dds/SecureHelloWorldExample/HelloWorld.idl deleted file mode 100644 index 0fd2c355aee..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorld.idl +++ /dev/null @@ -1,5 +0,0 @@ -struct HelloWorld -{ - unsigned long index; - string message; -}; diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldCdrAux.hpp b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldCdrAux.hpp deleted file mode 100644 index 1164cd5cce1..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldCdrAux.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * @file HelloWorldCdrAux.hpp - * This source file contains some definitions of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP -#define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP - -#include "HelloWorld.hpp" - -constexpr uint32_t HelloWorld_max_cdr_typesize {268UL}; -constexpr uint32_t HelloWorld_max_key_cdr_typesize {0UL}; - - -namespace eprosima { -namespace fastcdr { - -class Cdr; -class CdrSizeCalculator; - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const HelloWorld& data); - - -} // namespace fastcdr -} // namespace eprosima - -#endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP - diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldCdrAux.ipp b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldCdrAux.ipp deleted file mode 100644 index 19316df7d3c..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldCdrAux.ipp +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * @file HelloWorldCdrAux.ipp - * This source file contains some declarations of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP -#define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP - -#include "HelloWorldCdrAux.hpp" - -#include -#include - - -#include -using namespace eprosima::fastcdr::exception; - -namespace eprosima { -namespace fastcdr { - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const HelloWorld& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.index(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.message(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const HelloWorld& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.index() - << eprosima::fastcdr::MemberId(1) << data.message() -; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - HelloWorld& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.index(); - break; - - case 1: - dcdr >> data.message(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const HelloWorld& data) -{ - static_cast(scdr); - static_cast(data); -} - - - -} // namespace fastcdr -} // namespace eprosima - -#endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP - diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx deleted file mode 100644 index 38393dbf8c9..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * @file HelloWorldPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "HelloWorldPubSubTypes.hpp" - -#include -#include - -#include "HelloWorldCdrAux.hpp" -#include "HelloWorldTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -HelloWorldPubSubType::HelloWorldPubSubType() -{ - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -HelloWorldPubSubType::~HelloWorldPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool HelloWorldPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - const HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function HelloWorldPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* HelloWorldPubSubType::createData() -{ - return reinterpret_cast(new HelloWorld()); -} - -void HelloWorldPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool HelloWorldPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - const HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - HelloWorld_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void HelloWorldPubSubType::register_type_object_representation() -{ - register_HelloWorld_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "HelloWorldCdrAux.ipp" diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPubSubTypes.hpp b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPubSubTypes.hpp deleted file mode 100644 index 556d4c05ecf..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPubSubTypes.hpp +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * @file HelloWorldPubSubTypes.hpp - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP -#define FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP - -#include -#include -#include -#include -#include - -#include "HelloWorld.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - -/*! - * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef HelloWorld type; - - eProsima_user_DllExport HelloWorldPubSubType(); - - eProsima_user_DllExport ~HelloWorldPubSubType() override; - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - const void* const data, - eprosima::fastdds::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP - diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.cpp b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.cpp deleted file mode 100644 index b6db716b7f0..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.cpp +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file HelloWorldPublisher.cpp - * - */ - -#include "HelloWorldPublisher.h" - -#include -#include - -#include "HelloWorldPubSubTypes.hpp" - -using namespace eprosima::fastdds::dds; - -HelloWorldPublisher::HelloWorldPublisher() - : participant_(nullptr) - , publisher_(nullptr) - , topic_(nullptr) - , writer_(nullptr) - , type_(new HelloWorldPubSubType()) -{ -} - -bool HelloWorldPublisher::init() -{ - hello_.index(0); - hello_.message("HelloWorld"); - - //CREATE THE PARTICIPANT - DomainParticipantQos pqos; - pqos.properties().properties().emplace_back("dds.sec.auth.plugin", - "builtin.PKI-DH"); - pqos.properties().properties().emplace_back("dds.sec.auth.builtin.PKI-DH.identity_ca", - "file://certs/maincacert.pem"); - pqos.properties().properties().emplace_back("dds.sec.auth.builtin.PKI-DH.identity_certificate", - "file://certs/mainpubcert.pem"); - pqos.properties().properties().emplace_back("dds.sec.auth.builtin.PKI-DH.private_key", - "file://certs/mainpubkey.pem"); - pqos.properties().properties().emplace_back("dds.sec.access.plugin", - "builtin.Access-Permissions"); - pqos.properties().properties().emplace_back("dds.sec.access.builtin.Access-Permissions.permissions_ca", - "file://certs/maincacert.pem"); - pqos.properties().properties().emplace_back("dds.sec.access.builtin.Access-Permissions.governance", - "file://certs/governance.smime"); - pqos.properties().properties().emplace_back("dds.sec.access.builtin.Access-Permissions.permissions", - "file://certs/permissions.smime"); - pqos.properties().properties().emplace_back("dds.sec.crypto.plugin", - "builtin.AES-GCM-GMAC"); - - participant_ = DomainParticipantFactory::get_instance()->create_participant(0, pqos); - - if (participant_ == nullptr) - { - return false; - } - - //REGISTER THE TYPE - type_.register_type(participant_); - - //CREATE THE PUBLISHER - publisher_ = participant_->create_publisher(PUBLISHER_QOS_DEFAULT); - - if (publisher_ == nullptr) - { - return false; - } - - //CREATE THE TOPIC - topic_ = participant_->create_topic("HelloWorldTopic", "HelloWorld", TOPIC_QOS_DEFAULT); - - if (topic_ == nullptr) - { - return false; - } - - //CREATE THE DATAWRITER - DataWriterQos wqos; - wqos.reliability().kind = RELIABLE_RELIABILITY_QOS; - wqos.history().kind = KEEP_LAST_HISTORY_QOS; - wqos.history().depth = 20; - wqos.resource_limits().max_samples = 50; - wqos.resource_limits().max_samples_per_instance = 20; - wqos.reliable_writer_qos().times.heartbeat_period.seconds = 2; - wqos.reliable_writer_qos().times.heartbeat_period.nanosec = 200 * 1000 * 1000; - writer_ = publisher_->create_datawriter(topic_, wqos, &listener_); - - if (writer_ == nullptr) - { - return false; - } - - return true; - -} - -HelloWorldPublisher::~HelloWorldPublisher() -{ - if (writer_ != nullptr) - { - publisher_->delete_datawriter(writer_); - } - if (publisher_ != nullptr) - { - participant_->delete_publisher(publisher_); - } - if (topic_ != nullptr) - { - participant_->delete_topic(topic_); - } - DomainParticipantFactory::get_instance()->delete_participant(participant_); -} - -void HelloWorldPublisher::PubListener::on_publication_matched( - eprosima::fastdds::dds::DataWriter*, - const eprosima::fastdds::dds::PublicationMatchedStatus& info) -{ - if (info.current_count_change == 1) - { - matched_ = info.total_count; - first_connected_ = true; - std::cout << "Publisher matched." << std::endl; - } - else if (info.current_count_change == -1) - { - matched_ = info.total_count; - std::cout << "Publisher unmatched." << std::endl; - } - else - { - std::cout << info.current_count_change - << " is not a valid value for PublicationMatchedStatus current count change" << std::endl; - } -} - -void HelloWorldPublisher::run( - uint32_t samples) -{ - for (uint32_t i = 0; i < samples; ++i) - { - if (!publish()) - { - --i; - } - else - { - std::cout << "Message: " << hello_.message() << " with index: " << hello_.index() << " SENT" << std::endl; - } - } -} - -bool HelloWorldPublisher::publish() -{ - if (listener_.matched_ > 0 || listener_.first_connected_) - { - hello_.index(hello_.index() + 1); - writer_->write(&hello_); - return true; - } - return false; -} diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.h b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.h deleted file mode 100644 index e1376bd9191..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldPublisher.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file HelloWorldPublisher.h - * - */ - -#ifndef FASTDDS_EXAMPLES_CPP_DDS_SECURE_HELLO_WORLD_EXAMPLE__HELLOWORLDPUBLISHER_H -#define FASTDDS_EXAMPLES_CPP_DDS_SECURE_HELLO_WORLD_EXAMPLE__HELLOWORLDPUBLISHER_H - - -#include -#include -#include -#include -#include -#include - -#include "HelloWorld.hpp" - -class HelloWorldPublisher -{ -public: - - HelloWorldPublisher(); - - virtual ~HelloWorldPublisher(); - - //!Initialize - bool init(); - - //!Publish a sample - bool publish(); - - //!Run for number samples - void run( - uint32_t number); - -private: - - HelloWorld hello_; - - eprosima::fastdds::dds::DomainParticipant* participant_; - - eprosima::fastdds::dds::Publisher* publisher_; - - eprosima::fastdds::dds::Topic* topic_; - - eprosima::fastdds::dds::DataWriter* writer_; - - class PubListener : public eprosima::fastdds::dds::DataWriterListener - { - public: - - PubListener() - : matched_(0) - , first_connected_(false) - { - } - - ~PubListener() override - { - } - - void on_publication_matched( - eprosima::fastdds::dds::DataWriter* writer, - const eprosima::fastdds::dds::PublicationMatchedStatus& info) override; - - int matched_; - - bool first_connected_; - } - listener_; - - eprosima::fastdds::dds::TypeSupport type_; -}; - - - -#endif // FASTDDS_EXAMPLES_CPP_DDS_SECURE_HELLO_WORLD_EXAMPLE__HELLOWORLDPUBLISHER_H diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.cpp b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.cpp deleted file mode 100644 index 46008b7bfe7..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.cpp +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file HelloWorldSubscriber.cpp - * - */ - -#include "HelloWorldSubscriber.h" - -#include -#include - -#include -#include - -#include "HelloWorldPubSubTypes.hpp" - -using namespace eprosima::fastdds::dds; - -HelloWorldSubscriber::HelloWorldSubscriber() - : participant_(nullptr) - , subscriber_(nullptr) - , topic_(nullptr) - , reader_(nullptr) - , type_(new HelloWorldPubSubType()) -{ -} - -bool HelloWorldSubscriber::init() -{ - //CREATE THE PARTICIPANT - DomainParticipantQos pqos; - - pqos.properties().properties().emplace_back("dds.sec.auth.plugin", - "builtin.PKI-DH"); - pqos.properties().properties().emplace_back("dds.sec.auth.builtin.PKI-DH.identity_ca", - "file://certs/maincacert.pem"); - pqos.properties().properties().emplace_back("dds.sec.auth.builtin.PKI-DH.identity_certificate", - "file://certs/mainsubcert.pem"); - pqos.properties().properties().emplace_back("dds.sec.auth.builtin.PKI-DH.private_key", - "file://certs/mainsubkey.pem"); - pqos.properties().properties().emplace_back("dds.sec.access.plugin", - "builtin.Access-Permissions"); - pqos.properties().properties().emplace_back( - "dds.sec.access.builtin.Access-Permissions.permissions_ca", - "file://certs/maincacert.pem"); - pqos.properties().properties().emplace_back( - "dds.sec.access.builtin.Access-Permissions.governance", - "file://certs/governance.smime"); - pqos.properties().properties().emplace_back( - "dds.sec.access.builtin.Access-Permissions.permissions", - "file://certs/permissions.smime"); - pqos.properties().properties().emplace_back("dds.sec.crypto.plugin", - "builtin.AES-GCM-GMAC"); - - participant_ = DomainParticipantFactory::get_instance()->create_participant(0, pqos); - - if (participant_ == nullptr) - { - return false; - } - - //REGISTER THE TYPE - type_.register_type(participant_); - - //CREATE THE SUBSCRIBER - subscriber_ = participant_->create_subscriber(SUBSCRIBER_QOS_DEFAULT); - - if (subscriber_ == nullptr) - { - return false; - } - - //CREATE THE TOPIC - topic_ = participant_->create_topic("HelloWorldTopic", "HelloWorld", TOPIC_QOS_DEFAULT); - //CREATE THE DATAREADER - DataReaderQos rqos; - rqos.history().kind = KEEP_LAST_HISTORY_QOS; - rqos.history().depth = 30; - rqos.resource_limits().max_samples = 50; - rqos.resource_limits().allocated_samples = 20; - rqos.reliability().kind = RELIABLE_RELIABILITY_QOS; - - reader_ = subscriber_->create_datareader(topic_, rqos, &listener_); - - if (reader_ == nullptr) - { - return false; - } - - return true; -} - -HelloWorldSubscriber::~HelloWorldSubscriber() -{ - if (reader_ != nullptr) - { - subscriber_->delete_datareader(reader_); - } - if (topic_ != nullptr) - { - participant_->delete_topic(topic_); - } - if (subscriber_ != nullptr) - { - participant_->delete_subscriber(subscriber_); - } - DomainParticipantFactory::get_instance()->delete_participant(participant_); -} - -void HelloWorldSubscriber::SubListener::on_subscription_matched( - DataReader*, - const SubscriptionMatchedStatus& info) -{ - if (info.current_count_change == 1) - { - matched_ = info.total_count; - std::cout << "Subscriber matched." << std::endl; - } - else if (info.current_count_change == -1) - { - matched_ = info.total_count; - std::cout << "Subscriber unmatched." << std::endl; - } - else - { - std::cout << info.current_count_change - << " is not a valid value for SubscriptionMatchedStatus current count change" << std::endl; - } -} - -void HelloWorldSubscriber::SubListener::on_data_available( - DataReader* reader) -{ - SampleInfo info; - if (reader->take_next_sample(&hello_, &info) == RETCODE_OK) - { - if (info.instance_state == ALIVE_INSTANCE_STATE) - { - samples_++; - // Print your structure data here. - std::cout << "Message " << hello_.message() << " " << hello_.index() << " RECEIVED" << std::endl; - } - } -} - -void HelloWorldSubscriber::run() -{ - std::cout << "Subscriber running. Please press enter to stop the Subscriber" << std::endl; - std::cin.ignore(); -} - -void HelloWorldSubscriber::run( - uint32_t number) -{ - std::cout << "Subscriber running until " << number << "samples have been received" << std::endl; - while (number < this->listener_.samples_) - { - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - } -} diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.h b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.h deleted file mode 100644 index da1455248a9..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldSubscriber.h +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file HelloWorldSubscriber.h - * - */ - -#ifndef FASTDDS_EXAMPLES_CPP_DDS_SECURE_HELLO_WORLD_EXAMPLE__HELLOWORLDSUBSCRIBER_H -#define FASTDDS_EXAMPLES_CPP_DDS_SECURE_HELLO_WORLD_EXAMPLE__HELLOWORLDSUBSCRIBER_H - -#include -#include -#include -#include -#include - -#include "HelloWorld.hpp" - -class HelloWorldSubscriber -{ -public: - - HelloWorldSubscriber(); - - virtual ~HelloWorldSubscriber(); - - //!Initialize the subscriber - bool init(); - - //!RUN the subscriber - void run(); - - //!Run the subscriber until number samples have been received. - void run( - uint32_t number); - -private: - - eprosima::fastdds::dds::DomainParticipant* participant_; - - eprosima::fastdds::dds::Subscriber* subscriber_; - - eprosima::fastdds::dds::Topic* topic_; - - eprosima::fastdds::dds::DataReader* reader_; - - eprosima::fastdds::dds::TypeSupport type_; - -public: - - class SubListener : public eprosima::fastdds::dds::DataReaderListener - { - public: - - SubListener() - : matched_(0) - , samples_(0) - { - } - - ~SubListener() override - { - } - - void on_data_available( - eprosima::fastdds::dds::DataReader* reader) override; - - void on_subscription_matched( - eprosima::fastdds::dds::DataReader* reader, - const eprosima::fastdds::dds::SubscriptionMatchedStatus& info) override; - - HelloWorld hello_; - - int matched_; - - uint32_t samples_; - - } - listener_; - -}; - -#endif // FASTDDS_EXAMPLES_CPP_DDS_SECURE_HELLO_WORLD_EXAMPLE__HELLOWORLDSUBSCRIBER_H diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldTypeObjectSupport.cxx b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldTypeObjectSupport.cxx deleted file mode 100644 index 58928b6f057..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldTypeObjectSupport.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * @file HelloWorldTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "HelloWorldTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "HelloWorld.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_HelloWorld_type_identifier( - TypeIdentifierPair& type_ids_HelloWorld) -{ - - ReturnCode_t return_code_HelloWorld {eprosima::fastdds::dds::RETCODE_OK}; - return_code_HelloWorld = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "HelloWorld", type_ids_HelloWorld); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_HelloWorld) - { - StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, - false, false); - QualifiedTypeName type_name_HelloWorld = "HelloWorld"; - eprosima::fastcdr::optional type_ann_builtin_HelloWorld; - eprosima::fastcdr::optional ann_custom_HelloWorld; - CompleteTypeDetail detail_HelloWorld = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_HelloWorld, ann_custom_HelloWorld, type_name_HelloWorld.to_string()); - CompleteStructHeader header_HelloWorld; - header_HelloWorld = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_HelloWorld); - CompleteStructMemberSeq member_seq_HelloWorld; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint32_t", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_HelloWorld.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_HelloWorld); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_index); - } - { - TypeIdentifierPair type_ids_message; - ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_unbounded", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - { - SBound bound = 0; - StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, - "anonymous_string_unbounded", type_ids_message)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, - false, false, false, false); - MemberId member_id_message = 0x00000001; - bool common_message_ec {false}; - CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; - if (!common_message_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); - return; - } - MemberName name_message = "message"; - eprosima::fastcdr::optional member_ann_builtin_message; - ann_custom_HelloWorld.reset(); - CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_HelloWorld); - CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); - TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_message); - } - CompleteStructType struct_type_HelloWorld = TypeObjectUtils::build_complete_struct_type(struct_flags_HelloWorld, header_HelloWorld, member_seq_HelloWorld); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_ids_HelloWorld)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "HelloWorld already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp b/examples/cpp/dds/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp deleted file mode 100644 index ec922163d11..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * @file HelloWorldTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP -#define FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP - -#include - - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register HelloWorld related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_HelloWorld_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP diff --git a/examples/cpp/dds/SecureHelloWorldExample/HelloWorld_main.cpp b/examples/cpp/dds/SecureHelloWorldExample/HelloWorld_main.cpp deleted file mode 100644 index 91394aad3ee..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/HelloWorld_main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file HelloWorld_main.cpp - * - */ - -#include - -#include "HelloWorldPublisher.h" -#include "HelloWorldSubscriber.h" - -using namespace eprosima; -using namespace fastdds; -using namespace rtps; -using namespace eprosima::fastdds::dds; - -int main( - int argc, - char** argv) -{ - std::cout << "Starting " << std::endl; - int type = 1; - if (argc > 1) - { - if (strcmp(argv[1], "publisher") == 0) - { - type = 1; - } - else if (strcmp(argv[1], "subscriber") == 0) - { - type = 2; - } - } - else - { - std::cout << "publisher OR subscriber argument needed" << std::endl; - Log::Reset(); - return 0; - } - - switch (type) - { - case 1: - { - HelloWorldPublisher mypub; - if (mypub.init()) - { - mypub.run(10); - } - break; - } - case 2: - { - HelloWorldSubscriber mysub; - if (mysub.init()) - { - mysub.run(); - } - break; - } - } - Log::Reset(); - return 0; -} diff --git a/examples/cpp/dds/SecureHelloWorldExample/README.txt b/examples/cpp/dds/SecureHelloWorldExample/README.txt deleted file mode 100644 index 79060cb3e1d..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/README.txt +++ /dev/null @@ -1,10 +0,0 @@ -This example needs the certificates stored in "certs" directory. You need to -copy this folder where you will execute the example executable. The -CMakeList.txt file also copies this directory to the folder used to build the -example. - -To launch this test open two different consoles: - -In the first one launch: ./DDSSecureHelloWorldExample publisher (or DDSSecureHelloWorldExample.exe publisher on windows). -In the second one: ./DDSSecureHelloWorldExample subscriber (or DDSSecureHelloWorldExample.exe subscriber on windows). - diff --git a/examples/cpp/dds/SecureHelloWorldExample/certs/governance.smime b/examples/cpp/dds/SecureHelloWorldExample/certs/governance.smime deleted file mode 100644 index 42ffbceac6f..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/certs/governance.smime +++ /dev/null @@ -1,71 +0,0 @@ -MIME-Version: 1.0 -Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha-256"; boundary="----F43F382375A0826FABA8FE7FAAB5A1CB" - -This is an S/MIME signed message - -------F43F382375A0826FABA8FE7FAAB5A1CB -Content-Type: text/plain - - - - - - - - 0 - 230 - - - false - true - ENCRYPT - ENCRYPT - ENCRYPT - - - HelloWorldTopic - true - false - true - true - ENCRYPT - ENCRYPT - - - - - - -------F43F382375A0826FABA8FE7FAAB5A1CB -Content-Type: application/x-pkcs7-signature; name="smime.p7s" -Content-Transfer-Encoding: base64 -Content-Disposition: attachment; filename="smime.p7s" - -MIIEeQYJKoZIhvcNAQcCoIIEajCCBGYCAQExDzANBglghkgBZQMEAgEFADALBgkq -hkiG9w0BBwGgggJAMIICPDCCAeOgAwIBAgIJALZwpgo2sxthMAoGCCqGSM49BAMC -MIGaMQswCQYDVQQGEwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2Fu -dG9zMREwDwYDVQQKDAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNV -BAMMFWVQcm9zaW1hIE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNh -QGVwcm9zaW1hLmNvbTAeFw0xNzA5MDYwOTAzMDNaFw0yNzA5MDQwOTAzMDNaMIGa -MQswCQYDVQQGEwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2FudG9z -MREwDwYDVQQKDAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNVBAMM -FWVQcm9zaW1hIE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNhQGVw -cm9zaW1hLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABGLlhB3WQ8l1fpUE -3DfOoulA/de38Zfj7hmpKtOnxiH2q6RJbwhxvJeA7R7mkmAKaJKmzx695BjyiXVS -7bE7vgejEDAOMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgVTY1BEvT -4pw3GyBMzaUqmp69wi0kBkyOgq04OhyJ13UCICR125vvt0fUhXsXaxOAx28E4Ac9 -SVxpI+3UYs2kV5n0MYIB/TCCAfkCAQEwgagwgZoxCzAJBgNVBAYTAkVTMQswCQYD -VQQIDAJNQTEUMBIGA1UEBwwLVHJlcyBDYW50b3MxETAPBgNVBAoMCGVQcm9zaW1h -MREwDwYDVQQLDAhlUHJvc2ltYTEeMBwGA1UEAwwVZVByb3NpbWEgTWFpbiBUZXN0 -IENBMSIwIAYJKoZIhvcNAQkBFhNtYWluY2FAZXByb3NpbWEuY29tAgkAtnCmCjaz -G2EwDQYJYIZIAWUDBAIBBQCggeQwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAc -BgkqhkiG9w0BCQUxDxcNMTgwNDIwMDgyMDQ2WjAvBgkqhkiG9w0BCQQxIgQgeV8j -PJHH8Gg7wfTMPR1+2k6an80T7+wAv/2B5p04GioweQYJKoZIhvcNAQkPMWwwajAL -BglghkgBZQMEASowCwYJYIZIAWUDBAEWMAsGCWCGSAFlAwQBAjAKBggqhkiG9w0D -BzAOBggqhkiG9w0DAgICAIAwDQYIKoZIhvcNAwICAUAwBwYFKw4DAgcwDQYIKoZI -hvcNAwICASgwCgYIKoZIzj0EAwIERzBFAiEAvzBGtFCtU3Y4kxT1B/yrEdSzFxgU -pjd1kI2z4Z92BnUCIGacA/Mi9qW5ezSNgL1qMr+F3RP1QVsugFndssz7OdQN - -------F43F382375A0826FABA8FE7FAAB5A1CB-- - diff --git a/examples/cpp/dds/SecureHelloWorldExample/certs/governance_dds_sec.xml b/examples/cpp/dds/SecureHelloWorldExample/certs/governance_dds_sec.xml deleted file mode 100644 index 493fd3f1103..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/certs/governance_dds_sec.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - 0 - 230 - - - false - true - ENCRYPT - ENCRYPT - ENCRYPT - - - HelloWorldTopic - true - false - true - true - ENCRYPT - ENCRYPT - - - - - diff --git a/examples/cpp/dds/SecureHelloWorldExample/certs/maincacert.pem b/examples/cpp/dds/SecureHelloWorldExample/certs/maincacert.pem deleted file mode 100644 index b6d2da28a1a..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/certs/maincacert.pem +++ /dev/null @@ -1,14 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICPDCCAeOgAwIBAgIJALZwpgo2sxthMAoGCCqGSM49BAMCMIGaMQswCQYDVQQG -EwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2FudG9zMREwDwYDVQQK -DAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNVBAMMFWVQcm9zaW1h -IE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNhQGVwcm9zaW1hLmNv -bTAeFw0xNzA5MDYwOTAzMDNaFw0yNzA5MDQwOTAzMDNaMIGaMQswCQYDVQQGEwJF -UzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2FudG9zMREwDwYDVQQKDAhl -UHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNVBAMMFWVQcm9zaW1hIE1h -aW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNhQGVwcm9zaW1hLmNvbTBZ -MBMGByqGSM49AgEGCCqGSM49AwEHA0IABGLlhB3WQ8l1fpUE3DfOoulA/de38Zfj -7hmpKtOnxiH2q6RJbwhxvJeA7R7mkmAKaJKmzx695BjyiXVS7bE7vgejEDAOMAwG -A1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgVTY1BEvT4pw3GyBMzaUqmp69 -wi0kBkyOgq04OhyJ13UCICR125vvt0fUhXsXaxOAx28E4Ac9SVxpI+3UYs2kV5n0 ------END CERTIFICATE----- diff --git a/examples/cpp/dds/SecureHelloWorldExample/certs/maincakey.pem b/examples/cpp/dds/SecureHelloWorldExample/certs/maincakey.pem deleted file mode 100644 index bd7d89f4bf3..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/certs/maincakey.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgRaipe1KYZNzj+35E -N2jvtzjRsQ7n9Me/vm35UKGuVI6hRANCAARi5YQd1kPJdX6VBNw3zqLpQP3Xt/GX -4+4ZqSrTp8Yh9qukSW8IcbyXgO0e5pJgCmiSps8eveQY8ol1Uu2xO74H ------END PRIVATE KEY----- diff --git a/examples/cpp/dds/SecureHelloWorldExample/certs/mainpubcert.pem b/examples/cpp/dds/SecureHelloWorldExample/certs/mainpubcert.pem deleted file mode 100644 index ab99f06c5a5..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/certs/mainpubcert.pem +++ /dev/null @@ -1,44 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: - ae:7b:ad:8c:07:5a:ea:f3 - Signature Algorithm: ecdsa-with-SHA256 - Issuer: C=ES, ST=MA, L=Tres Cantos, O=eProsima, OU=eProsima, CN=eProsima Main Test CA/emailAddress=mainca@eprosima.com - Validity - Not Before: Sep 6 09:04:05 2017 GMT - Not After : Sep 4 09:04:05 2027 GMT - Subject: C=ES, ST=MA, O=eProsima, OU=eProsima, CN=Main Publisher/emailAddress=mainpub@eprosima.com - Subject Public Key Info: - Public Key Algorithm: id-ecPublicKey - Public-Key: (256 bit) - pub: - 04:55:95:f0:0b:1f:56:3f:80:4e:97:7e:1b:69:9c: - 7b:54:53:22:c4:a3:96:e9:99:2c:3d:c7:a8:8c:ec: - 1c:fd:d1:35:e7:ba:7d:63:01:9b:42:82:00:73:2c: - 52:e2:e1:0b:db:53:d9:45:a0:f8:64:1c:be:c5:0d: - 51:18:14:9f:90 - ASN1 OID: prime256v1 - NIST CURVE: P-256 - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - Signature Algorithm: ecdsa-with-SHA256 - 30:45:02:21:00:9c:e7:46:44:78:0c:95:eb:a7:38:9a:a7:af: - 4b:6c:bd:84:3b:bb:85:09:25:3d:49:b1:79:9e:e2:7e:dc:99: - 42:02:20:60:78:bd:d0:1e:cd:bc:4b:e3:25:2f:dd:56:6d:c8: - 29:78:3d:df:72:bc:bd:90:de:c6:19:b0:48:44:31:c7:46 ------BEGIN CERTIFICATE----- -MIICHTCCAcOgAwIBAgIJAK57rYwHWurzMAoGCCqGSM49BAMCMIGaMQswCQYDVQQG -EwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2FudG9zMREwDwYDVQQK -DAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNVBAMMFWVQcm9zaW1h -IE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNhQGVwcm9zaW1hLmNv -bTAeFw0xNzA5MDYwOTA0MDVaFw0yNzA5MDQwOTA0MDVaMH4xCzAJBgNVBAYTAkVT -MQswCQYDVQQIDAJNQTERMA8GA1UECgwIZVByb3NpbWExETAPBgNVBAsMCGVQcm9z -aW1hMRcwFQYDVQQDDA5NYWluIFB1Ymxpc2hlcjEjMCEGCSqGSIb3DQEJARYUbWFp -bnB1YkBlcHJvc2ltYS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARVlfAL -H1Y/gE6XfhtpnHtUUyLEo5bpmSw9x6iM7Bz90TXnun1jAZtCggBzLFLi4QvbU9lF -oPhkHL7FDVEYFJ+Qow0wCzAJBgNVHRMEAjAAMAoGCCqGSM49BAMCA0gAMEUCIQCc -50ZEeAyV66c4mqevS2y9hDu7hQklPUmxeZ7iftyZQgIgYHi90B7NvEvjJS/dVm3I -KXg933K8vZDexhmwSEQxx0Y= ------END CERTIFICATE----- diff --git a/examples/cpp/dds/SecureHelloWorldExample/certs/mainpubkey.pem b/examples/cpp/dds/SecureHelloWorldExample/certs/mainpubkey.pem deleted file mode 100644 index cfb610b539d..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/certs/mainpubkey.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgY5T1nA3Wpo8/JegF -k9vz0eTeboO2NB5LqoIDCICa8YChRANCAARVlfALH1Y/gE6XfhtpnHtUUyLEo5bp -mSw9x6iM7Bz90TXnun1jAZtCggBzLFLi4QvbU9lFoPhkHL7FDVEYFJ+Q ------END PRIVATE KEY----- diff --git a/examples/cpp/dds/SecureHelloWorldExample/certs/mainsubcert.pem b/examples/cpp/dds/SecureHelloWorldExample/certs/mainsubcert.pem deleted file mode 100644 index 8d93e9e3b9f..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/certs/mainsubcert.pem +++ /dev/null @@ -1,44 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: - ae:7b:ad:8c:07:5a:ea:f4 - Signature Algorithm: ecdsa-with-SHA256 - Issuer: C=ES, ST=MA, L=Tres Cantos, O=eProsima, OU=eProsima, CN=eProsima Main Test CA/emailAddress=mainca@eprosima.com - Validity - Not Before: Sep 6 09:05:01 2017 GMT - Not After : Sep 4 09:05:01 2027 GMT - Subject: C=ES, ST=MA, O=eProsima, OU=eProsima, CN=Main Subscriber/emailAddress=mainsub@eprosima.com - Subject Public Key Info: - Public Key Algorithm: id-ecPublicKey - Public-Key: (256 bit) - pub: - 04:bc:b4:db:7e:99:f8:24:a9:f9:ce:4d:ab:4e:4a: - 7c:17:73:9f:2a:15:0d:3b:0d:f5:f7:93:28:0b:df: - 00:f5:3d:96:84:11:c6:e4:fc:38:7b:bd:22:68:8a: - d7:07:80:d8:3c:b9:b0:c2:55:b2:eb:0c:8d:a7:a4: - 75:70:8b:16:3d - ASN1 OID: prime256v1 - NIST CURVE: P-256 - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - Signature Algorithm: ecdsa-with-SHA256 - 30:46:02:21:00:e0:aa:1e:90:67:d9:ef:37:cf:aa:30:d5:8a: - 9c:00:0c:7d:76:b8:61:49:eb:4a:7e:43:6d:bc:ea:2c:50:71: - 05:02:21:00:ed:73:99:02:f2:82:bc:49:69:43:97:19:14:a6: - d0:98:6a:49:ba:e3:ae:77:20:ab:6d:a5:43:b8:f1:5b:bb:46 ------BEGIN CERTIFICATE----- -MIICHzCCAcSgAwIBAgIJAK57rYwHWur0MAoGCCqGSM49BAMCMIGaMQswCQYDVQQG -EwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2FudG9zMREwDwYDVQQK -DAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNVBAMMFWVQcm9zaW1h -IE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNhQGVwcm9zaW1hLmNv -bTAeFw0xNzA5MDYwOTA1MDFaFw0yNzA5MDQwOTA1MDFaMH8xCzAJBgNVBAYTAkVT -MQswCQYDVQQIDAJNQTERMA8GA1UECgwIZVByb3NpbWExETAPBgNVBAsMCGVQcm9z -aW1hMRgwFgYDVQQDDA9NYWluIFN1YnNjcmliZXIxIzAhBgkqhkiG9w0BCQEWFG1h -aW5zdWJAZXByb3NpbWEuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEvLTb -fpn4JKn5zk2rTkp8F3OfKhUNOw3195MoC98A9T2WhBHG5Pw4e70iaIrXB4DYPLmw -wlWy6wyNp6R1cIsWPaMNMAswCQYDVR0TBAIwADAKBggqhkjOPQQDAgNJADBGAiEA -4KoekGfZ7zfPqjDVipwADH12uGFJ60p+Q2286ixQcQUCIQDtc5kC8oK8SWlDlxkU -ptCYakm64653IKttpUO48Vu7Rg== ------END CERTIFICATE----- diff --git a/examples/cpp/dds/SecureHelloWorldExample/certs/mainsubkey.pem b/examples/cpp/dds/SecureHelloWorldExample/certs/mainsubkey.pem deleted file mode 100644 index 27f93149cc9..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/certs/mainsubkey.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgJfWGXNN6B/1+Jz4x -o6H3pCmrC7rchZ/GMl8pg9uZ4gGhRANCAAS8tNt+mfgkqfnOTatOSnwXc58qFQ07 -DfX3kygL3wD1PZaEEcbk/Dh7vSJoitcHgNg8ubDCVbLrDI2npHVwixY9 ------END PRIVATE KEY----- diff --git a/examples/cpp/dds/SecureHelloWorldExample/certs/permissions.smime b/examples/cpp/dds/SecureHelloWorldExample/certs/permissions.smime deleted file mode 100644 index cf559d7e311..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/certs/permissions.smime +++ /dev/null @@ -1,88 +0,0 @@ -MIME-Version: 1.0 -Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha-256"; boundary="----F47A2A15090FF0128FA1D352597E1AD4" - -This is an S/MIME signed message - -------F47A2A15090FF0128FA1D352597E1AD4 -Content-Type: text/plain - - - - - - emailAddress=mainpub@eprosima.com, CN=Main Publisher, OU=eProsima, O=eProsima, ST=MA, C=ES - - 2013-06-01T13:00:00 - 2038-06-01T13:00:00 - - - - - 0 - 230 - - - - - HelloWorldTopic - - - - DENY - - - emailAddress=mainsub@eprosima.com, CN=Main Subscriber, OU=eProsima, O=eProsima, ST=MA, C=ES - - 2013-06-01T13:00:00 - 2038-06-01T13:00:00 - - - - - 0 - 230 - - - - - HelloWorldTopic - - - - DENY - - - - -------F47A2A15090FF0128FA1D352597E1AD4 -Content-Type: application/x-pkcs7-signature; name="smime.p7s" -Content-Transfer-Encoding: base64 -Content-Disposition: attachment; filename="smime.p7s" - -MIIEeQYJKoZIhvcNAQcCoIIEajCCBGYCAQExDzANBglghkgBZQMEAgEFADALBgkq -hkiG9w0BBwGgggJAMIICPDCCAeOgAwIBAgIJALZwpgo2sxthMAoGCCqGSM49BAMC -MIGaMQswCQYDVQQGEwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2Fu -dG9zMREwDwYDVQQKDAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNV -BAMMFWVQcm9zaW1hIE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNh -QGVwcm9zaW1hLmNvbTAeFw0xNzA5MDYwOTAzMDNaFw0yNzA5MDQwOTAzMDNaMIGa -MQswCQYDVQQGEwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2FudG9z -MREwDwYDVQQKDAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNVBAMM -FWVQcm9zaW1hIE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNhQGVw -cm9zaW1hLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABGLlhB3WQ8l1fpUE -3DfOoulA/de38Zfj7hmpKtOnxiH2q6RJbwhxvJeA7R7mkmAKaJKmzx695BjyiXVS -7bE7vgejEDAOMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgVTY1BEvT -4pw3GyBMzaUqmp69wi0kBkyOgq04OhyJ13UCICR125vvt0fUhXsXaxOAx28E4Ac9 -SVxpI+3UYs2kV5n0MYIB/TCCAfkCAQEwgagwgZoxCzAJBgNVBAYTAkVTMQswCQYD -VQQIDAJNQTEUMBIGA1UEBwwLVHJlcyBDYW50b3MxETAPBgNVBAoMCGVQcm9zaW1h -MREwDwYDVQQLDAhlUHJvc2ltYTEeMBwGA1UEAwwVZVByb3NpbWEgTWFpbiBUZXN0 -IENBMSIwIAYJKoZIhvcNAQkBFhNtYWluY2FAZXByb3NpbWEuY29tAgkAtnCmCjaz -G2EwDQYJYIZIAWUDBAIBBQCggeQwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAc -BgkqhkiG9w0BCQUxDxcNMTgwNDIwMDgyMjIzWjAvBgkqhkiG9w0BCQQxIgQgILQU -ebFR+2LG5xPwhlrTUf3b8T0MkR3aZjpsi/yptTMweQYJKoZIhvcNAQkPMWwwajAL -BglghkgBZQMEASowCwYJYIZIAWUDBAEWMAsGCWCGSAFlAwQBAjAKBggqhkiG9w0D -BzAOBggqhkiG9w0DAgICAIAwDQYIKoZIhvcNAwICAUAwBwYFKw4DAgcwDQYIKoZI -hvcNAwICASgwCgYIKoZIzj0EAwIERzBFAiEA2lSxk6YvQsqrx+LEjVwZI9/V6o5c -ggok/gGrVlbsEq0CIFWg6QFkrgny+OkJV2TNY3rSTr8YOvJa7Hm13pe9NqkP - -------F47A2A15090FF0128FA1D352597E1AD4-- - diff --git a/examples/cpp/dds/SecureHelloWorldExample/certs/permissions_dds_sec.xml b/examples/cpp/dds/SecureHelloWorldExample/certs/permissions_dds_sec.xml deleted file mode 100644 index b13d5051ef4..00000000000 --- a/examples/cpp/dds/SecureHelloWorldExample/certs/permissions_dds_sec.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - emailAddress=mainpub@eprosima.com, CN=Main Publisher, OU=eProsima, O=eProsima, ST=MA, C=ES - - 2013-06-01T13:00:00 - 2038-06-01T13:00:00 - - - - - 0 - 230 - - - - - HelloWorldTopic - - - - DENY - - - emailAddress=mainsub@eprosima.com, CN=Main Subscriber, OU=eProsima, O=eProsima, ST=MA, C=ES - - 2013-06-01T13:00:00 - 2038-06-01T13:00:00 - - - - - 0 - 230 - - - - - HelloWorldTopic - - - - DENY - - - diff --git a/examples/cpp/hello_world/Application.cpp b/examples/cpp/hello_world/Application.cpp index 3db1a1ebaa8..fb42f74aafc 100644 --- a/examples/cpp/hello_world/Application.cpp +++ b/examples/cpp/hello_world/Application.cpp @@ -17,7 +17,6 @@ * */ - #include "Application.hpp" #include "CLIParser.hpp" diff --git a/test/examples/CMakeLists.txt b/test/examples/CMakeLists.txt index 36a497dc0ee..2e29b11fe15 100644 --- a/test/examples/CMakeLists.txt +++ b/test/examples/CMakeLists.txt @@ -68,6 +68,11 @@ endif() # Find all pytest files for testing file(GLOB examples_python_tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.py) +# Add security test only if security is enabled +if (NOT SECURITY) + list(FILTER examples_python_tests EXCLUDE REGEX "*security*") +endif() + # Configure the pytest files, and add a test for each one foreach(example_test ${examples_python_tests}) get_filename_component(example_name ${example_test} NAME_WE) From 6999b951571ae4429476762d116c0cb108ee3f44 Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Fri, 12 Jul 2024 09:13:51 +0200 Subject: [PATCH 12/12] Refs #21266: Add changes for uncrustify and fix test/examples/CMakeLists.txt Signed-off-by: Carlosespicur --- examples/cpp/configuration/Application.hpp | 2 +- examples/cpp/configuration/PublisherApp.hpp | 2 +- examples/cpp/security/PublisherApp.cpp | 2 +- test/examples/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/cpp/configuration/Application.hpp b/examples/cpp/configuration/Application.hpp index eb92a49c6ec..298867229b2 100644 --- a/examples/cpp/configuration/Application.hpp +++ b/examples/cpp/configuration/Application.hpp @@ -52,4 +52,4 @@ class Application } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_EXAMPLES_CPP_CONFIGURATION__APPLICATION_HPP +#endif // FASTDDS_EXAMPLES_CPP_CONFIGURATION__APPLICATION_HPP diff --git a/examples/cpp/configuration/PublisherApp.hpp b/examples/cpp/configuration/PublisherApp.hpp index 7a31e61a34b..ca5e28eecf9 100644 --- a/examples/cpp/configuration/PublisherApp.hpp +++ b/examples/cpp/configuration/PublisherApp.hpp @@ -118,4 +118,4 @@ class PublisherApp : public Application, public DataWriterListener } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_EXAMPLES_CPP_CONFIGURATION__PUBLISHERAPP_HPP +#endif // FASTDDS_EXAMPLES_CPP_CONFIGURATION__PUBLISHERAPP_HPP diff --git a/examples/cpp/security/PublisherApp.cpp b/examples/cpp/security/PublisherApp.cpp index 2650d299509..2c8baf8e44e 100644 --- a/examples/cpp/security/PublisherApp.cpp +++ b/examples/cpp/security/PublisherApp.cpp @@ -159,7 +159,7 @@ bool PublisherApp::publish() if (!is_stopped()) { hello_.index(hello_.index() + 1); - ret = writer_->write(&hello_); + ret = (writer_->write(&hello_) == RETCODE_OK) ? true : false; } return ret; } diff --git a/test/examples/CMakeLists.txt b/test/examples/CMakeLists.txt index 2e29b11fe15..7dd4dfeedee 100644 --- a/test/examples/CMakeLists.txt +++ b/test/examples/CMakeLists.txt @@ -70,7 +70,7 @@ file(GLOB examples_python_tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CUR # Add security test only if security is enabled if (NOT SECURITY) - list(FILTER examples_python_tests EXCLUDE REGEX "*security*") + list(FILTER examples_python_tests EXCLUDE REGEX "security") endif() # Configure the pytest files, and add a test for each one