#include <FederatorConfig.h>
Collaboration diagram for OpenDDS::Federator::Config:
Public Member Functions | |
Config (int argc, ACE_TCHAR **argv) | |
Default constructor. | |
virtual | ~Config () |
Virtual destructor. | |
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 26 of file FederatorConfig.h.
OpenDDS::Federator::Config::Config | ( | int | argc, | |
ACE_TCHAR ** | argv | |||
) |
Default constructor.
Definition at line 188 of file FederatorConfig.cpp.
References argv_, OpenDDS::DCPS::DCPS_debug_level, and processFile().
00189 : argc_(0), 00190 federationId_(hash_endpoints(argc, argv)), 00191 federationDomain_(DEFAULT_FEDERATIONDOMAIN), 00192 federationPort_(-1) 00193 { 00194 if (::OpenDDS::DCPS::DCPS_debug_level > 0) { 00195 ACE_DEBUG((LM_DEBUG, 00196 ACE_TEXT("(%P|%t) INFO: Federator::Config::Config()\n"))); 00197 } 00198 00199 // Setup the internal storage. 00200 this->argv_ = new ACE_TCHAR*[ argc]; 00201 00202 // Process the federation arguments. Copy the uninteresting arguments verbatim. 00203 ArgCopier argCopier(this); 00204 std::for_each(&argv[0], &argv[ argc], argCopier); 00205 00206 // Read and process any configuration file. 00207 this->processFile(); 00208 }
OpenDDS::Federator::Config::~Config | ( | ) | [virtual] |
Virtual destructor.
Definition at line 210 of file FederatorConfig.cpp.
References argv_, and OpenDDS::DCPS::DCPS_debug_level.
00211 { 00212 if (::OpenDDS::DCPS::DCPS_debug_level > 0) { 00213 ACE_DEBUG((LM_DEBUG, 00214 ACE_TEXT("(%P|%t) INFO: Federator::Config::~FederatorConfig()\n"))); 00215 } 00216 00217 // We prwn this 00218 delete [] this->argv_; 00219 }
ACE_INLINE void OpenDDS::Federator::Config::addArg | ( | ACE_TCHAR * | arg | ) |
ACE_INLINE int OpenDDS::Federator::Config::argc | ( | ) | const |
Definition at line 17 of file FederatorConfig.inl.
References argc_.
00018 { 00019 return this->argc_; 00020 }
ACE_INLINE int & OpenDDS::Federator::Config::argc | ( | ) |
Access the enhanced argv.
Definition at line 10 of file FederatorConfig.inl.
References argc_.
00011 { 00012 return this->argc_; 00013 }
ACE_INLINE ACE_TCHAR ** OpenDDS::Federator::Config::argv | ( | ) | const |
Definition at line 31 of file FederatorConfig.inl.
References argv_.
00032 { 00033 return this->argv_; 00034 }
ACE_INLINE ACE_TCHAR **& OpenDDS::Federator::Config::argv | ( | ) |
Access the enhanced argc.
Definition at line 24 of file FederatorConfig.inl.
References argv_.
Referenced by InfoRepo::init().
00025 { 00026 return this->argv_; 00027 }
ACE_INLINE OpenDDS::Federator::tstring OpenDDS::Federator::Config::configFile | ( | ) | const |
Definition at line 80 of file FederatorConfig.inl.
References configFile_.
00081 { 00082 return this->configFile_; 00083 }
ACE_INLINE void OpenDDS::Federator::Config::configFile | ( | const tstring & | file | ) |
Configuration filename.
Definition at line 73 of file FederatorConfig.inl.
References configFile_.
00074 { 00075 this->configFile_ = file; 00076 }
ACE_INLINE OpenDDS::Federator::tstring OpenDDS::Federator::Config::federateIor | ( | ) | const |
Definition at line 94 of file FederatorConfig.inl.
References federateIor_.
00095 { 00096 return this->federateIor_; 00097 }
ACE_INLINE void OpenDDS::Federator::Config::federateIor | ( | const tstring & | ior | ) |
Initial federation IOR value.
Definition at line 87 of file FederatorConfig.inl.
References federateIor_.
Referenced by InfoRepo::init().
00088 { 00089 this->federateIor_ = ior; 00090 }
ACE_INLINE long OpenDDS::Federator::Config::federationDomain | ( | ) | const |
Definition at line 52 of file FederatorConfig.inl.
References federationDomain_.
00053 { 00054 return this->federationDomain_; 00055 }
ACE_INLINE void OpenDDS::Federator::Config::federationDomain | ( | long | domain | ) |
Federation Id value.
Definition at line 45 of file FederatorConfig.inl.
References federationDomain_.
Referenced by InfoRepo::init(), OpenDDS::Federator::ManagerImpl::initialize(), OpenDDS::Federator::ManagerImpl::join_federation(), and OpenDDS::Federator::ManagerImpl::pushState().
00046 { 00047 this->federationDomain_ = domain; 00048 }
ACE_INLINE const TAO_DDS_DCPSFederationId & OpenDDS::Federator::Config::federationId | ( | ) | const |
Definition at line 108 of file FederatorConfig.inl.
References federationId_.
00109 { 00110 return this->federationId_; 00111 }
ACE_INLINE TAO_DDS_DCPSFederationId & OpenDDS::Federator::Config::federationId | ( | ) |
Federation Id value.
Definition at line 101 of file FederatorConfig.inl.
References federationId_.
Referenced by OpenDDS::Federator::ManagerImpl::id().
00102 { 00103 return this->federationId_; 00104 }
ACE_INLINE short OpenDDS::Federator::Config::federationPort | ( | ) | const |
Definition at line 66 of file FederatorConfig.inl.
References federationPort_.
00067 { 00068 return this->federationPort_; 00069 }
ACE_INLINE void OpenDDS::Federator::Config::federationPort | ( | short | port | ) |
Federation Port value.
Definition at line 59 of file FederatorConfig.inl.
References federationPort_.
00060 { 00061 this->federationPort_ = port; 00062 }
void OpenDDS::Federator::Config::processFile | ( | ) | [private] |
Process a configuration file.
Definition at line 222 of file FederatorConfig.cpp.
References OpenDDS::DCPS::DCPS_debug_level, federationDomain_, federationId_, federationPort_, and TAO_DDS_DCPSFederationId::id().
Referenced by Config().
00223 { 00224 if (::OpenDDS::DCPS::DCPS_debug_level > 0) { 00225 ACE_DEBUG((LM_DEBUG, 00226 ACE_TEXT("(%P|%t) INFO: Federator::Config::process()\n"))); 00227 } 00228 00229 if (this->configFile_.empty()) { 00230 // No filename, no processing. 00231 return; 00232 } 00233 00234 // Grab a spot to stick the configuration. 00235 ACE_Configuration_Heap heap; 00236 00237 if (0 != heap.open()) { 00238 ACE_ERROR((LM_ERROR, 00239 ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ") 00240 ACE_TEXT("unable to open configuration heap.\n"))); 00241 return; 00242 } 00243 00244 // Import the file into our shiny new spot. 00245 ACE_Ini_ImpExp import(heap); 00246 00247 if (0 != import.import_config(this->configFile_.c_str())) { 00248 ACE_ERROR((LM_ERROR, 00249 ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ") 00250 ACE_TEXT("unable to import configuration file.\n"))); 00251 return; 00252 } 00253 00254 // Configuration file format: 00255 // 00256 // FederationDomain = <number> (REQUIRED) 00257 // FederationId = <number> (REQUIRED) 00258 // FederationPort = <number> (REQUIRED) 00259 // 00260 00261 // Grab the common configuration settings. 00262 const ACE_Configuration_Section_Key &root = heap.root_section(); 00263 00264 // Federation Domain value - REQUIRED 00265 ACE_TString federationDomainString; 00266 00267 if (0 != heap.get_string_value(root, FEDERATION_DOMAIN_KEY, federationDomainString)) { 00268 ACE_ERROR((LM_ERROR, 00269 ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ") 00270 ACE_TEXT("Unable to obtain value for FederationDomain in root section\n"))); 00271 return; 00272 } 00273 00274 // Convert to numeric repository key value. 00275 this->federationDomain_ = ACE_OS::atoi(federationDomainString.c_str()); 00276 00277 if (::OpenDDS::DCPS::DCPS_debug_level > 0) { 00278 ACE_DEBUG((LM_DEBUG, 00279 ACE_TEXT("(%P|%t) FederationDomain == %d\n"), 00280 this->federationDomain_)); 00281 } 00282 00283 // Federation Id value - REQUIRED 00284 ACE_TString federationIdString; 00285 00286 if (0 != heap.get_string_value(root, FEDERATION_ID_KEY, federationIdString)) { 00287 ACE_ERROR((LM_ERROR, 00288 ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ") 00289 ACE_TEXT("Unable to obtain value for FederationId in root section\n"))); 00290 return; 00291 } 00292 00293 // Convert to numeric repository key value. 00294 RepoKey idValue = ACE_OS::atoi(federationIdString.c_str()); 00295 00296 // Allow the command line to override the file value. 00297 if (this->federationId_.overridden()) { 00298 ACE_DEBUG((LM_DEBUG, 00299 ACE_TEXT("(%P|%t) FederationId == %d from file ") 00300 ACE_TEXT("overridden by value %d from command line.\n"), 00301 idValue, 00302 this->federationId_.id())); 00303 00304 } else { 00305 this->federationId_.id(idValue); 00306 00307 if (::OpenDDS::DCPS::DCPS_debug_level > 0) { 00308 ACE_DEBUG((LM_DEBUG, 00309 ACE_TEXT("(%P|%t) FederationId == %d\n"), 00310 this->federationId_.id())); 00311 } 00312 } 00313 00314 // Federation port value - REQUIRED 00315 ACE_TString federationPortString; 00316 00317 if (0 != heap.get_string_value(root, FEDERATION_PORT_KEY, federationPortString)) { 00318 ACE_ERROR((LM_ERROR, 00319 ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ") 00320 ACE_TEXT("Unable to obtain value for FederationPort in root section\n"))); 00321 return; 00322 } 00323 00324 // Convert to numeric repository key value. 00325 this->federationPort_ = ACE_OS::atoi(federationPortString.c_str()); 00326 00327 if (::OpenDDS::DCPS::DCPS_debug_level > 0) { 00328 ACE_DEBUG((LM_DEBUG, 00329 ACE_TEXT("(%P|%t) FederationPort == %d\n"), 00330 this->federationPort_)); 00331 } 00332 }
int OpenDDS::Federator::Config::argc_ [private] |
ACE_TCHAR** OpenDDS::Federator::Config::argv_ [private] |
Configuration filename, if any.
Definition at line 85 of file FederatorConfig.h.
Referenced by configFile().
const tstring OpenDDS::Federator::Config::FEDERATE_WITH_OPTION [static] |
Command line option specifying a repository to federate with.
Definition at line 35 of file FederatorConfig.h.
Initial federation IOR, if any.
Definition at line 88 of file FederatorConfig.h.
Referenced by federateIor().
long OpenDDS::Federator::Config::federationDomain_ [private] |
Configured Federation Domain value.
Definition at line 94 of file FederatorConfig.h.
Referenced by federationDomain(), and processFile().
Configured Federation Id value.
Definition at line 91 of file FederatorConfig.h.
Referenced by federationId(), and processFile().
short OpenDDS::Federator::Config::federationPort_ [private] |
Configured Federation Port value.
Definition at line 97 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 29 of file FederatorConfig.h.
const tstring OpenDDS::Federator::Config::FEDERATOR_ID_OPTION [static] |
Command line option specifying the federation Id value.
Definition at line 32 of file FederatorConfig.h.