MADARA  3.2.3
madara::transport::Base Class Referenceabstract

Base class from which all transports must be derived. More...

#include <Transport.h>

Inheritance diagram for madara::transport::Base:
madara::transport::BasicASIOTransport madara::transport::NddsTransport madara::transport::SpliceDDSTransport madara::transport::ZMQTransport madara::transport::UdpTransport madara::transport::BroadcastTransport madara::transport::MulticastTransport madara::transport::UdpRegistryClient madara::transport::UdpRegistryServer

Public Types

typedef std::vector< std::string > HostsVector
 Used to define a vector of hosts to contact. More...
 

Public Member Functions

 Base (const std::string &id, TransportSettings &new_settings, knowledge::ThreadSafeContext &context)
 Constructor. More...
 
virtual ~Base ()=0
 Destructor. More...
 
int check_transport (void)
 all subclasses should call this method at the beginning of send_data More...
 
virtual void close (void)
 Closes this transport. More...
 
void invalidate_transport (void)
 Invalidates a transport to indicate it is shutting down. More...
 
long prep_send (const knowledge::VariableReferenceMap &orig_updates, const char *print_prefix)
 Preps a message for sending. More...
 
virtual long send_data (const knowledge::VariableReferenceMap &)=0
 Sends a list of updates to the domain. More...
 
TransportSettingssettings (void)
 Getter for the transport settings. More...
 
virtual int setup (void)
 all subclasses should call this method at the end of its setup More...
 
int validate_transport (void)
 Validates a transport to indicate it is not shutting down. More...
 

Protected Attributes

madara::utility::ScopedArray< char > buffer_
 buffer for sending More...
 
madara::knowledge::ThreadSafeContextcontext_
 
HostsVector hosts
 
const std::string id_
 host:port identifier of this process More...
 
volatile bool is_valid_
 
madara::expression::ExpressionTree on_data_received_
 data received rules, defined in Transport settings More...
 
PacketScheduler packet_scheduler_
 scheduler for dropping packets to simulate network issues More...
 
BandwidthMonitor receive_monitor_
 monitor for receiving bandwidth usage More...
 
BandwidthMonitor send_monitor_
 monitor for sending bandwidth usage More...
 
QoSTransportSettings settings_
 
volatile bool shutting_down_
 

Detailed Description

Base class from which all transports must be derived.

To support knowledge updates, only the send_multiassignment method is currently required to be extended as the set, evaluate, and wait methods all call send_multiassignment. For example transport,

See also
madara::transport::MulticastTransport.

Definition at line 45 of file Transport.h.

Member Typedef Documentation

typedef std::vector<std::string> madara::transport::Base::HostsVector

Used to define a vector of hosts to contact.

Definition at line 51 of file Transport.h.

Constructor & Destructor Documentation

madara::transport::Base::Base ( const std::string &  id,
TransportSettings new_settings,
knowledge::ThreadSafeContext context 
)

Constructor.

Parameters
idunique identifier (generally host:port)
new_settingssettings to apply to the transport
contextthe knowledge record context

Definition at line 11 of file Transport.cpp.

madara::transport::Base::~Base ( )
pure virtual

Destructor.

Definition at line 25 of file Transport.cpp.

Member Function Documentation

int madara::transport::Base::check_transport ( void  )
inline

all subclasses should call this method at the beginning of send_data

Definition at line 18 of file Transport.inl.

void madara::transport::Base::close ( void  )
virtual
void madara::transport::Base::invalidate_transport ( void  )
inline

Invalidates a transport to indicate it is shutting down.

Definition at line 33 of file Transport.inl.

long madara::transport::Base::prep_send ( const knowledge::VariableReferenceMap orig_updates,
const char *  print_prefix 
)

Preps a message for sending.

Parameters
orig_updatesupdates before send filtering is applied
print_prefixprefix to include before every log message, e.g., "MyTransport::svc"
Returns
-1 Transport is shutting down
-2 Transport is invalid
-3 Unable to allocate send buffer
0 No message to send > 0 size of buffered message

filter the updates according to the filters specified by the user in QoSTransportSettings (if applicable)

size = buffer[0] (unsigned 64 bit) transport id = buffer[8] (8 byte) domain = buffer[16] (32 byte domain name) originator = buffer[48] (64 byte originator host:port) type = buffer[112] (unsigned 32 bit type of message–usually MULTIASSIGN) updates = buffer[116] (unsigned 32 bit number of updates) quality = buffer[120] (unsigned 32 bit quality of message) clock = buffer[124] (unsigned 64 bit clock for this message) ttl = buffer[132] (the new knowledge starts here) knowledge = buffer[133] (the new knowledge starts here)

Definition at line 812 of file Transport.cpp.

virtual long madara::transport::Base::send_data ( const knowledge::VariableReferenceMap )
pure virtual

Sends a list of updates to the domain.

This function must be implemented by your transport

Default implementation constructs a KnowledgeRecords object and calls the deprecated version of send_data. This is expensive, so override this version instead.

Returns
result of operation or -1 if we are shutting down

Implemented in madara::transport::ZMQTransport, madara::transport::UdpRegistryClient, madara::transport::UdpTransport, madara::transport::SpliceDDSTransport, madara::transport::UdpRegistryServer, and madara::transport::NddsTransport.

madara::transport::TransportSettings & madara::transport::Base::settings ( void  )
inline

Getter for the transport settings.

Returns
the current transport settings

Definition at line 43 of file Transport.inl.

int madara::transport::Base::setup ( void  )
virtual
int madara::transport::Base::validate_transport ( void  )
inline

Validates a transport to indicate it is not shutting down.

Definition at line 6 of file Transport.inl.

Member Data Documentation

madara::utility::ScopedArray<char> madara::transport::Base::buffer_
protected

buffer for sending

Definition at line 154 of file Transport.h.

madara::knowledge::ThreadSafeContext& madara::transport::Base::context_
protected

Definition at line 136 of file Transport.h.

HostsVector madara::transport::Base::hosts
protected

Definition at line 128 of file Transport.h.

const std::string madara::transport::Base::id_
protected

host:port identifier of this process

Definition at line 131 of file Transport.h.

volatile bool madara::transport::Base::is_valid_
protected

Definition at line 126 of file Transport.h.

madara::expression::ExpressionTree madara::transport::Base::on_data_received_
protected

data received rules, defined in Transport settings

Definition at line 140 of file Transport.h.

PacketScheduler madara::transport::Base::packet_scheduler_
protected

scheduler for dropping packets to simulate network issues

Definition at line 151 of file Transport.h.

BandwidthMonitor madara::transport::Base::receive_monitor_
protected

monitor for receiving bandwidth usage

Definition at line 148 of file Transport.h.

BandwidthMonitor madara::transport::Base::send_monitor_
protected

monitor for sending bandwidth usage

Definition at line 145 of file Transport.h.

QoSTransportSettings madara::transport::Base::settings_
protected

Definition at line 133 of file Transport.h.

volatile bool madara::transport::Base::shutting_down_
protected

Definition at line 127 of file Transport.h.


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