TraveSim Adapters  0.1
Protobuf adapters for TraveSim project
travesim::TeamsConfigurer Class Reference

TeamsConfigurer class definition. More...

#include "teams_configurer.hpp"

Inheritance diagram for travesim::TeamsConfigurer:
Collaboration diagram for travesim::TeamsConfigurer:

Public Types

enum  TeamColor { YELLOW, BLUE }
 Team color enumeration type. More...
 

Public Member Functions

 TeamsConfigurer (void)
 Construct a new TeamsConfigurer object. More...
 
std::string get_address (TeamColor color)
 Get the configured address of a team. More...
 
uint16_t get_port (TeamColor color)
 Get the configured port of a team. More...
 
bool get_specific_source (void)
 Get the specific_source config. More...
 
- Public Member Functions inherited from travesim::AdapterConfigurer< travesim_adapters::TeamsConfig >
 AdapterConfigurer (void)
 Construct a new AdapterConfigurer object. More...
 
 AdapterConfigurer (std::string config_namespace)
 Construct a new AdapterConfigurer object. More...
 
bool get_reset (void)
 Get the reset config. More...
 

Friends

std::ostream & operator<< (std::ostream &output, const TeamsConfigurer &teams_conf)
 Output stream operator overloading. More...
 

Additional Inherited Members

- Protected Attributes inherited from travesim::AdapterConfigurer< travesim_adapters::TeamsConfig >
bool reconfigured
 
travesim_adapters::TeamsConfig config
 
boost::recursive_mutex mutex
 

Detailed Description

TeamsConfigurer class definition.

Definition at line 28 of file teams_configurer.hpp.

Member Enumeration Documentation

◆ TeamColor

Team color enumeration type.

Enumerator
YELLOW 
BLUE 

Definition at line 34 of file teams_configurer.hpp.

Constructor & Destructor Documentation

◆ TeamsConfigurer()

travesim::TeamsConfigurer::TeamsConfigurer ( void  )

Construct a new TeamsConfigurer object.

Definition at line 28 of file teams_configurer.cpp.

30 }
AdapterConfigurer(void)
Construct a new AdapterConfigurer object.
#define TEAMS_CONFIGURER_NAMESPACE

Member Function Documentation

◆ get_address()

std::string travesim::TeamsConfigurer::get_address ( TeamColor  color)

Get the configured address of a team.

Parameters
colorColor of the team to get the address
Returns
std::string address string

Definition at line 32 of file teams_configurer.cpp.

32  {
33  boost::recursive_mutex::scoped_lock scoped_lock(this->mutex);
34 
35  std::string address;
36 
37  if (color == TeamColor::YELLOW) {
38  address = this->config.yellow_team_address;
39  } else {
40  address = this->config.blue_team_address;
41  }
42 
44 
45  if (validation == IPValidation::VALID) {
46  return address;
47  } else {
48  ROS_ERROR_STREAM(get_error_msg(validation));
49 
50  return INVALID_ADDRESS;
51  }
52 }
IPValidation
Type used to validate a IP string.
std::string get_error_msg(IPValidation error)
Get the error msg based on the validation type.
IPValidation check_valid_ip(std::string ip, std::string min_ip, std::string max_ip)
Checks if a IP is valid and is in the specified range.
#define MIN_UNICAST_ADDRESS
#define MAX_UNICAST_ADDRESS
#define INVALID_ADDRESS

References travesim::check_valid_ip(), travesim::AdapterConfigurer< travesim_adapters::TeamsConfig >::config, travesim::get_error_msg(), INVALID_ADDRESS, MAX_UNICAST_ADDRESS, MIN_UNICAST_ADDRESS, travesim::AdapterConfigurer< travesim_adapters::TeamsConfig >::mutex, and travesim::VALID.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_port()

uint16_t travesim::TeamsConfigurer::get_port ( TeamColor  color)

Get the configured port of a team.

Parameters
colorColor of the team to get the port
Returns
uint16_t port number

Definition at line 54 of file teams_configurer.cpp.

54  {
55  boost::recursive_mutex::scoped_lock scoped_lock(this->mutex);
56 
57  if (color == TeamColor::YELLOW) {
58  return this->config.yellow_team_port;
59  } else {
60  return this->config.blue_team_port;
61  }
62 }

References travesim::AdapterConfigurer< travesim_adapters::TeamsConfig >::config, and travesim::AdapterConfigurer< travesim_adapters::TeamsConfig >::mutex.

Here is the caller graph for this function:

◆ get_specific_source()

bool travesim::TeamsConfigurer::get_specific_source ( void  )

Get the specific_source config.

Returns
true if specific source is enabled, false otherwise

Definition at line 64 of file teams_configurer.cpp.

64  {
65  boost::recursive_mutex::scoped_lock scoped_lock(this->mutex);
66  return this->config.specific_source;
67 }

References travesim::AdapterConfigurer< travesim_adapters::TeamsConfig >::config, and travesim::AdapterConfigurer< travesim_adapters::TeamsConfig >::mutex.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  output,
const TeamsConfigurer teams_conf 
)
friend

Output stream operator overloading.

Definition at line 69 of file teams_configurer.cpp.

69  {
70  output << "Yellow Team Endpoint: " << teams_conf.config.yellow_team_address;
71  output << ":" << teams_conf.config.yellow_team_port << std::endl;
72  output << "Blue Team Endpoint: " << teams_conf.config.blue_team_address;
73  output << ":" << teams_conf.config.blue_team_port << std::endl;
74  output << "Specific Source: " << (teams_conf.config.specific_source ? "True" : "False") << std::endl;
75  output << "Reset: " << ((teams_conf.config.reset || teams_conf.reconfigured) ? "True" : "False") << std::endl;
76 
77  return output;
78 }

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