#include <InfoRepoDiscovery.h>
Public Member Functions | |
int | discovery_config (ACE_Configuration_Heap &cf) |
Definition at line 274 of file InfoRepoDiscovery.h.
int OpenDDS::DCPS::InfoRepoDiscovery::Config::discovery_config | ( | ACE_Configuration_Heap & | cf | ) | [virtual] |
Implements OpenDDS::DCPS::Discovery::Config.
Definition at line 863 of file InfoRepoDiscovery.cpp.
References ACE_TEXT(), ACE_OS::atoi(), OpenDDS::DCPS::convertToInteger(), OpenDDS::DCPS::DCPS_debug_level, OpenDDS::DCPS::Discovery::DEFAULT_REPO, LM_DEBUG, LM_ERROR, LM_NOTICE, ACE_Configuration_Heap::open_section(), OpenDDS::DCPS::processSections(), OpenDDS::DCPS::pullValues(), OpenDDS::DCPS::REPO_SECTION_NAME, ACE_Configuration::root_section(), and TheServiceParticipant.
00864 { 00865 const ACE_Configuration_Section_Key& root = cf.root_section(); 00866 ACE_Configuration_Section_Key repo_sect; 00867 00868 if (cf.open_section(root, REPO_SECTION_NAME, 0, repo_sect) != 0) { 00869 if (DCPS_debug_level > 0) { 00870 // This is not an error if the configuration file does not have 00871 // any repository (sub)section. The code default configuration will be used. 00872 ACE_DEBUG((LM_NOTICE, 00873 ACE_TEXT("(%P|%t) NOTICE: InfoRepoDiscovery::Config::discovery_config ") 00874 ACE_TEXT("failed to open [%s] section.\n"), 00875 REPO_SECTION_NAME)); 00876 } 00877 00878 return 0; 00879 00880 } else { 00881 // Ensure there are no properties in this section 00882 ValueMap vm; 00883 if (pullValues(cf, repo_sect, vm) > 0) { 00884 // There are values inside [repo] 00885 ACE_ERROR_RETURN((LM_ERROR, 00886 ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ") 00887 ACE_TEXT("repo sections must have a subsection name\n")), 00888 -1); 00889 } 00890 // Process the subsections of this section (the individual repos) 00891 KeyList keys; 00892 if (processSections( cf, repo_sect, keys ) != 0) { 00893 ACE_ERROR_RETURN((LM_ERROR, 00894 ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ") 00895 ACE_TEXT("too many nesting layers in the [repo] section.\n")), 00896 -1); 00897 } 00898 00899 // Loop through the [repo/*] sections 00900 for (KeyList::const_iterator it=keys.begin(); it != keys.end(); ++it) { 00901 std::string repo_name = (*it).first; 00902 00903 ValueMap values; 00904 pullValues( cf, (*it).second, values ); 00905 Discovery::RepoKey repoKey = Discovery::DEFAULT_REPO; 00906 bool repoKeySpecified = false, bitIpSpecified = false, 00907 bitPortSpecified = false; 00908 std::string repoIor; 00909 int bitPort = 0; 00910 std::string bitIp; 00911 for (ValueMap::const_iterator it=values.begin(); it != values.end(); ++it) { 00912 std::string name = (*it).first; 00913 if (name == "RepositoryKey") { 00914 repoKey = (*it).second; 00915 repoKeySpecified = true; 00916 if (DCPS_debug_level > 0) { 00917 ACE_DEBUG((LM_DEBUG, 00918 ACE_TEXT("(%P|%t) [repository/%C]: RepositoryKey == %C\n"), 00919 repo_name.c_str(), repoKey.c_str())); 00920 } 00921 00922 } else if (name == "RepositoryIor") { 00923 repoIor = (*it).second; 00924 00925 if (DCPS_debug_level > 0) { 00926 ACE_DEBUG((LM_DEBUG, 00927 ACE_TEXT("(%P|%t) [repository/%C]: RepositoryIor == %C\n"), 00928 repo_name.c_str(), repoIor.c_str())); 00929 } 00930 } else if (name == "DCPSBitTransportIPAddress") { 00931 bitIp = (*it).second; 00932 bitIpSpecified = true; 00933 if (DCPS_debug_level > 0) { 00934 ACE_DEBUG((LM_DEBUG, 00935 ACE_TEXT("(%P|%t) [repository/%C]: DCPSBitTransportIPAddress == %C\n"), 00936 repo_name.c_str(), bitIp.c_str())); 00937 } 00938 } else if (name == "DCPSBitTransportPort") { 00939 std::string value = (*it).second; 00940 bitPort = ACE_OS::atoi(value.c_str()); 00941 bitPortSpecified = true; 00942 if (convertToInteger(value, bitPort)) { 00943 } else { 00944 ACE_ERROR_RETURN((LM_ERROR, 00945 ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ") 00946 ACE_TEXT("Illegal integer value for DCPSBitTransportPort (%C) in [repository/%C] section.\n"), 00947 value.c_str(), repo_name.c_str()), 00948 -1); 00949 } 00950 if (DCPS_debug_level > 0) { 00951 ACE_DEBUG((LM_DEBUG, 00952 ACE_TEXT("(%P|%t) [repository/%C]: DCPSBitTransportPort == %d\n"), 00953 repo_name.c_str(), bitPort)); 00954 } 00955 } else { 00956 ACE_ERROR_RETURN((LM_ERROR, 00957 ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ") 00958 ACE_TEXT("Unexpected entry (%C) in [repository/%C] section.\n"), 00959 name.c_str(), repo_name.c_str()), 00960 -1); 00961 } 00962 } 00963 00964 if (values.find("RepositoryIor") == values.end()) { 00965 ACE_ERROR_RETURN((LM_ERROR, 00966 ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ") 00967 ACE_TEXT("Repository section [repository/%C] section is missing RepositoryIor value.\n"), 00968 repo_name.c_str()), 00969 -1); 00970 } 00971 00972 if (!repoKeySpecified) { 00973 // If the RepositoryKey option was not specified, use the section 00974 // name as the repo key 00975 repoKey = repo_name; 00976 } 00977 InfoRepoDiscovery_rch discovery( 00978 make_rch<InfoRepoDiscovery>(repoKey, repoIor.c_str())); 00979 if (bitPortSpecified) discovery->bit_transport_port(bitPort); 00980 if (bitIpSpecified) discovery->bit_transport_ip(bitIp); 00981 TheServiceParticipant->add_discovery( 00982 DCPS::static_rchandle_cast<Discovery>(discovery)); 00983 } 00984 } 00985 00986 return 0; 00987 }