OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
OpenDDS::Federator::Config Class Reference

#include <FederatorConfig.h>

Collaboration diagram for OpenDDS::Federator::Config:
Collaboration graph
[legend]

Public Member Functions

 Config (int argc, ACE_TCHAR **argv)
 Default constructor. More...
 
virtual ~Config ()
 
int & argc ()
 Access the enhanced argv. More...
 
int argc () const
 
ACE_TCHAR **& argv ()
 Access the enhanced argc. More...
 
ACE_TCHAR ** argv () const
 
void addArg (ACE_TCHAR *arg)
 Add an argument. More...
 
TAO_DDS_DCPSFederationIdfederationId ()
 Federation Id value. More...
 
const TAO_DDS_DCPSFederationIdfederationId () const
 
void federationDomain (long domain)
 Federation Id value. More...
 
long federationDomain () const
 
void federationPort (short port)
 Federation Port value. More...
 
short federationPort () const
 
void federateIor (const tstring &ior)
 Initial federation IOR value. More...
 
tstring federateIor () const
 
void configFile (const tstring &file)
 Configuration filename. More...
 
tstring configFile () const
 

Static Public Attributes

static const tstring FEDERATOR_CONFIG_OPTION
 Command line option specifying the configuration file. More...
 
static const tstring FEDERATOR_ID_OPTION
 Command line option specifying the federation Id value. More...
 
static const tstring FEDERATE_WITH_OPTION
 Command line option specifying a repository to federate with. More...
 

Private Member Functions

void processFile ()
 Process a configuration file. More...
 

Private Attributes

int argc_
 Enhanced argc. More...
 
ACE_TCHAR ** argv_
 Enhanced argv. More...
 
tstring configFile_
 Configuration filename, if any. More...
 
tstring federateIor_
 Initial federation IOR, if any. More...
 
TAO_DDS_DCPSFederationId federationId_
 Configured Federation Id value. More...
 
long federationDomain_
 Configured Federation Domain value. More...
 
short federationPort_
 Configured Federation Port value. More...
 

Detailed Description

Definition at line 28 of file FederatorConfig.h.

Constructor & Destructor Documentation

◆ Config()

OpenDDS::Federator::Config::Config ( int  argc,
ACE_TCHAR **  argv 
)

Default constructor.

Definition at line 190 of file FederatorConfig.cpp.

References ACE_DEBUG, ACE_TEXT(), argv_, OpenDDS::DCPS::DCPS_debug_level, LM_DEBUG, and processFile().

191  : argc_(0),
194  federationPort_(-1)
195 {
197  ACE_DEBUG((LM_DEBUG,
198  ACE_TEXT("(%P|%t) INFO: Federator::Config::Config()\n")));
199  }
200 
201  // Setup the internal storage.
202  this->argv_ = new ACE_TCHAR*[argc + 1](); // argv_[argc] == 0
203 
204  // Process the federation arguments. Copy the uninteresting arguments verbatim.
205  ArgCopier argCopier(this);
206  std::for_each(&argv[0], &argv[ argc], argCopier);
207 
208  // Read and process any configuration file.
209  this->processFile();
210 }
#define ACE_DEBUG(X)
ACE_TCHAR **& argv()
Access the enhanced argc.
void processFile()
Process a configuration file.
const FederationDomain DEFAULT_FEDERATIONDOMAIN
Definition: Federator.idl:37
char ACE_TCHAR
TAO_DDS_DCPSFederationId federationId_
Configured Federation Id value.
::CORBA::Long hash_endpoints(int argc, ACE_TCHAR **argv)
ACE_TEXT("TCP_Factory")
int argc_
Enhanced argc.
long federationDomain_
Configured Federation Domain value.
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
ACE_TCHAR ** argv_
Enhanced argv.
int & argc()
Access the enhanced argv.
short federationPort_
Configured Federation Port value.

◆ ~Config()

OpenDDS::Federator::Config::~Config ( )
virtual

Definition at line 212 of file FederatorConfig.cpp.

References ACE_DEBUG, ACE_TEXT(), argv_, OpenDDS::DCPS::DCPS_debug_level, and LM_DEBUG.

213 {
215  ACE_DEBUG((LM_DEBUG,
216  ACE_TEXT("(%P|%t) INFO: Federator::Config::~FederatorConfig()\n")));
217  }
218 
219  // We prwn this
220  delete [] this->argv_;
221 }
#define ACE_DEBUG(X)
ACE_TEXT("TCP_Factory")
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
ACE_TCHAR ** argv_
Enhanced argv.

Member Function Documentation

◆ addArg()

ACE_INLINE void OpenDDS::Federator::Config::addArg ( ACE_TCHAR arg)

Add an argument.

Definition at line 40 of file FederatorConfig.inl.

References ACE_INLINE, argc_, and argv_.

Referenced by OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::ArgCopier::operator()().

41 {
42  this->argv_[this->argc_++] = arg;
43 }
int argc_
Enhanced argc.
ACE_TCHAR ** argv_
Enhanced argv.

◆ argc() [1/2]

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 ACE_INLINE, and argc_.

13 {
14  return this->argc_;
15 }
int argc_
Enhanced argc.

◆ argc() [2/2]

ACE_INLINE int OpenDDS::Federator::Config::argc ( void  ) const

Definition at line 19 of file FederatorConfig.inl.

References ACE_INLINE, and argc_.

20 {
21  return this->argc_;
22 }
int argc_
Enhanced argc.

◆ argv() [1/2]

ACE_INLINE ACE_TCHAR **& OpenDDS::Federator::Config::argv ( void  )

Access the enhanced argc.

Definition at line 26 of file FederatorConfig.inl.

References ACE_INLINE, and argv_.

Referenced by InfoRepo::init().

27 {
28  return this->argv_;
29 }
ACE_TCHAR ** argv_
Enhanced argv.

◆ argv() [2/2]

ACE_INLINE ACE_TCHAR ** OpenDDS::Federator::Config::argv ( void  ) const

Definition at line 33 of file FederatorConfig.inl.

References ACE_INLINE, and argv_.

34 {
35  return this->argv_;
36 }
ACE_TCHAR ** argv_
Enhanced argv.

◆ configFile() [1/2]

ACE_INLINE void OpenDDS::Federator::Config::configFile ( const tstring file)

Configuration filename.

Definition at line 75 of file FederatorConfig.inl.

References ACE_INLINE, and configFile_.

Referenced by OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::ArgCopier::operator()().

76 {
77  this->configFile_ = file;
78 }
tstring configFile_
Configuration filename, if any.

◆ configFile() [2/2]

ACE_INLINE OpenDDS::Federator::tstring OpenDDS::Federator::Config::configFile ( ) const

Definition at line 82 of file FederatorConfig.inl.

References ACE_INLINE, and configFile_.

83 {
84  return this->configFile_;
85 }
tstring configFile_
Configuration filename, if any.

◆ federateIor() [1/2]

ACE_INLINE void OpenDDS::Federator::Config::federateIor ( const tstring ior)

Initial federation IOR value.

Definition at line 89 of file FederatorConfig.inl.

References ACE_INLINE, and federateIor_.

Referenced by InfoRepo::init(), and OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::ArgCopier::operator()().

90 {
91  this->federateIor_ = ior;
92 }
tstring federateIor_
Initial federation IOR, if any.

◆ federateIor() [2/2]

ACE_INLINE OpenDDS::Federator::tstring OpenDDS::Federator::Config::federateIor ( ) const

Definition at line 96 of file FederatorConfig.inl.

References ACE_INLINE, and federateIor_.

97 {
98  return this->federateIor_;
99 }
tstring federateIor_
Initial federation IOR, if any.

◆ federationDomain() [1/2]

ACE_INLINE void OpenDDS::Federator::Config::federationDomain ( long  domain)

◆ federationDomain() [2/2]

ACE_INLINE long OpenDDS::Federator::Config::federationDomain ( ) const

Definition at line 54 of file FederatorConfig.inl.

References ACE_INLINE, and federationDomain_.

55 {
56  return this->federationDomain_;
57 }
long federationDomain_
Configured Federation Domain value.

◆ federationId() [1/2]

ACE_INLINE TAO_DDS_DCPSFederationId & OpenDDS::Federator::Config::federationId ( )

Federation Id value.

Definition at line 103 of file FederatorConfig.inl.

References ACE_INLINE, and federationId_.

Referenced by OpenDDS::Federator::ManagerImpl::id(), InfoRepo::init(), and OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::ArgCopier::operator()().

104 {
105  return this->federationId_;
106 }
TAO_DDS_DCPSFederationId federationId_
Configured Federation Id value.

◆ federationId() [2/2]

ACE_INLINE const TAO_DDS_DCPSFederationId & OpenDDS::Federator::Config::federationId ( ) const

Definition at line 110 of file FederatorConfig.inl.

References federationId_, and OPENDDS_END_VERSIONED_NAMESPACE_DECL.

111 {
112  return this->federationId_;
113 }
TAO_DDS_DCPSFederationId federationId_
Configured Federation Id value.

◆ federationPort() [1/2]

ACE_INLINE void OpenDDS::Federator::Config::federationPort ( short  port)

Federation Port value.

Definition at line 61 of file FederatorConfig.inl.

References ACE_INLINE, and federationPort_.

62 {
63  this->federationPort_ = port;
64 }
short federationPort_
Configured Federation Port value.

◆ federationPort() [2/2]

ACE_INLINE short OpenDDS::Federator::Config::federationPort ( ) const

Definition at line 68 of file FederatorConfig.inl.

References ACE_INLINE, and federationPort_.

69 {
70  return this->federationPort_;
71 }
short federationPort_
Configured Federation Port value.

◆ processFile()

void OpenDDS::Federator::Config::processFile ( )
private

Process a configuration file.

Definition at line 224 of file FederatorConfig.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_TEXT(), ACE_OS::atoi(), ACE_String_Base< char >::c_str(), configFile_, OpenDDS::DCPS::DCPS_debug_level, OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::FEDERATION_DOMAIN_KEY, OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::FEDERATION_ID_KEY, OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL::FEDERATION_PORT_KEY, federationDomain_, federationId_, federationPort_, ACE_Configuration_Heap::get_string_value(), TAO_DDS_DCPSFederationId::id(), LM_DEBUG, LM_ERROR, ACE_Configuration_Heap::open(), OPENDDS_END_VERSIONED_NAMESPACE_DECL, TAO_DDS_DCPSFederationId::overridden(), and ACE_Configuration::root_section().

Referenced by Config().

225 {
227  ACE_DEBUG((LM_DEBUG,
228  ACE_TEXT("(%P|%t) INFO: Federator::Config::process()\n")));
229  }
230 
231  if (this->configFile_.empty()) {
232  // No filename, no processing.
233  return;
234  }
235 
236  // Grab a spot to stick the configuration.
238 
239  if (0 != heap.open()) {
240  ACE_ERROR((LM_ERROR,
241  ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ")
242  ACE_TEXT("unable to open configuration heap.\n")));
243  return;
244  }
245 
246  // Import the file into our shiny new spot.
247  ACE_Ini_ImpExp import(heap);
248 
249  if (0 != import.import_config(this->configFile_.c_str())) {
250  ACE_ERROR((LM_ERROR,
251  ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ")
252  ACE_TEXT("unable to import configuration file.\n")));
253  return;
254  }
255 
256  // Configuration file format:
257  //
258  // FederationDomain = <number> (REQUIRED)
259  // FederationId = <number> (REQUIRED)
260  // FederationPort = <number> (REQUIRED)
261  //
262 
263  // Grab the common configuration settings.
264  const ACE_Configuration_Section_Key &root = heap.root_section();
265 
266  // Federation Domain value - REQUIRED
267  ACE_TString federationDomainString;
268 
269  if (0 != heap.get_string_value(root, FEDERATION_DOMAIN_KEY, federationDomainString)) {
270  ACE_ERROR((LM_ERROR,
271  ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ")
272  ACE_TEXT("Unable to obtain value for FederationDomain in root section\n")));
273  return;
274  }
275 
276  // Convert to numeric repository key value.
277  this->federationDomain_ = ACE_OS::atoi(federationDomainString.c_str());
278 
280  ACE_DEBUG((LM_DEBUG,
281  ACE_TEXT("(%P|%t) FederationDomain == %d\n"),
282  this->federationDomain_));
283  }
284 
285  // Federation Id value - REQUIRED
286  ACE_TString federationIdString;
287 
288  if (0 != heap.get_string_value(root, FEDERATION_ID_KEY, federationIdString)) {
289  ACE_ERROR((LM_ERROR,
290  ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ")
291  ACE_TEXT("Unable to obtain value for FederationId in root section\n")));
292  return;
293  }
294 
295  // Convert to numeric repository key value.
296  RepoKey idValue = ACE_OS::atoi(federationIdString.c_str());
297 
298  // Allow the command line to override the file value.
299  if (this->federationId_.overridden()) {
300  ACE_DEBUG((LM_DEBUG,
301  ACE_TEXT("(%P|%t) FederationId == %d from file ")
302  ACE_TEXT("overridden by value %d from command line.\n"),
303  idValue,
304  this->federationId_.id()));
305 
306  } else {
307  this->federationId_.id(idValue);
308 
310  ACE_DEBUG((LM_DEBUG,
311  ACE_TEXT("(%P|%t) FederationId == %d\n"),
312  this->federationId_.id()));
313  }
314  }
315 
316  // Federation port value - REQUIRED
317  ACE_TString federationPortString;
318 
319  if (0 != heap.get_string_value(root, FEDERATION_PORT_KEY, federationPortString)) {
320  ACE_ERROR((LM_ERROR,
321  ACE_TEXT("(%P|%t) ERROR: Federator::Config::process - ")
322  ACE_TEXT("Unable to obtain value for FederationPort in root section\n")));
323  return;
324  }
325 
326  // Convert to numeric repository key value.
327  this->federationPort_ = ACE_OS::atoi(federationPortString.c_str());
328 
330  ACE_DEBUG((LM_DEBUG,
331  ACE_TEXT("(%P|%t) FederationPort == %d\n"),
332  this->federationPort_));
333  }
334 }
#define ACE_DEBUG(X)
#define ACE_ERROR(X)
const char * c_str(void) const
virtual int get_string_value(const ACE_Configuration_Section_Key &key, const ACE_TCHAR *name, ACE_TString &value)
virtual const ACE_Configuration_Section_Key & root_section(void) const
tstring configFile_
Configuration filename, if any.
TAO_DDS_DCPSFederationId federationId_
Configured Federation Id value.
ACE_TEXT("TCP_Factory")
int atoi(const char *s)
long federationDomain_
Configured Federation Domain value.
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
::CORBA::Long RepoKey
int open(const ACE_TCHAR *file_name, void *base_address=ACE_DEFAULT_BASE_ADDR, size_t default_map_size=ACE_DEFAULT_CONFIG_SECTION_SIZE)
short federationPort_
Configured Federation Port value.
void id(RepoKey fedId)

Member Data Documentation

◆ argc_

int OpenDDS::Federator::Config::argc_
private

Enhanced argc.

Definition at line 80 of file FederatorConfig.h.

Referenced by addArg(), and argc().

◆ argv_

ACE_TCHAR** OpenDDS::Federator::Config::argv_
private

Enhanced argv.

Definition at line 83 of file FederatorConfig.h.

Referenced by addArg(), argv(), Config(), and ~Config().

◆ configFile_

tstring OpenDDS::Federator::Config::configFile_
private

Configuration filename, if any.

Definition at line 86 of file FederatorConfig.h.

Referenced by configFile(), and processFile().

◆ FEDERATE_WITH_OPTION

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()().

◆ federateIor_

tstring OpenDDS::Federator::Config::federateIor_
private

Initial federation IOR, if any.

Definition at line 89 of file FederatorConfig.h.

Referenced by federateIor().

◆ federationDomain_

long OpenDDS::Federator::Config::federationDomain_
private

Configured Federation Domain value.

Definition at line 95 of file FederatorConfig.h.

Referenced by federationDomain(), and processFile().

◆ federationId_

TAO_DDS_DCPSFederationId OpenDDS::Federator::Config::federationId_
private

Configured Federation Id value.

Definition at line 92 of file FederatorConfig.h.

Referenced by federationId(), and processFile().

◆ federationPort_

short OpenDDS::Federator::Config::federationPort_
private

Configured Federation Port value.

Definition at line 98 of file FederatorConfig.h.

Referenced by federationPort(), and processFile().

◆ FEDERATOR_CONFIG_OPTION

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()().

◆ FEDERATOR_ID_OPTION

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()().


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