Skip to content

Commit 984405b

Browse files
authored
Example refactor: Content filter (#4859)
* Refs #20823: Copy ContentFilteredTopicExample files to content_filtering Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Change file names and CMakeList structure Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Add CLI parser Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Add application hpp and cpp Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Create publisher application Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Create subscriber application Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Add test Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #Refs 20823: Rename folder to content_filter Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823 Add customizable lower bound and upper bound arguments to the example Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Add changes to version.md Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Initialize interval in publisher Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Apply suggestion Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Apply suggestion: Update Readme.md Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Add option none filter Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Set datareader and datawriter qos to meet the condition for writer side filtering Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Apply suggestions: Add filtering on the writer side Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Uncrustify Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Change guard name and custom filter classes name Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823 Apply suggestions Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Update ReadMe Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Add new arguments to set a custom filter expression and to allowing the writer side filtering Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: add transient and ralible as arguments Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Split and modify test Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: uncrustify Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Solve windows warning Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Remove argument --reliable --transient-local Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Add the right includes Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Remove folders that were added during the rebase Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20823: Add license Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --------- Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>
1 parent b441560 commit 984405b

92 files changed

Lines changed: 1636 additions & 9086 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
# limitations under the License.
1414

1515
set(fastdds_FOUND TRUE)
16+
1617
add_subdirectory(cpp/configuration)
18+
add_subdirectory(cpp/content_filter)
1719
add_subdirectory(cpp/custom_payload_pool)
1820
add_subdirectory(cpp/dds)
1921
add_subdirectory(cpp/hello_world)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/**
16+
* @file Application.cpp
17+
*
18+
*/
19+
20+
#include "Application.hpp"
21+
22+
#include "CLIParser.hpp"
23+
#include "SubscriberApp.hpp"
24+
#include "PublisherApp.hpp"
25+
26+
using namespace eprosima::fastdds::dds;
27+
28+
namespace eprosima {
29+
namespace fastdds {
30+
namespace examples {
31+
namespace content_filter {
32+
33+
//! Factory method to create a publisher or subscriber
34+
std::shared_ptr<Application> Application::make_app(
35+
const CLIParser::content_filter_config& config,
36+
const std::string& topic_name)
37+
{
38+
std::shared_ptr<Application> entity;
39+
switch (config.entity)
40+
{
41+
case CLIParser::EntityKind::PUBLISHER:
42+
entity = std::make_shared<PublisherApp>(config.pub_config, topic_name);
43+
break;
44+
case CLIParser::EntityKind::SUBSCRIBER:
45+
entity = std::make_shared<SubscriberApp>(config.sub_config, topic_name);
46+
break;
47+
case CLIParser::EntityKind::UNDEFINED:
48+
default:
49+
throw std::runtime_error("Entity initialization failed");
50+
break;
51+
}
52+
return entity;
53+
}
54+
55+
} // namespace content_filter
56+
} // namespace examples
57+
} // namespace fastdds
58+
} // namespace eprosima
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/**
16+
* @file Application.hpp
17+
*
18+
*/
19+
20+
#ifndef _FASTDDS_CONTENT_FILTER_APPLICATION_HPP_
21+
#define _FASTDDS_CONTENT_FILTER_APPLICATION_HPP_
22+
23+
#include <atomic>
24+
25+
#include "CLIParser.hpp"
26+
27+
namespace eprosima {
28+
namespace fastdds {
29+
namespace examples {
30+
namespace content_filter {
31+
32+
class Application
33+
{
34+
public:
35+
36+
//! Virtual destructor
37+
virtual ~Application() = default;
38+
39+
//! Run application
40+
virtual void run() = 0;
41+
42+
//! Trigger the end of execution
43+
virtual void stop() = 0;
44+
45+
//! Factory method to create applications based on configuration
46+
static std::shared_ptr<Application> make_app(
47+
const CLIParser::content_filter_config& config,
48+
const std::string& topic_name);
49+
};
50+
51+
} // namespace content_filter
52+
} // namespace examples
53+
} // namespace fastdds
54+
} // namespace eprosima
55+
56+
#endif /* _FASTDDS_CONTEN_FILTER_APPLICATION_HPP_ */

0 commit comments

Comments
 (0)