OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | List of all members
OpenDDS::DCPS::InfoRepoDiscovery::Config Class Reference

#include <InfoRepoDiscovery.h>

Inheritance diagram for OpenDDS::DCPS::InfoRepoDiscovery::Config:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::InfoRepoDiscovery::Config:
Collaboration graph
[legend]

Public Member Functions

int discovery_config (ACE_Configuration_Heap &cf)
 
- Public Member Functions inherited from OpenDDS::DCPS::Discovery::Config
virtual ~Config ()
 

Additional Inherited Members

- Protected Member Functions inherited from OpenDDS::DCPS::EnableContainerSupportedUniquePtr< Config >
 EnableContainerSupportedUniquePtr ()
 
void _add_ref ()
 
void _remove_ref ()
 
long ref_count () const
 

Detailed Description

Definition at line 269 of file InfoRepoDiscovery.h.

Member Function Documentation

◆ discovery_config()

int OpenDDS::DCPS::InfoRepoDiscovery::Config::discovery_config ( ACE_Configuration_Heap cf)
virtual

Implements OpenDDS::DCPS::Discovery::Config.

Definition at line 867 of file InfoRepoDiscovery.cpp.

References ACE_DEBUG, ACE_ERROR_RETURN, ACE_TEXT(), ACE_OS::atoi(), OpenDDS::DCPS::convertToInteger(), OpenDDS::DCPS::DCPS_debug_level, OpenDDS::DCPS::Discovery::DEFAULT_REPO, LM_DEBUG, LM_ERROR, LM_NOTICE, name, ACE_Configuration_Heap::open_section(), OpenDDS::DCPS::processSections(), OpenDDS::DCPS::pullValues(), OpenDDS::DCPS::REPO_SECTION_NAME, ACE_Configuration::root_section(), TheServiceParticipant, and value.

868 {
869  const ACE_Configuration_Section_Key& root = cf.root_section();
871 
872  if (cf.open_section(root, REPO_SECTION_NAME, 0, repo_sect) != 0) {
873  if (DCPS_debug_level > 0) {
874  // This is not an error if the configuration file does not have
875  // any repository (sub)section. The code default configuration will be used.
876  ACE_DEBUG((LM_NOTICE,
877  ACE_TEXT("(%P|%t) NOTICE: InfoRepoDiscovery::Config::discovery_config ")
878  ACE_TEXT("failed to open [%s] section.\n"),
880  }
881 
882  return 0;
883 
884  } else {
885  // Ensure there are no properties in this section
886  ValueMap vm;
887  if (pullValues(cf, repo_sect, vm) > 0) {
888  // There are values inside [repo]
889  ACE_ERROR_RETURN((LM_ERROR,
890  ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
891  ACE_TEXT("repo sections must have a subsection name\n")),
892  -1);
893  }
894  // Process the subsections of this section (the individual repos)
895  KeyList keys;
896  if (processSections( cf, repo_sect, keys ) != 0) {
897  ACE_ERROR_RETURN((LM_ERROR,
898  ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
899  ACE_TEXT("too many nesting layers in the [repo] section.\n")),
900  -1);
901  }
902 
903  // Loop through the [repo/*] sections
904  for (KeyList::const_iterator it=keys.begin(); it != keys.end(); ++it) {
905  std::string repo_name = (*it).first;
906 
907  ValueMap values;
908  pullValues( cf, (*it).second, values );
910  bool repoKeySpecified = false, bitIpSpecified = false,
911  bitPortSpecified = false;
912  std::string repoIor;
913  int bitPort = 0;
914  std::string bitIp;
915  for (ValueMap::const_iterator it=values.begin(); it != values.end(); ++it) {
916  std::string name = (*it).first;
917  if (name == "RepositoryKey") {
918  repoKey = (*it).second;
919  repoKeySpecified = true;
920  if (DCPS_debug_level > 0) {
921  ACE_DEBUG((LM_DEBUG,
922  ACE_TEXT("(%P|%t) [repository/%C]: RepositoryKey == %C\n"),
923  repo_name.c_str(), repoKey.c_str()));
924  }
925 
926  } else if (name == "RepositoryIor") {
927  repoIor = (*it).second;
928 
929  if (DCPS_debug_level > 0) {
930  ACE_DEBUG((LM_DEBUG,
931  ACE_TEXT("(%P|%t) [repository/%C]: RepositoryIor == %C\n"),
932  repo_name.c_str(), repoIor.c_str()));
933  }
934  } else if (name == "DCPSBitTransportIPAddress") {
935  bitIp = (*it).second;
936  bitIpSpecified = true;
937  if (DCPS_debug_level > 0) {
938  ACE_DEBUG((LM_DEBUG,
939  ACE_TEXT("(%P|%t) [repository/%C]: DCPSBitTransportIPAddress == %C\n"),
940  repo_name.c_str(), bitIp.c_str()));
941  }
942  } else if (name == "DCPSBitTransportPort") {
943  std::string value = (*it).second;
944  bitPort = ACE_OS::atoi(value.c_str());
945  bitPortSpecified = true;
946  if (convertToInteger(value, bitPort)) {
947  } else {
948  ACE_ERROR_RETURN((LM_ERROR,
949  ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
950  ACE_TEXT("Illegal integer value for DCPSBitTransportPort (%C) in [repository/%C] section.\n"),
951  value.c_str(), repo_name.c_str()),
952  -1);
953  }
954  if (DCPS_debug_level > 0) {
955  ACE_DEBUG((LM_DEBUG,
956  ACE_TEXT("(%P|%t) [repository/%C]: DCPSBitTransportPort == %d\n"),
957  repo_name.c_str(), bitPort));
958  }
959  } else {
960  ACE_ERROR_RETURN((LM_ERROR,
961  ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
962  ACE_TEXT("Unexpected entry (%C) in [repository/%C] section.\n"),
963  name.c_str(), repo_name.c_str()),
964  -1);
965  }
966  }
967 
968  if (values.find("RepositoryIor") == values.end()) {
969  ACE_ERROR_RETURN((LM_ERROR,
970  ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
971  ACE_TEXT("Repository section [repository/%C] section is missing RepositoryIor value.\n"),
972  repo_name.c_str()),
973  -1);
974  }
975 
976  if (!repoKeySpecified) {
977  // If the RepositoryKey option was not specified, use the section
978  // name as the repo key
979  repoKey = repo_name;
980  }
981  InfoRepoDiscovery_rch discovery(
982  make_rch<InfoRepoDiscovery>(repoKey, repoIor.c_str()));
983  if (bitPortSpecified) discovery->bit_transport_port(bitPort);
984  if (bitIpSpecified) discovery->bit_transport_ip(bitIp);
985  TheServiceParticipant->add_discovery(
986  DCPS::static_rchandle_cast<Discovery>(discovery));
987  }
988  }
989 
990  return 0;
991 }
#define ACE_DEBUG(X)
static const char * DEFAULT_REPO
Key value for the default repository IOR.
Definition: Discovery.h:85
const LogLevel::Value value
Definition: debug.cpp:61
static const ACE_TCHAR REPO_SECTION_NAME[]
virtual const ACE_Configuration_Section_Key & root_section(void) const
RcHandle< InfoRepoDiscovery > InfoRepoDiscovery_rch
const char *const name
Definition: debug.cpp:60
ACE_TEXT("TCP_Factory")
int atoi(const char *s)
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
virtual int open_section(const ACE_Configuration_Section_Key &base, const ACE_TCHAR *sub_section, bool create, ACE_Configuration_Section_Key &result)
int processSections(ACE_Configuration_Heap &cf, const ACE_Configuration_Section_Key &key, KeyList &subsections)
Definition: ConfigUtils.cpp:41
#define ACE_ERROR_RETURN(X, Y)
int pullValues(ACE_Configuration_Heap &cf, const ACE_Configuration_Section_Key &key, ValueMap &values)
Definition: ConfigUtils.cpp:17
#define TheServiceParticipant
OPENDDS_STRING RepoKey
Definition: Discovery.h:80
bool convertToInteger(const String &s, T &value)

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