TraveSim Adapters  0.1
Protobuf adapters for TraveSim project
replacer_configurer.cpp
Go to the documentation of this file.
1 /**
2  * @file replacer_configurer.cpp
3  *
4  * @author Lucas Haug <lucas.haug@thuneratz.org>
5  *
6  * @brief Configurer for the Replacer
7  *
8  * @date 06/2021
9  *
10  * @copyright MIT License - Copyright (c) 2021 ThundeRatz
11  *
12  */
13 
16 
17 /*****************************************
18  * Private Constants
19  *****************************************/
20 
21 #define REPLACER_CONFIGURER_NAMESPACE BASE_CONFIGURER_NAMESPACE "replacer"
22 
23 namespace travesim {
24 /*****************************************
25  * Public Methods Bodies Definitions
26  *****************************************/
27 
30 }
31 
33  boost::recursive_mutex::scoped_lock scoped_lock(this->mutex);
34 
35  std::string address = this->config.replacer_address;
36 
38 
39  if (validation == IPValidation::VALID) {
40  return address;
41  } else {
42  ROS_ERROR_STREAM(get_error_msg(validation));
43 
44  return INVALID_ADDRESS;
45  }
46 }
47 
49  boost::recursive_mutex::scoped_lock scoped_lock(this->mutex);
50  return this->config.replacer_port;
51 }
52 
54  boost::recursive_mutex::scoped_lock scoped_lock(this->mutex);
55  return this->config.specific_source;
56 }
57 
58 std::ostream& operator <<(std::ostream& output, const ReplacerConfigurer& repl_conf) {
59  output << "Replacer Endpoint: " << repl_conf.config.replacer_address;
60  output << ":" << repl_conf.config.replacer_port << std::endl;
61  output << "Specific Source: " << (repl_conf.config.specific_source ? "True" : "False") << std::endl;
62  output << "Reset: " << ((repl_conf.config.reset || repl_conf.reconfigured) ? "True" : "False") << std::endl;
63 
64  return output;
65 }
66 }
std::string get_address(void)
Get the replacer configured address.
#define REPLACER_CONFIGURER_NAMESPACE
IPValidation
Type used to validate a IP string.
bool get_specific_source(void)
Get the specific_source config.
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.
Configurer for the Replacer.
Configurers utilitary funtions.
uint16_t get_port(void)
Get the replacer configured port.
#define MIN_UNICAST_ADDRESS
ReplacerConfigurer class definition.
std::ostream & operator<<(std::ostream &output, const ReplacerConfigurer &repl_conf)
#define MAX_UNICAST_ADDRESS
#define INVALID_ADDRESS
ReplacerConfigurer(void)
Construct a new ReplacerConfigurer object.