Skip to main content

AVxcelerate Simulation Framework 2025 R2 SP02

simulation_framework::core::Topic< TopicMsgType > Class Template Reference

Last update: 19.09.2025

This is the concrete Topic class that can be used for creation of a communication channel with given underlying message. As default type, DDS type will be applied. TopicId is globally unique and represents one single Topic. Different Topics can hold same underlying message type but they are different topics for communication. More...

#include <topic.h>

Inheritance diagram for simulation_framework::core::Topic< TopicMsgType >:
Collaboration diagram for simulation_framework::core::Topic< TopicMsgType >:

Public Types

using PublisherCallback = std::function< TopicMsgType()>
 
using SubscriberMessageCallback = std::function< void(const TopicMsgType &)>
 
using TopicMessageType = TopicMsgType
 

Public Member Functions

 Topic (const TopicId &topic_id, const TopicType topic_type=TopicType::kRTIDDS)
 
TopicId GetId () const override
 
TopicType GetType () const override
 
void AddPublisher (std::unique_ptr< IPublisher > pub_ptr) override
 
void AddSubscriber (std::unique_ptr< ISubscriber > sub_ptr) override
 
std::size_t SubscriberCount () const override
 
std::size_t PublisherCount () const override
 
void ClearPubSub () override
 
const Subscribers & GetSubscribers () const override
 
const Publishers & GetPublishers () const override
 

Detailed Description

template<typename TopicMsgType>
class simulation_framework::core::Topic< TopicMsgType >

This is the concrete Topic class that can be used for creation of a communication channel with given underlying message. As default type, DDS type will be applied. TopicId is globally unique and represents one single Topic. Different Topics can hold same underlying message type but they are different topics for communication.

Example:

This is the concrete Topic class that can be used for creation of a communication channel with given ...
Definition topic.h:38

Definition at line 37 of file topic.h.

Member Typedef Documentation

◆ PublisherCallback

template<typename TopicMsgType >
using simulation_framework::core::Topic< TopicMsgType >::PublisherCallback = std::function<TopicMsgType()>

Definition at line 40 of file topic.h.

◆ SubscriberMessageCallback

template<typename TopicMsgType >
using simulation_framework::core::Topic< TopicMsgType >::SubscriberMessageCallback = std::function<void(const TopicMsgType&)>

Definition at line 41 of file topic.h.

◆ TopicMessageType

Definition at line 42 of file topic.h.

Constructor & Destructor Documentation

◆ Topic()

template<typename TopicMsgType >
simulation_framework::core::Topic< TopicMsgType >::Topic ( const TopicId &  topic_id,
const TopicType  topic_type = TopicType::kRTIDDS 
)
inline

Definition at line 44 of file topic.h.

45 : ITopic{}, topic_id_(topic_id), topic_type_(topic_type)
46 {
47 }

Member Function Documentation

◆ AddPublisher()

template<typename TopicMsgType >
void simulation_framework::core::Topic< TopicMsgType >::AddPublisher ( std::unique_ptr< IPublisher >  pub_ptr)
inlineoverridevirtual

Add one publisher of this Topic. The max publisher count of a topic is limited to be one.

Parameters
pub_ptrThe abstraction of publisher interface

Implements simulation_framework::core::ITopic.

Definition at line 52 of file topic.h.

53 {
54 if (publishers_.size() == 1)
55 {
56 throw std::range_error("Already a Publisher for topic " + topic_id_ +
57 " has been set. Multiple publishers for same topic is NOT allowed! ");
58 }
59 publishers_.push_back(std::move(pub_ptr));
60 }

◆ AddSubscriber()

template<typename TopicMsgType >
void simulation_framework::core::Topic< TopicMsgType >::AddSubscriber ( std::unique_ptr< ISubscriber >  sub_ptr)
inlineoverridevirtual

Add one subscriber to this Topic

Parameters
sub_ptrThe abstraction of subscriber interface

Implements simulation_framework::core::ITopic.

Definition at line 61 of file topic.h.

61{ subscribers_.push_back(std::move(sub_ptr)); }

◆ ClearPubSub()

template<typename TopicMsgType >
void simulation_framework::core::Topic< TopicMsgType >::ClearPubSub ( )
inlineoverridevirtual

Remove all publisher and subscriber which are asociated with this Topic

Implements simulation_framework::core::ITopic.

Definition at line 66 of file topic.h.

67 {
68 publishers_.clear();
69 subscribers_.clear();
70 }

◆ GetId()

template<typename TopicMsgType >
TopicId simulation_framework::core::Topic< TopicMsgType >::GetId ( ) const
inlineoverridevirtual
Returns
A unique ID of this topic

Implements simulation_framework::core::ITopic.

Definition at line 49 of file topic.h.

49{ return topic_id_; }

◆ GetPublishers()

template<typename TopicMsgType >
const Publishers & simulation_framework::core::Topic< TopicMsgType >::GetPublishers ( ) const
inlineoverridevirtual
Returns
The list of assigned publisher which are publishing message to this Topic

Implements simulation_framework::core::ITopic.

Definition at line 73 of file topic.h.

73{ return publishers_; }

◆ GetSubscribers()

template<typename TopicMsgType >
const Subscribers & simulation_framework::core::Topic< TopicMsgType >::GetSubscribers ( ) const
inlineoverridevirtual
Returns
The list of assigned subscriber which are listening to this Topic

Implements simulation_framework::core::ITopic.

Definition at line 72 of file topic.h.

72{ return subscribers_; }

◆ GetType()

template<typename TopicMsgType >
TopicType simulation_framework::core::Topic< TopicMsgType >::GetType ( ) const
inlineoverridevirtual
Returns
The type of this topic

Implements simulation_framework::core::ITopic.

Definition at line 50 of file topic.h.

50{ return topic_type_; }

◆ PublisherCount()

template<typename TopicMsgType >
std::size_t simulation_framework::core::Topic< TopicMsgType >::PublisherCount ( ) const
inlineoverridevirtual
Returns
The number of publisher which publishes message into this Topic. The max publisher count of a topic is limited to be one.

Implements simulation_framework::core::ITopic.

Definition at line 64 of file topic.h.

64{ return publishers_.size(); }

◆ SubscriberCount()

template<typename TopicMsgType >
std::size_t simulation_framework::core::Topic< TopicMsgType >::SubscriberCount ( ) const
inlineoverridevirtual
Returns
The number of subscriber which is listening to this topic

Implements simulation_framework::core::ITopic.

Definition at line 63 of file topic.h.

63{ return subscribers_.size(); }

The documentation for this class was generated from the following file:

Connect with Ansys