OctopOS
0.6.0
Data communication bus for SPACE HAUC
|
#include <subscriber.h>
Public Member Functions | |
subscriber (std::string topic_name, key_t shared_queue) | |
bool | data_available () |
T | get_data () |
Optional< T > | get_data_async () |
~subscriber () | |
Additional Inherited Members | |
Static Public Member Functions inherited from subscriber_manager | |
static void * | wait_for_data (void *data) |
Protected Types inherited from tentacle | |
enum | role_t { SUBSCRIBER, PUBLISHER } |
Protected Member Functions inherited from subscriber_manager | |
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 inherited from subscriber_manager | |
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 inherited from subscriber_manager | |
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_t > | topic_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 |
subscriber is used to retrtieve the data published to a topic so it can be used in the client application. This class provides an easy interface for reading off a topic's data_queue. T is the type of data assosciated with the topic.
|
inline |
Created a new subscriber to a specific topic. Intializes mutex and condition variable for data_queue protection.
topic_name | The Name of the topic to be subscribed to. |
shared_queue | The key for the message queue to construct a tentacle on. |
The lambda is the callback. It pushes the new data onto the data_queue.
|
inline |
Frees pthread primatives
|
inline |
Is data available to read?
|
inline |
Reads from the top of the data queue. If there is no data this will block untill signaled from the callback that there is data available.
|
inline |
Reads from the top of the data queue if there is data. Will not block and and returns an empty Optional. You must check if the data is defined before using it.