OctopOS  0.6.0
Data communication bus for SPACE HAUC
Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Static Protected Attributes | List of all members
subscriber_manager Class Reference

#include <subscriber.h>

Inheritance diagram for subscriber_manager:
tentacle subscriber< T >

Static Public Member Functions

static void * wait_for_data (void *data)
 

Protected Member Functions

 subscriber_manager (key_t shared_queue)
 
- Protected Member Functions inherited from tentacle
 tentacle (key_t msg_key)
 
bool write (long type, std::string data)
 
bool write (std::pair< long, std::string > pair)
 

Static Protected Member Functions

static bool register_cb (callback cb, std::string topic, uint size, subscriber_manager *sub)
 
- Static Protected Member Functions inherited from tentacle
static long getTempId (role_t role)
 
static std::pair< long, std::string > read (long type, bool block=true, bool under=false)
 

Static Protected Attributes

static std::unordered_map< std::string, std::tuple< sem_id_t, shm_object *, generic_t * > > topic_memory
 
static std::unordered_map< std::string, octopOS_id_ttopic_ids
 
static std::unordered_map< std::string, std::vector< callback > > registered_callbacks
 
static std::mutex topic_ids_lock
 
static std::mutex topic_memory_lock
 
static std::mutex registered_callbacks_lock
 
- Static Protected Attributes inherited from tentacle
static int message_que
 
static intptr_t * shared_data = NULL
 

Additional Inherited Members

- Protected Types inherited from tentacle
enum  role_t { SUBSCRIBER, PUBLISHER }
 

Detailed Description

subscriber_manager provides a base class with static maps that can be shared across the different templated child classes

Constructor & Destructor Documentation

◆ subscriber_manager()

subscriber_manager::subscriber_manager ( key_t  shared_queue)
inlineexplicitprotected

constructs subscriber_manager class. passes the message bus key to the parent tentacle.

Parameters
shared_queueThe message bus to construct a tentacle on.

Member Function Documentation

◆ register_cb()

bool subscriber_manager::register_cb ( callback  cb,
std::string  topic,
uint  size,
subscriber_manager sub 
)
staticprotected

Registers CB to topic; CB will be invoked when new data is available on topic

Parameters
cbThe callback to be registered for the topic.
topicThe name of the topic to register the callback to.
sizeThe size of the data object. Only used if a new topic must be created.
subA reference to the subscriber class invoking the static method.
Returns
true if registerd successfully, otherwise false.

◆ wait_for_data()

void * subscriber_manager::wait_for_data ( void *  data)
static

wait_for_data provides a "server" funtion that waits for updates notifications from octopOS and then adds the data to the data_queue of the different subscribers. Function signature is like this so it can easily be run in it's own thread.

Parameters
dataNot used
Returns
Will not return. This function loops infinatly.

Member Data Documentation

◆ registered_callbacks

std::unordered_map< std::string, std::vector< callback > > subscriber_manager::registered_callbacks
staticprotected
Initial value:
=
std::unordered_map<std::string, std::vector<callback> >()

topic_ids is a map which assosciates the topic name with its callbacks

◆ topic_ids

std::unordered_map< std::string, octopOS_id_t > subscriber_manager::topic_ids
staticprotected
Initial value:
=
std::unordered_map<std::string, octopOS_id_t>()

topic_ids is a map which assosciates the topic name with its unique identifier

◆ topic_ids_lock

std::mutex subscriber_manager::topic_ids_lock
staticprotected

mutex locks for the different member data v

◆ topic_memory

std::unordered_map< std::string, std::tuple< sem_id_t, shm_object *, generic_t * > > subscriber_manager::topic_memory
staticprotected
Initial value:
=
std::unordered_map<std::string,
std::tuple<sem_id_t, shm_object*, generic_t*>>()

topic_memory is a map which assosciates all the shared memory data with a topic name


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