    

 ## On this page

  

 

 # simulation\_framework::core::Topic&lt; TopicMsgType &gt; Class Template Reference

 Last update: 16.07.2025 

This is the concrete [Topic](classsimulation__framework_1_1core_1_1Topic.xhtml "This is the concrete Topic class that can be used for creation of a communication channel with given ...") 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](classsimulation__framework_1_1core_1_1Topic.xhtml "This is the concrete Topic class that can be used for creation of a communication channel with given ..."). Different Topics can hold same underlying message type but they are different topics for communication. [More...](classsimulation__framework_1_1core_1_1Topic.xhtml#details)

`#include <<a class="el" href="topic_8h_source.xhtml">topic.h</a>>`

Inheritance diagram for simulation_framework::core::Topic&lt; TopicMsgType &gt;:

![Inheritance graph](/sites/default/files/migrate-content/avxcelerate_simulation_framework_2025_r2_2/classsimulation__framework_1_1core_1_1Topic__inherit__graph.png)

\[[legend](graph_legend.xhtml)\]

Collaboration diagram for simulation_framework::core::Topic&lt; TopicMsgType &gt;:

![Collaboration graph](/sites/default/files/migrate-content/avxcelerate_simulation_framework_2025_r2_2/classsimulation__framework_1_1core_1_1Topic__coll__graph.png)

\[[legend](graph_legend.xhtml)\]

## <a id="pub-types" name="pub-types"></a>Public Types

[using](classsimulation__framework_1_1core_1_1Topic.xhtml) [PublisherCallback](classsimulation__framework_1_1core_1_1Topic.xhtml#a0f29e64e5b4720391091e07f6250e20a) = std::function&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml)()&gt; [using](classsimulation__framework_1_1core_1_1Topic.xhtml) [SubscriberMessageCallback](classsimulation__framework_1_1core_1_1Topic.xhtml#a2c04396e41962b68a36c63f8a3c215f1) = std::function&lt; [void](classsimulation__framework_1_1core_1_1Topic.xhtml)([const](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &amp;)&gt; [using](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMessageType](classsimulation__framework_1_1core_1_1Topic.xhtml#aa28465d4f009835110d723ee902d17b4) = [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) ## <a id="pub-methods" name="pub-methods"></a>Public Member Functions

 [Topic](classsimulation__framework_1_1core_1_1Topic.xhtml#a9ff71b7b23ec021c0f39891008c45e22) ([const](classsimulation__framework_1_1core_1_1Topic.xhtml) TopicId &amp;[topic\_id](classsimulation__framework_1_1core_1_1Topic.xhtml), [const](classsimulation__framework_1_1core_1_1Topic.xhtml) TopicType [topic\_type](classsimulation__framework_1_1core_1_1Topic.xhtml)=TopicType::kRTIDDS) TopicId [GetId](classsimulation__framework_1_1core_1_1Topic.xhtml#a6cef83adabcaab8aabd20cd3184dca3c) () [const](classsimulation__framework_1_1core_1_1Topic.xhtml) [override](classsimulation__framework_1_1core_1_1Topic.xhtml) TopicType [GetType](classsimulation__framework_1_1core_1_1Topic.xhtml#a6f459336816bf96dd43d4a827043485d) () [const](classsimulation__framework_1_1core_1_1Topic.xhtml) [override](classsimulation__framework_1_1core_1_1Topic.xhtml) [void](classsimulation__framework_1_1core_1_1Topic.xhtml) [AddPublisher](classsimulation__framework_1_1core_1_1Topic.xhtml#a9a3bdb1cc0fb2b885fbe528903abcb14) (std::unique\_ptr&lt; IPublisher &gt; [pub\_ptr](classsimulation__framework_1_1core_1_1Topic.xhtml)) [override](classsimulation__framework_1_1core_1_1Topic.xhtml) [void](classsimulation__framework_1_1core_1_1Topic.xhtml) [AddSubscriber](classsimulation__framework_1_1core_1_1Topic.xhtml#a33882d851ffa66f8db5a83813969e48a) (std::unique\_ptr&lt; ISubscriber &gt; [sub\_ptr](classsimulation__framework_1_1core_1_1Topic.xhtml)) [override](classsimulation__framework_1_1core_1_1Topic.xhtml) std::size\_t [SubscriberCount](classsimulation__framework_1_1core_1_1Topic.xhtml#a71ce3df423a48cbc555cf9fb322726df) () [const](classsimulation__framework_1_1core_1_1Topic.xhtml) [override](classsimulation__framework_1_1core_1_1Topic.xhtml) std::size\_t [PublisherCount](classsimulation__framework_1_1core_1_1Topic.xhtml#a9056b30c90efc165ee8559b41e8a9064) () [const](classsimulation__framework_1_1core_1_1Topic.xhtml) [override](classsimulation__framework_1_1core_1_1Topic.xhtml) [void](classsimulation__framework_1_1core_1_1Topic.xhtml) [ClearPubSub](classsimulation__framework_1_1core_1_1Topic.xhtml#ac366c5dd53e4c5770b1a5f40ae2c8956) () [override](classsimulation__framework_1_1core_1_1Topic.xhtml) [const](classsimulation__framework_1_1core_1_1Topic.xhtml) Subscribers &amp; [GetSubscribers](classsimulation__framework_1_1core_1_1Topic.xhtml#ab0a3ea471d469cf2b0611b6548752298) () [const](classsimulation__framework_1_1core_1_1Topic.xhtml) [override](classsimulation__framework_1_1core_1_1Topic.xhtml) [const](classsimulation__framework_1_1core_1_1Topic.xhtml) Publishers &amp; [GetPublishers](classsimulation__framework_1_1core_1_1Topic.xhtml#ac31691f84f68ad4a3aeda6074739676f) () [const](classsimulation__framework_1_1core_1_1Topic.xhtml) [override](classsimulation__framework_1_1core_1_1Topic.xhtml) <a id="details" name="details"></a>## Detailed Description

template&lt;typename TopicMsgType&gt;  
class simulation_framework::core::Topic&lt; TopicMsgType &gt;

This is the concrete [Topic](classsimulation__framework_1_1core_1_1Topic.xhtml "This is the concrete Topic class that can be used for creation of a communication channel with given ...") 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](classsimulation__framework_1_1core_1_1Topic.xhtml "This is the concrete Topic class that can be used for creation of a communication channel with given ..."). Different Topics can hold same underlying message type but they are different topics for communication.

Example:

[Topic&lt;GenericBytesMessage&gt;](classsimulation__framework_1_1core_1_1Topic.xhtml) [osi\_topic\_1](classsimulation__framework_1_1core_1_1Topic.xhtml)("topic\_1");

[Topic&lt;GenericBytesMessage&gt;](classsimulation__framework_1_1core_1_1Topic.xhtml) [osi\_topic\_2](classsimulation__framework_1_1core_1_1Topic.xhtml)("topic\_2");

[simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)

This is the concrete Topic class that can be used for creation of a communication channel with given ...

**Definition** [topic.h:38](topic_8h_source.xhtml#l00037)





Definition at line [37](topic_8h_source.xhtml#l00037) of file [topic.h](topic_8h_source.xhtml).



## Member Typedef Documentation

<a id="a0f29e64e5b4720391091e07f6250e20a" name="a0f29e64e5b4720391091e07f6250e20a"></a>## [◆ ](#a0f29e64e5b4720391091e07f6250e20a)PublisherCallback

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 [using](classsimulation__framework_1_1core_1_1Topic.xhtml) [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::PublisherCallback = std::function&lt;[TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml)()&gt;

Definition at line [40](topic_8h_source.xhtml#l00040) of file [topic.h](topic_8h_source.xhtml).





<a id="a2c04396e41962b68a36c63f8a3c215f1" name="a2c04396e41962b68a36c63f8a3c215f1"></a>## [◆ ](#a2c04396e41962b68a36c63f8a3c215f1)SubscriberMessageCallback

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 [using](classsimulation__framework_1_1core_1_1Topic.xhtml) [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::SubscriberMessageCallback = std::function&lt;[void](classsimulation__framework_1_1core_1_1Topic.xhtml)([const](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml)&amp;)&gt;

Definition at line [41](topic_8h_source.xhtml#l00041) of file [topic.h](topic_8h_source.xhtml).





<a id="aa28465d4f009835110d723ee902d17b4" name="aa28465d4f009835110d723ee902d17b4"></a>## [◆ ](#aa28465d4f009835110d723ee902d17b4)TopicMessageType

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 [using](classsimulation__framework_1_1core_1_1Topic.xhtml) [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::TopicMessageType = [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml)

Definition at line [42](topic_8h_source.xhtml#l00042) of file [topic.h](topic_8h_source.xhtml).





## Constructor &amp; Destructor Documentation

<a id="a9ff71b7b23ec021c0f39891008c45e22" name="a9ff71b7b23ec021c0f39891008c45e22"></a>## [◆ ](#a9ff71b7b23ec021c0f39891008c45e22)Topic()

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::Topic  ( [const](classsimulation__framework_1_1core_1_1Topic.xhtml) TopicId &amp;  *topic\_id*,    [const](classsimulation__framework_1_1core_1_1Topic.xhtml) TopicType  *topic\_type* = `TopicType::kRTIDDS`   )   inline 

Definition at line [44](topic_8h_source.xhtml#l00044) of file [topic.h](topic_8h_source.xhtml).

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

 46 {

 47 }







## Member Function Documentation

<a id="a9a3bdb1cc0fb2b885fbe528903abcb14" name="a9a3bdb1cc0fb2b885fbe528903abcb14"></a>## [◆ ](#a9a3bdb1cc0fb2b885fbe528903abcb14)AddPublisher()

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 [void](classsimulation__framework_1_1core_1_1Topic.xhtml) [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::AddPublisher  ( std::unique\_ptr&lt; IPublisher &gt;  *pub\_ptr*)   inlineoverridevirtual 

Add one publisher of this [Topic](classsimulation__framework_1_1core_1_1Topic.xhtml "This is the concrete Topic class that can be used for creation of a communication channel with given ..."). The max publisher count of a topic is limited to be one.

Parameters pub\_ptrThe abstraction of publisher interface Implements [simulation\_framework::core::ITopic](classsimulation__framework_1_1core_1_1ITopic.xhtml#aadab7c49ae9beaa036d3fa9845aed85d).

Definition at line [52](topic_8h_source.xhtml#l00052) of file [topic.h](topic_8h_source.xhtml).

 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 }







<a id="a33882d851ffa66f8db5a83813969e48a" name="a33882d851ffa66f8db5a83813969e48a"></a>## [◆ ](#a33882d851ffa66f8db5a83813969e48a)AddSubscriber()

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 [void](classsimulation__framework_1_1core_1_1Topic.xhtml) [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::AddSubscriber  ( std::unique\_ptr&lt; ISubscriber &gt;  *sub\_ptr*)   inlineoverridevirtual 

Add one subscriber to this [Topic](classsimulation__framework_1_1core_1_1Topic.xhtml "This is the concrete Topic class that can be used for creation of a communication channel with given ...")

Parameters sub\_ptrThe abstraction of subscriber interface Implements [simulation\_framework::core::ITopic](classsimulation__framework_1_1core_1_1ITopic.xhtml#a612d64a1aca7a60a8efc7f07f4d28311).

Definition at line [61](topic_8h_source.xhtml#l00061) of file [topic.h](topic_8h_source.xhtml).

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







<a id="ac366c5dd53e4c5770b1a5f40ae2c8956" name="ac366c5dd53e4c5770b1a5f40ae2c8956"></a>## [◆ ](#ac366c5dd53e4c5770b1a5f40ae2c8956)ClearPubSub()

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 [void](classsimulation__framework_1_1core_1_1Topic.xhtml) [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::ClearPubSub  ( )   inlineoverridevirtual 

Remove all publisher and subscriber which are asociated with this [Topic](classsimulation__framework_1_1core_1_1Topic.xhtml "This is the concrete Topic class that can be used for creation of a communication channel with given ...")

Implements [simulation\_framework::core::ITopic](classsimulation__framework_1_1core_1_1ITopic.xhtml#a470392793ee8cb2fc406b8b1e1b55d2d).

Definition at line [66](topic_8h_source.xhtml#l00066) of file [topic.h](topic_8h_source.xhtml).

 67 {

 68 publishers_.clear();

 69 subscribers_.clear();

 70 }







<a id="a6cef83adabcaab8aabd20cd3184dca3c" name="a6cef83adabcaab8aabd20cd3184dca3c"></a>## [◆ ](#a6cef83adabcaab8aabd20cd3184dca3c)GetId()

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 TopicId [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::GetId  ( )  const  inlineoverridevirtual 

ReturnsA unique ID of this topic Implements [simulation\_framework::core::ITopic](classsimulation__framework_1_1core_1_1ITopic.xhtml#ad4e077cd059e9c6f0ce9ad0df73ca3cd).

Definition at line [49](topic_8h_source.xhtml#l00049) of file [topic.h](topic_8h_source.xhtml).

 49{ return topic_id_; }







<a id="ac31691f84f68ad4a3aeda6074739676f" name="ac31691f84f68ad4a3aeda6074739676f"></a>## [◆ ](#ac31691f84f68ad4a3aeda6074739676f)GetPublishers()

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 [const](classsimulation__framework_1_1core_1_1Topic.xhtml) Publishers &amp; [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::GetPublishers  ( )  const  inlineoverridevirtual 

ReturnsThe list of assigned publisher which are publishing message to this [Topic](classsimulation__framework_1_1core_1_1Topic.xhtml "This is the concrete Topic class that can be used for creation of a communication channel with given ...")Implements [simulation\_framework::core::ITopic](classsimulation__framework_1_1core_1_1ITopic.xhtml#aa02ef4f55132426e2af9de01bde3bf4b).

Definition at line [73](topic_8h_source.xhtml#l00073) of file [topic.h](topic_8h_source.xhtml).

 73{ return publishers_; }







<a id="ab0a3ea471d469cf2b0611b6548752298" name="ab0a3ea471d469cf2b0611b6548752298"></a>## [◆ ](#ab0a3ea471d469cf2b0611b6548752298)GetSubscribers()

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 [const](classsimulation__framework_1_1core_1_1Topic.xhtml) Subscribers &amp; [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::GetSubscribers  ( )  const  inlineoverridevirtual 

ReturnsThe list of assigned subscriber which are listening to this [Topic](classsimulation__framework_1_1core_1_1Topic.xhtml "This is the concrete Topic class that can be used for creation of a communication channel with given ...")Implements [simulation\_framework::core::ITopic](classsimulation__framework_1_1core_1_1ITopic.xhtml#a52c9a4a95089eb1dfbc0606974d9a8d0).

Definition at line [72](topic_8h_source.xhtml#l00072) of file [topic.h](topic_8h_source.xhtml).

 72{ return subscribers_; }







<a id="a6f459336816bf96dd43d4a827043485d" name="a6f459336816bf96dd43d4a827043485d"></a>## [◆ ](#a6f459336816bf96dd43d4a827043485d)GetType()

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 TopicType [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::GetType  ( )  const  inlineoverridevirtual 

ReturnsThe type of this topic Implements [simulation\_framework::core::ITopic](classsimulation__framework_1_1core_1_1ITopic.xhtml#a461f8684a1e5190affbe69253f74fdb7).

Definition at line [50](topic_8h_source.xhtml#l00050) of file [topic.h](topic_8h_source.xhtml).

 50{ return topic_type_; }







<a id="a9056b30c90efc165ee8559b41e8a9064" name="a9056b30c90efc165ee8559b41e8a9064"></a>## [◆ ](#a9056b30c90efc165ee8559b41e8a9064)PublisherCount()

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 std::size\_t [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::PublisherCount  ( )  const  inlineoverridevirtual 

ReturnsThe number of publisher which publishes message into this [Topic](classsimulation__framework_1_1core_1_1Topic.xhtml "This is the concrete Topic class that can be used for creation of a communication channel with given ..."). The max publisher count of a topic is limited to be one. Implements [simulation\_framework::core::ITopic](classsimulation__framework_1_1core_1_1ITopic.xhtml#a469c0e1f5fd07f9829e93fd8a43bd6f7).

Definition at line [64](topic_8h_source.xhtml#l00064) of file [topic.h](topic_8h_source.xhtml).

 64{ return publishers_.size(); }







<a id="a71ce3df423a48cbc555cf9fb322726df" name="a71ce3df423a48cbc555cf9fb322726df"></a>## [◆ ](#a71ce3df423a48cbc555cf9fb322726df)SubscriberCount()

template&lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt; 

 std::size\_t [simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt; [TopicMsgType](classsimulation__framework_1_1core_1_1Topic.xhtml) &gt;::SubscriberCount  ( )  const  inlineoverridevirtual 

ReturnsThe number of subscriber which is listening to this topic Implements [simulation\_framework::core::ITopic](classsimulation__framework_1_1core_1_1ITopic.xhtml#a370ff9b0059ea1c200e6a5384671aac8).

Definition at line [63](topic_8h_source.xhtml#l00063) of file [topic.h](topic_8h_source.xhtml).

 63{ return subscribers_.size(); }







---

The documentation for this class was generated from the following file:- [topic.h](topic_8h_source.xhtml)