Options to be used when constructing the Manager. More...
#include <manager.h>
Public Member Functions | |
ManagerOptions & | bandwidth_bps (std::size_t bytes_per_second) |
Sets the hard limit for bandwidth. | |
ManagerOptions & | compressor (boost::shared_ptr< Compressor > const &compressor) |
Sets the compressor to be used. | |
ManagerOptions & | long_marshall (buffer_function_type const &long_marshall) |
Sets the function that creates long round packets. | |
ManagerOptions & | long_unmarshall (id_buffer_function_type const &long_unmarshall) |
Sets the function that interprets long round packets. | |
ManagerOptions (uint8_t sid, uint8_t num_sids, std::string const &multicast_address) | |
Constructor. | |
ManagerOptions & | max_lost (unsigned max_lost) |
Sets the maximum number of lost packets. | |
ManagerOptions & | offline_handler (id_function_type const &offline_handler) |
Sets the handler for agent deactivation event. | |
ManagerOptions & | online_handler (id_function_type const &online_handler) |
Sets the handler for agent activation event. | |
ManagerOptions & | ports (unsigned short long_port, unsigned short short_port) |
Sets the ports to be used. | |
ManagerOptions & | short_handler (handler_function_type const &short_handler) |
Sets the function that interprets short round packets. | |
ManagerOptions & | short_max_mine_simultaneous (std::size_t short_max_mine_simultaneous) |
Sets the maximum number of simultaneous short rounds. | |
ManagerOptions & | short_slot_us (unsigned short_slot_us) |
Sets the slot duration for the short rounds. | |
ManagerOptions & | short_wait_us (unsigned short_wait_us) |
Sets the waiting time for the short rounds. | |
ManagerOptions & | tup_ms (unsigned tup_ms) |
Sets the team update period. | |
ManagerOptions & | tup_us (unsigned tup_us) |
Sets the team update period. | |
Private Attributes | |
std::size_t | bytes_per_second_ |
boost::shared_ptr< Compressor > | compressor_ |
buffer_function_type | long_marshall_ |
id_buffer_function_type | long_unmarshall_ |
unsigned | max_lost_ |
std::string const & | multicast_address_ |
unsigned short | multicast_long_port_ |
unsigned short | multicast_short_port_ |
uint8_t | num_sids_ |
id_function_type | offline_handler_ |
id_function_type | online_handler_ |
handler_function_type | short_handler_ |
std::size_t | short_max_mine_simultaneous_ |
unsigned | short_slot_us_ |
unsigned | short_wait_us_ |
uint8_t | sid_ |
unsigned | tup_us_ |
Friends | |
class | Manager |
Options to be used when constructing the Manager.
This class is a simple container of options, to be passed to the Manager constructor to be used there.
socrob::multicast::ManagerOptions::ManagerOptions | ( | uint8_t | sid, |
uint8_t | num_sids, | ||
std::string const & | multicast_address | ||
) | [inline] |
Constructor.
The ManagerOptions constructor takes three parameters that must always be specified.
sid | The static ID of the agent. Must be different for all agents participating. |
num_sids | The maximum number of agents. Must be the same for all agents. |
multicast_address | The address to be used to create the multicast sockets. |
ManagerOptions& socrob::multicast::ManagerOptions::bandwidth_bps | ( | std::size_t | bytes_per_second | ) | [inline] |
Sets the hard limit for bandwidth.
Sets the hard limit for bandwidth. Special value 0 disables the hard limit. By default, the bandwidth is not limited.
bytes_per_second | Maximum bandwidth in bytes per second, 0 means unlimited. |
ManagerOptions& socrob::multicast::ManagerOptions::compressor | ( | boost::shared_ptr< Compressor > const & | compressor | ) | [inline] |
Sets the compressor to be used.
Sets the compressor to be used by both the long and the sort rounds. It must inherit from the Compressor class and be thread safe. It will automatically be used as a filter to encode all transmissions and decode all received packets. The compressor must be the same for the whole team. By default, no compression is used.
compressor | Shared pointer to the compressor. |
ManagerOptions& socrob::multicast::ManagerOptions::long_marshall | ( | buffer_function_type const & | long_marshall | ) | [inline] |
Sets the function that creates long round packets.
Sets the function responsible for creation of long round packets. This function will be called at the appropriate moment to generate a packet to be transmitted in the long rounds. Please note that this function might be called simultaneously with other functions from different threads.
long_marshall | Long round packet creator function. |
ManagerOptions& socrob::multicast::ManagerOptions::long_unmarshall | ( | id_buffer_function_type const & | long_unmarshall | ) | [inline] |
Sets the function that interprets long round packets.
Sets the function responsible to interpret long round packets. This function will be called whenever a packet from any agent arrives in the long rounds. Please note that this function might be called simultaneously with other functions from different threads. Please note that this function might be called many times simultaneously.
long_unmarshall | Long round packet interpreter function. |
ManagerOptions& socrob::multicast::ManagerOptions::max_lost | ( | unsigned | max_lost | ) | [inline] |
Sets the maximum number of lost packets.
Sets the maximum number of consecutive rounds in which no packet from a given agent is received. After this number of rounds, the agent is removed from the team. By default, this is 10. Using the default team update period of 0,1 seconds, an agent will be removed from the team after 1 second of silence.
max_lost | Maximum number of lost packets. |
ManagerOptions& socrob::multicast::ManagerOptions::offline_handler | ( | id_function_type const & | offline_handler | ) | [inline] |
Sets the handler for agent deactivation event.
Sets the function to be called when an agent is determined to be not running. Please note that this function might be called simultaneously with other functions from different threads.
offline_handler | Agent deactivation handler. |
ManagerOptions& socrob::multicast::ManagerOptions::online_handler | ( | id_function_type const & | online_handler | ) | [inline] |
Sets the handler for agent activation event.
Sets the function to be called when the first transmission from an agent is received. Please note that this function might be called simultaneously with other functions from different threads.
online_handler | Agent activation handler. |
ManagerOptions& socrob::multicast::ManagerOptions::ports | ( | unsigned short | long_port, |
unsigned short | short_port | ||
) | [inline] |
Sets the ports to be used.
Sets the ports to be used for the multicast sockets. Two ports are necessary, one for short rounds and another for long rounds. The two ports must be different. The ports must be the same for the whole team. By default, ports 2000 and 2001 are used.
long_port | Port to be used by the long round manager. |
short_port | Port to be used by the short round manager. |
ManagerOptions& socrob::multicast::ManagerOptions::short_handler | ( | handler_function_type const & | short_handler | ) | [inline] |
Sets the function that interprets short round packets.
Sets the function responsible to interpret short rounds packets. This function will be called whenever a packet containing a question arrives in the short rounds. As soon as the answer is transmitted, data about the question round is deleted. Therefore, if another packet arrives with the same answer, this function will be called again. This can be a problem, depending on the question semantics. If you need to ignore duplicates, you must implement your own method. One possibility is including an identifier in the question and keep track of already answered questions, ignoring duplicates. Be careful with what happens when one agent is restarted with the system running. Using timestamps instead of identifiers might be simpler. Please note that this function might be called from inside startShortRound. Please note that this function might be called simultaneously with other functions from different threads.
short_handler | Short round packet interpreter function. |
ManagerOptions& socrob::multicast::ManagerOptions::short_max_mine_simultaneous | ( | std::size_t | short_max_mine_simultaneous | ) | [inline] |
Sets the maximum number of simultaneous short rounds.
Sets the maximum number of short rounds started by this agent which can be active simultaneously. If this agent keeps starting short rounds before the previous ones are resolved, after this number of rounds new attempts to start a short round will fail, ignoring the attempt. By default, the maximum number of simultaneous short rounds started by one agent is 4.
short_max_mine_simultaneous | Maximum number of simultaneous short rounds. |
ManagerOptions& socrob::multicast::ManagerOptions::short_slot_us | ( | unsigned | short_slot_us | ) | [inline] |
Sets the slot duration for the short rounds.
Sets the slot duration to be used in the short rounds, which is the maximum interval between transmissions of any agent active in a short round. This value must be the same for the whole team. By default, the slot duration is 5 milliseconds.
short_slot_us | Slot duration in microseconds. |
ManagerOptions& socrob::multicast::ManagerOptions::short_wait_us | ( | unsigned | short_wait_us | ) | [inline] |
Sets the waiting time for the short rounds.
Sets the waiting time to be used by the short rounds, which is the time that an agent waits before transmitting, after receiving a packet from the agent that was expected to transmit right before. When this happens, the slot duration is ignored. This value must be the same for the whole team. By default, the waiting time is 1 millisecond.
short_wait_us | Waiting time in microseconds. |
ManagerOptions& socrob::multicast::ManagerOptions::tup_ms | ( | unsigned | tup_ms | ) | [inline] |
Sets the team update period.
Sets the team update period for the agent, which is the minimum interval between transmissions of each agent (it may be enlarged due to delays). This value must be the same for the whole team. By default, the team update period is 0,1 seconds.
tup_ms | Team update period in milliseconds. |
ManagerOptions& socrob::multicast::ManagerOptions::tup_us | ( | unsigned | tup_us | ) | [inline] |
Sets the team update period.
Sets the team update period for the agent, which is the minimum interval between transmissions of each agent (it may be enlarged due to delays). This value must be the same for the whole team. By default, the team update period is 0,1 seconds.
tup_us | Team update period in microseconds. |
std::size_t socrob::multicast::ManagerOptions::bytes_per_second_ [private] |
boost::shared_ptr<Compressor> socrob::multicast::ManagerOptions::compressor_ [private] |
unsigned socrob::multicast::ManagerOptions::max_lost_ [private] |
std::string const& socrob::multicast::ManagerOptions::multicast_address_ [private] |
unsigned short socrob::multicast::ManagerOptions::multicast_long_port_ [private] |
unsigned short socrob::multicast::ManagerOptions::multicast_short_port_ [private] |
uint8_t socrob::multicast::ManagerOptions::num_sids_ [private] |
std::size_t socrob::multicast::ManagerOptions::short_max_mine_simultaneous_ [private] |
unsigned socrob::multicast::ManagerOptions::short_slot_us_ [private] |
unsigned socrob::multicast::ManagerOptions::short_wait_us_ [private] |
uint8_t socrob::multicast::ManagerOptions::sid_ [private] |
unsigned socrob::multicast::ManagerOptions::tup_us_ [private] |