Skip to main content

AVxcelerate Simulation Framework 2024 R2 SP02

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

Last update: 16.07.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:

Topic<GenericBytesMessage> osi_topic_1("topic_1");
Topic<GenericBytesMessage> osi_topic_2("topic_2");

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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ GetType()

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

Implements simulation_framework::core::ITopic.

◆ 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.

◆ 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.


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

Connect with Ansys