Wrapping a reader/writer in a class

3 posts / 0 new
Last post
Last seen: 2 months 2 weeks ago
Joined: 03/31/2022
Posts: 11
Wrapping a reader/writer in a class


I am attempting to wrap a DateReader/DataWriter in a class where the constructor handles all the details of creating the Reader/Writer, and the class functions provide a simplified interface to the developer with details being handled inside the class functions. I am trying to create a simple version based on the Hello World example. The barebones header I created looks like :

#include "hello_world.hpp"
class HelloWorldWriter
public :
private :
dds::pub::DataWriter<HelloWorld> m_writer;

Just trying this in the compiler get the error " 'DataWriter' in namespace 'dds::pub' does not name a template type ".
I suspect I am missing something fundamental in this approach, but all the example I have looked at do not do DateWriter wrapping.

Is there a good example I can look at ?

Dale Pennington

Last seen: 4 months 1 week ago
Joined: 11/14/2017
Posts: 28

Hi Dale,

Here's an example of wrapping data type support (pubs/subs) in a class, with a few demo programs showing usage.
The intent was to make it trivially easy to create pubs or subs (or both) for different data types, with very few lines of code in the main application.
Note that this might not offer the best solution for your needs, but it does wrap things in a class & might help resolve the build trouble you're seeing.


Last seen: 2 months 2 weeks ago
Joined: 03/31/2022
Posts: 11

Thanks, for the example. Got it to build (had to regen the .idl file as we have a newer  version of DDS), and figured out my current boneheaded mistake.