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

#include <octopos.h>

Public Member Functions

 octopOS (octopOS const &)=delete
 
void operator= (octopOS const &)=delete
 
 ~octopOS ()
 
std::pair< unsigned, key_t > create_new_topic (std::string name, unsigned size)
 
bool propagate_to_subscribers (std::string name)
 
std::pair< unsigned, key_t > subscribe_to_topic (std::string name, unsigned tentacle, octopOS_id_t subscriber_id, long size=-1)
 

Static Public Member Functions

static octopOSgetInstance ()
 
static void * listen_for_child (void *tentacle_index_dynamic)
 
static void sig_handler (int sig)
 

Detailed Description

octopOS is the main control class. It is singleton so there can only ever be one instance. octopOS implements a light weight data bus on top of the IPC primatives. On destruction, or a deadly signal octopOS will free these resources befor terminating the program

Constructor & Destructor Documentation

◆ octopOS()

octopOS::octopOS ( octopOS const &  )
delete

copy constructor deleted to prevent accidental copying of class

◆ ~octopOS()

octopOS::~octopOS ( )

The constructor creates the neccecary shared memory segments, semaphors, and IPC message busses for the rest of the system to build on.

Member Function Documentation

◆ create_new_topic()

std::pair< unsigned, key_t > octopOS::create_new_topic ( std::string  name,
unsigned  size 
)

create_new_topic adds a new topic to octopOS that can be published to or subscreibed from.

Parameters
nameThe name of the new topic (will be used as it's identifier)
sizeThe amount of space need to store the data object associated with the topic.
Returns
a pair where the first is the offset of the data object in the shared memory segment, and the second is the key for the associated semaphore

◆ getInstance()

octopOS & octopOS::getInstance ( )
static

getInstance returns a reference to the single static instance of octopOS.

Returns
reference to running octopOS instance

◆ listen_for_child()

void * octopOS::listen_for_child ( void *  tentacle_index_dynamic)
static

listen_for_child listens for requestes from a child on a specific tentacle. It then routes the request and executes the proper octopOS code to complete the request. Function signature is designed to be used with pthread_create.

Parameters
tentacle_index_dynamicThe index in the global tentacle list to be listening on. Note: this should be a pointer to dynamically allocated memory containing the index value. This memory will be freed by this function.
Returns
NULL

◆ operator=()

void octopOS::operator= ( octopOS const &  )
delete

assignment operator deleted to prevent accidental copying of class

◆ propagate_to_subscribers()

bool octopOS::propagate_to_subscribers ( std::string  name)

propagate_to_subscribers sends a message to every subscriber of a topic alerting it that the data has for the topic has been updated.

Parameters
nameThe topic to propagate t.
Returns
true if propagation was successfull otherwise false.

◆ sig_handler()

void octopOS::sig_handler ( int  sig)
static

sig_handler provides a signal handler to clean up persistant resources in the case of total failure.

Parameters
sigThe number identifier of the signal caught

◆ subscribe_to_topic()

std::pair< unsigned, key_t > octopOS::subscribe_to_topic ( std::string  name,
unsigned  tentacle,
octopOS_id_t  subscriber_id,
long  size = -1 
)

subscribe_to_topic adds a subscriber to a topic's subscriber list.

Parameters
nameThe name of the topic to subscribe to.
tentacleThe tentacle that the subscription request is comming from. Need for later routing.
subscriber_idThe unique identifier of the subscriber.
sizeThe size of the topic data. Needed only if the topic does not exist so it can be created.
Returns
a pair where the first is the offset of the data object in the shared memory segment, and the second is the key for the associated semaphore

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