Skip to content

Commit

Permalink
Examples refactor: Delivery mechanisms (#4959)
Browse files Browse the repository at this point in the history
* Refs #20650: Implement Delivery mechanisms example

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Generate types with latest gen version

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Write example README and versions.md

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Add example tests

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Apply rev suggestions

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Please linter

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Apply rev suggestions and fix test

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Adjust timeouts

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Add missing configurations that were lost in the review

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Proper configuration for initial peers

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Set pubsub tcp as unsupported cornercase

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Include publisher tests

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Adapt pubsub stop condition when both pub and sub have really stopped

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Adapt tests

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Regenerate types with latest changes in fastdds / fastdds gen

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Include license in test files

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Apply THE fix

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Add type constraints check in each app

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Add missing mechanisms: UDPv6, TCPv6 and large data

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Update the tests with new meachanisms

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Add address argument and usage

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Add isolated examples

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Apply rev suggestions

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Please linter

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #20650: Apply rev suggestions (2)

Signed-off-by: JesusPoderoso <[email protected]>

---------

Signed-off-by: JesusPoderoso <[email protected]>
  • Loading branch information
JesusPoderoso committed Jun 27, 2024
1 parent ccacad0 commit 4c9f1d6
Show file tree
Hide file tree
Showing 28 changed files with 3,669 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ add_subdirectory(cpp/configuration)
add_subdirectory(cpp/content_filter)
add_subdirectory(cpp/custom_payload_pool)
add_subdirectory(cpp/dds)
add_subdirectory(cpp/delivery_mechanisms)
add_subdirectory(cpp/hello_world)
add_subdirectory(cpp/rtps)
add_subdirectory(cpp/xtypes)
62 changes: 62 additions & 0 deletions examples/cpp/delivery_mechanisms/Application.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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 "PublisherApp.hpp"
#include "SubscriberApp.hpp"
#include "PubSubApp.hpp"

using namespace eprosima::fastdds::dds;

namespace eprosima {
namespace fastdds {
namespace examples {
namespace delivery_mechanisms {

//! Factory method to create a publisher or subscriber
std::shared_ptr<Application> Application::make_app(
const CLIParser::delivery_mechanisms_config& config,
const std::string& topic_name)
{
std::shared_ptr<Application> entity;
switch (config.entity)
{
case CLIParser::EntityKind::PUBLISHER:
entity = std::make_shared<PublisherApp>(config, topic_name);
break;
case CLIParser::EntityKind::SUBSCRIBER:
entity = std::make_shared<SubscriberApp>(config, topic_name);
break;
case CLIParser::EntityKind::PUBSUB:
entity = std::make_shared<PubSubApp>(config, topic_name);
break;
case CLIParser::EntityKind::UNDEFINED:
default:
throw std::runtime_error("Entity initialization failed");
break;
}
return entity;
}

} // namespace delivery_mechanisms
} // namespace examples
} // namespace fastdds
} // namespace eprosima
56 changes: 56 additions & 0 deletions examples/cpp/delivery_mechanisms/Application.hpp
Original file line number Diff line number Diff line change
@@ -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_DELIVERY_MECHANISMS_APPLICATION_HPP_
#define _FASTDDS_DELIVERY_MECHANISMS_APPLICATION_HPP_

#include <atomic>

#include "CLIParser.hpp"

namespace eprosima {
namespace fastdds {
namespace examples {
namespace delivery_mechanisms {

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<Application> make_app(
const CLIParser::delivery_mechanisms_config& config,
const std::string& topic_name);
};

} // namespace delivery_mechanisms
} // namespace examples
} // namespace fastdds
} // namespace eprosima

#endif /* _FASTDDS_DELIVERY_MECHANISMS_APPLICATION_HPP_ */
Loading

0 comments on commit 4c9f1d6

Please sign in to comment.