#include <FederatorConfig.h>
Public Member Functions | |
Config (int argc, ACE_TCHAR **argv) | |
Default constructor. | |
virtual | ~Config () |
int & | argc () |
Access the enhanced argv. | |
int | argc () const |
ACE_TCHAR **& | argv () |
Access the enhanced argc. | |
ACE_TCHAR ** | argv () const |
void | addArg (ACE_TCHAR *arg) |
Add an argument. | |
TAO_DDS_DCPSFederationId & | federationId () |
Federation Id value. | |
const TAO_DDS_DCPSFederationId & | federationId () const |
void | federationDomain (long domain) |
Federation Id value. | |
long | federationDomain () const |
void | federationPort (short port) |
Federation Port value. | |
short | federationPort () const |
void | federateIor (const tstring &ior) |
Initial federation IOR value. | |
tstring | federateIor () const |
void | configFile (const tstring &file) |
Configuration filename. | |
tstring | configFile () const |
Static Public Attributes | |
static const tstring | FEDERATOR_CONFIG_OPTION |
Command line option specifying the configuration file. | |
static const tstring | FEDERATOR_ID_OPTION |
Command line option specifying the federation Id value. | |
static const tstring | FEDERATE_WITH_OPTION |
Command line option specifying a repository to federate with. | |
Private Member Functions | |
void | processFile () |
Process a configuration file. | |
Private Attributes | |
int | argc_ |
Enhanced argc. | |
ACE_TCHAR ** | argv_ |
Enhanced argv. | |
tstring | configFile_ |
Configuration filename, if any. | |
tstring | federateIor_ |
Initial federation IOR, if any. | |
TAO_DDS_DCPSFederationId | federationId_ |
Configured Federation Id value. | |
long | federationDomain_ |
Configured Federation Domain value. | |
short | federationPort_ |
Configured Federation Port value. |
Definition at line 28 of file FederatorConfig.h.
OpenDDS::Federator::Config::Config | ( | int | argc, | |
ACE_TCHAR ** | argv | |||
) |
Default constructor.
Definition at line 190 of file FederatorConfig.cpp.
References ACE_TEXT(), argv_, OpenDDS::DCPS::DCPS_debug_level, LM_DEBUG, and processFile().
00191 : argc_(0), 00192 federationId_(hash_endpoints(argc, argv)), 00193 federationDomain_(DEFAULT_FEDERATIONDOMAIN), 00194 federationPort_(-1) 00195 { 00196 if (::OpenDDS::DCPS::DCPS_debug_level > 0) { 00197 ACE_DEBUG((LM_DEBUG, 00198 ACE_TEXT("(%P|%t) INFO: Federator::Config::Config()\n"))); 00199 } 00200 00201 // Setup the internal storage. 00202 this->argv_ = new ACE_TCHAR*[argc + 1](); // argv_[argc] == 0 00203 00204 // Process the federation arguments. Copy the uninteresting arguments verbatim. 00205 ArgCopier argCopier(this); 00206 std::for_each(&argv[0], &argv[ argc], argCopier); 00207 00208 // Read and process any configuration file. 00209 this->processFile(); 00210 }
OpenDDS::Federator::Config::~Config | ( | ) | [virtual] |
Definition at line 212 of file FederatorConfig.cpp.
References ACE_TEXT(), argv_, OpenDDS::DCPS::DCPS_debug_level, and LM_DEBUG.
00213 { 00214 if (::OpenDDS::DCPS::DCPS_debug_level > 0) { 00215 ACE_DEBUG((LM_DEBUG, 00216 ACE_TEXT("(%P|%t) INFO: Federator::Config::~FederatorConfig()\n"))); 00217 } 00218 00219 // We prwn this 00220 delete [] this->argv_; 00221 }
ACE_INLINE void OpenDDS::Federator::Config::addArg | ( | ACE_TCHAR * | arg | ) |
Add an argument.
Definition at line 40 of file FederatorConfig.inl.
Referenced by OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::ArgCopier::operator()().
ACE_INLINE int OpenDDS::Federator::Config::argc | ( | void | ) | const |
Definition at line 19 of file FederatorConfig.inl.
References argc_.
00020 { 00021 return this->argc_; 00022 }
OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int & OpenDDS::Federator::Config::argc | ( | void | ) |
Access the enhanced argv.
Definition at line 12 of file FederatorConfig.inl.
References argc_.
00013 { 00014 return this->argc_; 00015 }
ACE_INLINE ACE_TCHAR ** OpenDDS::Federator::Config::argv | ( | void | ) | const |
Definition at line 33 of file FederatorConfig.inl.
References argv_.
00034 { 00035 return this->argv_; 00036 }
ACE_INLINE ACE_TCHAR **& OpenDDS::Federator::Config::argv | ( | void | ) |
Access the enhanced argc.
Definition at line 26 of file FederatorConfig.inl.
References argv_.
Referenced by InfoRepo::init().
00027 { 00028 return this->argv_; 00029 }
ACE_INLINE OpenDDS::Federator::tstring OpenDDS::Federator::Config::configFile | ( | ) | const |
Definition at line 82 of file FederatorConfig.inl.
References configFile_.
00083 { 00084 return this->configFile_; 00085 }
ACE_INLINE void OpenDDS::Federator::Config::configFile | ( | const tstring & | file | ) |
Configuration filename.
Definition at line 75 of file FederatorConfig.inl.
References configFile_.
Referenced by OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::ArgCopier::operator()().
00076 { 00077 this->configFile_ = file; 00078 }
ACE_INLINE OpenDDS::Federator::tstring OpenDDS::Federator::Config::federateIor | ( | ) | const |
Definition at line 96 of file FederatorConfig.inl.
References federateIor_.
00097 { 00098 return this->federateIor_; 00099 }
ACE_INLINE void OpenDDS::Federator::Config::federateIor | ( | const tstring & | ior | ) |
Initial federation IOR value.
Definition at line 89 of file FederatorConfig.inl.
References federateIor_.
Referenced by InfoRepo::init(), and OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::ArgCopier::operator()().
00090 { 00091 this->federateIor_ = ior; 00092 }
ACE_INLINE long OpenDDS::Federator::Config::federationDomain | ( | ) | const |
Definition at line 54 of file FederatorConfig.inl.
References federationDomain_.
00055 { 00056 return this->federationDomain_; 00057 }
ACE_INLINE void OpenDDS::Federator::Config::federationDomain | ( | long | domain | ) |
Federation Id value.
Definition at line 47 of file FederatorConfig.inl.
References federationDomain_.
Referenced by OpenDDS::Federator::ManagerImpl::destroy(), InfoRepo::init(), OpenDDS::Federator::ManagerImpl::initialize(), OpenDDS::Federator::ManagerImpl::join_federation(), OpenDDS::Federator::ManagerImpl::pushState(), and OpenDDS::Federator::ManagerImpl::repository().
00048 { 00049 this->federationDomain_ = domain; 00050 }
ACE_INLINE const TAO_DDS_DCPSFederationId & OpenDDS::Federator::Config::federationId | ( | ) | const |
Definition at line 110 of file FederatorConfig.inl.
References federationId_.
00111 { 00112 return this->federationId_; 00113 }
ACE_INLINE TAO_DDS_DCPSFederationId & OpenDDS::Federator::Config::federationId | ( | ) |
Federation Id value.
Definition at line 103 of file FederatorConfig.inl.
References federationId_.
Referenced by OpenDDS::Federator::ManagerImpl::id(), InfoRepo::init(), and OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::ArgCopier::operator()().
00104 { 00105 return this->federationId_; 00106 }
ACE_INLINE short OpenDDS::Federator::Config::federationPort | ( | ) | const |
Definition at line 68 of file FederatorConfig.inl.
References federationPort_.
00069 { 00070 return this->federationPort_; 00071 }
ACE_INLINE void OpenDDS::Federator::Config::federationPort | ( | short | port | ) |
Federation Port value.
Definition at line 61 of file FederatorConfig.inl.
References federationPort_.
00062 { 00063 this->federationPort_ = port; 00064 }
void OpenDDS::Federator::Config::processFile | ( | ) | [private] |
Process a configuration file.
Definition at line 224 of file FederatorConfig.cpp.
References ACE_TEXT(), ACE_OS::atoi(), ACE_String_Base< ACE_CHAR_T >::c_str(), configFile_, OpenDDS::DCPS::DCPS_debug_level, federationDomain_, federationId_, federationPort_, ACE_Configuration_Heap::get_string_value(), TAO_DDS_DCPSFederationId::id(), LM_DEBUG, LM_ERROR, ACE_Configuration_Heap::open(), TAO_DDS_DCPSFederationId::overridden(), and ACE_Configuration::root_section().
Referenced by Config().
00225 { 00226 if (::OpenDDS::DCPS::DCPS_debug_level > 0) { 00227 ACE_DEBUG((LM_DEBUG, 00228 ACE_TEXT("(%P|%t) INFO: Federator::Config::process()\n"))); 00229 } 00230 00231 if (this->configFile_.empty()) { 00232 // No filename, no processing. 00233 return; 00234 } 00235 00236 // Grab a spot to stick the configuration. 00237 ACE_Configuration_Heap heap; 00238 00239 if (0 != heap.open()) { 00240 ACE_ERROR((LM_ERROR, 00241 ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ") 00242 ACE_TEXT("unable to open configuration heap.\n"))); 00243 return; 00244 } 00245 00246 // Import the file into our shiny new spot. 00247 ACE_Ini_ImpExp import(heap); 00248 00249 if (0 != import.import_config(this->configFile_.c_str())) { 00250 ACE_ERROR((LM_ERROR, 00251 ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ") 00252 ACE_TEXT("unable to import configuration file.\n"))); 00253 return; 00254 } 00255 00256 // Configuration file format: 00257 // 00258 // FederationDomain = <number> (REQUIRED) 00259 // FederationId = <number> (REQUIRED) 00260 // FederationPort = <number> (REQUIRED) 00261 // 00262 00263 // Grab the common configuration settings. 00264 const ACE_Configuration_Section_Key &root = heap.root_section(); 00265 00266 // Federation Domain value - REQUIRED 00267 ACE_TString federationDomainString; 00268 00269 if (0 != heap.get_string_value(root, FEDERATION_DOMAIN_KEY, federationDomainString)) { 00270 ACE_ERROR((LM_ERROR, 00271 ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ") 00272 ACE_TEXT("Unable to obtain value for FederationDomain in root section\n"))); 00273 return; 00274 } 00275 00276 // Convert to numeric repository key value. 00277 this->federationDomain_ = ACE_OS::atoi(federationDomainString.c_str()); 00278 00279 if (::OpenDDS::DCPS::DCPS_debug_level > 0) { 00280 ACE_DEBUG((LM_DEBUG, 00281 ACE_TEXT("(%P|%t) FederationDomain == %d\n"), 00282 this->federationDomain_)); 00283 } 00284 00285 // Federation Id value - REQUIRED 00286 ACE_TString federationIdString; 00287 00288 if (0 != heap.get_string_value(root, FEDERATION_ID_KEY, federationIdString)) { 00289 ACE_ERROR((LM_ERROR, 00290 ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ") 00291 ACE_TEXT("Unable to obtain value for FederationId in root section\n"))); 00292 return; 00293 } 00294 00295 // Convert to numeric repository key value. 00296 RepoKey idValue = ACE_OS::atoi(federationIdString.c_str()); 00297 00298 // Allow the command line to override the file value. 00299 if (this->federationId_.overridden()) { 00300 ACE_DEBUG((LM_DEBUG, 00301 ACE_TEXT("(%P|%t) FederationId == %d from file ") 00302 ACE_TEXT("overridden by value %d from command line.\n"), 00303 idValue, 00304 this->federationId_.id())); 00305 00306 } else { 00307 this->federationId_.id(idValue); 00308 00309 if (::OpenDDS::DCPS::DCPS_debug_level > 0) { 00310 ACE_DEBUG((LM_DEBUG, 00311 ACE_TEXT("(%P|%t) FederationId == %d\n"), 00312 this->federationId_.id())); 00313 } 00314 } 00315 00316 // Federation port value - REQUIRED 00317 ACE_TString federationPortString; 00318 00319 if (0 != heap.get_string_value(root, FEDERATION_PORT_KEY, federationPortString)) { 00320 ACE_ERROR((LM_ERROR, 00321 ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ") 00322 ACE_TEXT("Unable to obtain value for FederationPort in root section\n"))); 00323 return; 00324 } 00325 00326 // Convert to numeric repository key value. 00327 this->federationPort_ = ACE_OS::atoi(federationPortString.c_str()); 00328 00329 if (::OpenDDS::DCPS::DCPS_debug_level > 0) { 00330 ACE_DEBUG((LM_DEBUG, 00331 ACE_TEXT("(%P|%t) FederationPort == %d\n"), 00332 this->federationPort_)); 00333 } 00334 }
int OpenDDS::Federator::Config::argc_ [private] |
ACE_TCHAR** OpenDDS::Federator::Config::argv_ [private] |
Configuration filename, if any.
Definition at line 86 of file FederatorConfig.h.
Referenced by configFile(), and processFile().
const tstring OpenDDS::Federator::Config::FEDERATE_WITH_OPTION [static] |
Command line option specifying a repository to federate with.
Definition at line 37 of file FederatorConfig.h.
Referenced by OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::ArgCopier::operator()().
Initial federation IOR, if any.
Definition at line 89 of file FederatorConfig.h.
Referenced by federateIor().
long OpenDDS::Federator::Config::federationDomain_ [private] |
Configured Federation Domain value.
Definition at line 95 of file FederatorConfig.h.
Referenced by federationDomain(), and processFile().
Configured Federation Id value.
Definition at line 92 of file FederatorConfig.h.
Referenced by federationId(), and processFile().
short OpenDDS::Federator::Config::federationPort_ [private] |
Configured Federation Port value.
Definition at line 98 of file FederatorConfig.h.
Referenced by federationPort(), and processFile().
const tstring OpenDDS::Federator::Config::FEDERATOR_CONFIG_OPTION [static] |
Command line option specifying the configuration file.
Definition at line 31 of file FederatorConfig.h.
Referenced by OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::ArgCopier::operator()().
const tstring OpenDDS::Federator::Config::FEDERATOR_ID_OPTION [static] |
Command line option specifying the federation Id value.
Definition at line 34 of file FederatorConfig.h.
Referenced by OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::ArgCopier::operator()().