MADARA  3.4.1
madara::transport::TransportContext Class Reference

Provides context about the transport. More...

#include <TransportContext.h>

Public Types

enum  Operations { IDLE_OPERATION = 0 , SENDING_OPERATION = 1 , RECEIVING_OPERATION = 2 , REBROADCASTING_OPERATION = 3 }
 

Public Member Functions

 TransportContext (const TransportContext &rhs)
 Copy constructor. More...
 
 TransportContext (int64_t operation=IDLE_OPERATION, uint64_t receive_bandwidth=0, uint64_t send_bandwidth=0, uint64_t message_time=0, uint64_t current_time=utility::get_time(), const std::string &domain="", const std::string &originator="", const std::string &endpoint="")
 Constructor. More...
 
 ~TransportContext ()
 Destructor. More...
 
void add_record (const std::string &key, const madara::knowledge::KnowledgeRecord &record)
 Adds a record to the list that should be appended to send or rebroadcast. More...
 
void clear_records (void)
 Clears records added through filtering operations. More...
 
uint64_t get_current_time (void) const
 Gets the current timestamp. More...
 
const std::string & get_domain (void) const
 Returns the network domain. More...
 
const std::string & get_endpoint (void) const
 Returns the current message endpoint. More...
 
uint64_t get_message_time (void) const
 Gets the message timestamp. More...
 
int64_t get_operation (void) const
 Get operation that the context is performing. More...
 
const std::string & get_originator (void) const
 Returns the current message originator. More...
 
uint64_t get_receive_bandwidth (void) const
 Gets the receive bandwidth in bytes per second. More...
 
const knowledge::KnowledgeMapget_records (void) const
 Returns the additional records stored in the context. More...
 
uint64_t get_send_bandwidth (void) const
 Gets the send/rebroadcast bandwidth in bytes per second. More...
 
void operator= (const TransportContext &rhs)
 Assignment operator. More...
 
void set_current_time (uint64_t current_time)
 Sets the current time. More...
 
void set_domain (const std::string &domain)
 Sets the network domain. More...
 
void set_endpoint (const std::string &endpoint)
 Sets the current message endpoint. More...
 
void set_message_time (uint64_t message_time)
 Sets the message time. More...
 
void set_operation (int64_t operation)
 Sets the operation that the context is/should be performing. More...
 
void set_originator (const std::string &originator)
 Sets the current message originator. More...
 
void set_receive_bandwidth (uint64_t bandwidth)
 Sets the bandwidth used for receives in bytes per second. More...
 
void set_records (const knowledge::KnowledgeMap &source)
 Sets the current message originator. More...
 
void set_send_bandwidth (uint64_t bandwidth)
 Sets the bandwidth used for sends/rebroadcast in bytes per second. More...
 

Private Attributes

uint64_t current_time_
 Current timestamp. More...
 
std::string domain_
 Networking domain. More...
 
std::string endpoint_
 Public endpoint of the current message. More...
 
uint64_t message_time_
 Message timestamp. More...
 
int64_t operation_
 Operation being performed. More...
 
std::string originator_
 Originator of the current message. More...
 
uint64_t receive_bandwidth_
 Bandwidth being utilized for receive operations. More...
 
knowledge::KnowledgeMap records_
 Context specific records. More...
 
uint64_t send_bandwidth_
 Bandwidth being utilized for send operations. More...
 

Detailed Description

Provides context about the transport.

Definition at line 19 of file TransportContext.h.

Member Enumeration Documentation

◆ Operations

Enumerator
IDLE_OPERATION 
SENDING_OPERATION 
RECEIVING_OPERATION 
REBROADCASTING_OPERATION 

Definition at line 22 of file TransportContext.h.

Constructor & Destructor Documentation

◆ TransportContext() [1/2]

madara::transport::TransportContext::TransportContext ( int64_t  operation = IDLE_OPERATION,
uint64_t  receive_bandwidth = 0,
uint64_t  send_bandwidth = 0,
uint64_t  message_time = 0,
uint64_t  current_time = utility::get_time(),
const std::string &  domain = "",
const std::string &  originator = "",
const std::string &  endpoint = "" 
)

Constructor.

Definition at line 4 of file TransportContext.cpp.

◆ TransportContext() [2/2]

madara::transport::TransportContext::TransportContext ( const TransportContext rhs)

Copy constructor.

Parameters
rhsthe value to be copied into this class

Definition at line 19 of file TransportContext.cpp.

◆ ~TransportContext()

madara::transport::TransportContext::~TransportContext ( )

Destructor.

Definition at line 33 of file TransportContext.cpp.

Member Function Documentation

◆ add_record()

void madara::transport::TransportContext::add_record ( const std::string &  key,
const madara::knowledge::KnowledgeRecord record 
)
inline

Adds a record to the list that should be appended to send or rebroadcast.

Parameters
keykey of the record to add
recordrecord to add to the append list

Definition at line 70 of file TransportContext.inl.

◆ clear_records()

void madara::transport::TransportContext::clear_records ( void  )
inline

Clears records added through filtering operations.

Definition at line 6 of file TransportContext.inl.

◆ get_current_time()

uint64_t madara::transport::TransportContext::get_current_time ( void  ) const
inline

Gets the current timestamp.

Returns
current time in nanoseconds

Definition at line 28 of file TransportContext.inl.

◆ get_domain()

const std::string & madara::transport::TransportContext::get_domain ( void  ) const
inline

Returns the network domain.

Returns
the current knowledge domain

Definition at line 88 of file TransportContext.inl.

◆ get_endpoint()

const std::string & madara::transport::TransportContext::get_endpoint ( void  ) const
inline

Returns the current message endpoint.

Endpoint is the public host:port information about how to actually contact the sender, whereas originator is the declared identifier of the sender.

Returns
endpoint the public host:port information for the sender

Definition at line 112 of file TransportContext.inl.

◆ get_message_time()

uint64_t madara::transport::TransportContext::get_message_time ( void  ) const
inline

Gets the message timestamp.

For receive and rebroadcast operations, this timestamp will be the time that the message was originally sent. For send operations, this timestamp is typically the same as the current timestamp.

Returns
timestamp of message

Definition at line 34 of file TransportContext.inl.

◆ get_operation()

int64_t madara::transport::TransportContext::get_operation ( void  ) const
inline

Get operation that the context is performing.

Returns
operation being performed. See enums in this class.

Definition at line 11 of file TransportContext.inl.

◆ get_originator()

const std::string & madara::transport::TransportContext::get_originator ( void  ) const
inline

Returns the current message originator.

Returns
the originator of current message

Definition at line 100 of file TransportContext.inl.

◆ get_receive_bandwidth()

uint64_t madara::transport::TransportContext::get_receive_bandwidth ( void  ) const
inline

Gets the receive bandwidth in bytes per second.

Returns
the bandwidth taken up in receive operations

Definition at line 16 of file TransportContext.inl.

◆ get_records()

const madara::knowledge::KnowledgeMap & madara::transport::TransportContext::get_records ( void  ) const
inline

Returns the additional records stored in the context.

Returns
records to add to context

Definition at line 77 of file TransportContext.inl.

◆ get_send_bandwidth()

uint64_t madara::transport::TransportContext::get_send_bandwidth ( void  ) const
inline

Gets the send/rebroadcast bandwidth in bytes per second.

Returns
the bandwidth taken up in send/rebroadcast operations

Definition at line 22 of file TransportContext.inl.

◆ operator=()

void madara::transport::TransportContext::operator= ( const TransportContext rhs)

Assignment operator.

Parameters
rhsthe value to be copied into this class

Definition at line 35 of file TransportContext.cpp.

◆ set_current_time()

void madara::transport::TransportContext::set_current_time ( uint64_t  current_time)
inline

Sets the current time.

This should be utility::get_time ().

Parameters
current_timethe current time in nanoseconds

Definition at line 58 of file TransportContext.inl.

◆ set_domain()

void madara::transport::TransportContext::set_domain ( const std::string &  domain)
inline

Sets the network domain.

Parameters
domainthe knowledge domain

Definition at line 82 of file TransportContext.inl.

◆ set_endpoint()

void madara::transport::TransportContext::set_endpoint ( const std::string &  endpoint)
inline

Sets the current message endpoint.

Endpoint is the public host:port information about how to actually contact the sender, whereas originator is the declared identifier of the sender.

Parameters
endpointthe public host:port information for the sender

Definition at line 106 of file TransportContext.inl.

◆ set_message_time()

void madara::transport::TransportContext::set_message_time ( uint64_t  message_time)
inline

Sets the message time.

For receive and rebroadcast operations, this timestamp will be the time that the message was originally sent. For send operations, this timestamp is typically the same as the current timestamp.

Parameters
message_timethe message time in seconds

Definition at line 64 of file TransportContext.inl.

◆ set_operation()

void madara::transport::TransportContext::set_operation ( int64_t  operation)
inline

Sets the operation that the context is/should be performing.

Parameters
operationoperation the context is undertaking

Definition at line 40 of file TransportContext.inl.

◆ set_originator()

void madara::transport::TransportContext::set_originator ( const std::string &  originator)
inline

Sets the current message originator.

Parameters
originatorthe originator of the current message

Definition at line 94 of file TransportContext.inl.

◆ set_receive_bandwidth()

void madara::transport::TransportContext::set_receive_bandwidth ( uint64_t  bandwidth)
inline

Sets the bandwidth used for receives in bytes per second.

Parameters
bandwidthbandwidth being used by the transport

Definition at line 46 of file TransportContext.inl.

◆ set_records()

void madara::transport::TransportContext::set_records ( const knowledge::KnowledgeMap source)
inline

Sets the current message originator.

Parameters
sourcethe source record map to set

Definition at line 118 of file TransportContext.inl.

◆ set_send_bandwidth()

void madara::transport::TransportContext::set_send_bandwidth ( uint64_t  bandwidth)
inline

Sets the bandwidth used for sends/rebroadcast in bytes per second.

Parameters
bandwidthbandwidth being used by the transport

Definition at line 52 of file TransportContext.inl.

Member Data Documentation

◆ current_time_

uint64_t madara::transport::TransportContext::current_time_
private

Current timestamp.

Definition at line 215 of file TransportContext.h.

◆ domain_

std::string madara::transport::TransportContext::domain_
private

Networking domain.

Definition at line 220 of file TransportContext.h.

◆ endpoint_

std::string madara::transport::TransportContext::endpoint_
private

Public endpoint of the current message.

This may be different from originator as originator is the declared id of the agent sending. Endpoint is the public ip:port information that the underlying socket is claiming the message comes from. This is an important distinction in NAT-based networking.

Definition at line 235 of file TransportContext.h.

◆ message_time_

uint64_t madara::transport::TransportContext::message_time_
private

Message timestamp.

Definition at line 210 of file TransportContext.h.

◆ operation_

int64_t madara::transport::TransportContext::operation_
private

Operation being performed.

Definition at line 195 of file TransportContext.h.

◆ originator_

std::string madara::transport::TransportContext::originator_
private

Originator of the current message.

Definition at line 225 of file TransportContext.h.

◆ receive_bandwidth_

uint64_t madara::transport::TransportContext::receive_bandwidth_
private

Bandwidth being utilized for receive operations.

Definition at line 200 of file TransportContext.h.

◆ records_

knowledge::KnowledgeMap madara::transport::TransportContext::records_
private

Context specific records.

Definition at line 240 of file TransportContext.h.

◆ send_bandwidth_

uint64_t madara::transport::TransportContext::send_bandwidth_
private

Bandwidth being utilized for send operations.

Definition at line 205 of file TransportContext.h.


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