VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
G::PublisherChannel Class Reference

A named publisher channel that can be subscribed to. More...

#include <gpublisher.h>

Public Member Functions

 PublisherChannel (const std::string &channel_name, const std::string &socket_path_prefix=std::string())
 Constructor. More...
 
 ~PublisherChannel ()
 Destructor.
 
PublisherSubscribersubscribe ()
 Subscribes to the publisher returning a new()ed object. More...
 
bool receive (size_t, int, std::vector< char > &, std::string *=nullptr, G::EpochTime *=nullptr)
 Used by PublisherSubscriber.
 
void releaseSlot (size_t slot_id)
 Used by PublisherSubscriber.
 
std::string name () const
 Returns the channel name, as passed in to the constructor.
 

Detailed Description

A named publisher channel that can be subscribed to.

Definition at line 139 of file gpublisher.h.

Constructor & Destructor Documentation

G::PublisherChannel::PublisherChannel ( const std::string &  channel_name,
const std::string &  socket_path_prefix = std::string() 
)
explicit

Constructor.

The socket path prefix should be an absolute path with a basename; the actual path will have ".<pid>" added. The default is "/tmp/<channel_name>".

The implementation maps the publisher's 'control' memory segment.

Definition at line 310 of file gpublisher.cpp.

Member Function Documentation

G::PublisherSubscriber * G::PublisherChannel::subscribe ( )

Subscribes to the publisher returning a new()ed object.

Notification is via a named socket. The actual socket name is the given prefix (or some sensible default) plus ".<pid>". The lifetime of the subscriber object must be less than the lifetime of the channel.

The implementation creates a socket, grabs a free slot in the control memory segment, and installs the socket file descriptor in the slot. The slot and the socket are freed in the PublisherSubscriber's destructor.

Definition at line 327 of file gpublisher.cpp.


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