#include <InfoRepoDiscovery.h>
Inheritance diagram for OpenDDS::DCPS::InfoRepoDiscovery::Config:
Public Member Functions | |
int | discovery_config (ACE_Configuration_Heap &cf) |
Definition at line 265 of file InfoRepoDiscovery.h.
int OpenDDS::DCPS::InfoRepoDiscovery::Config::discovery_config | ( | ACE_Configuration_Heap & | cf | ) | [virtual] |
Implements OpenDDS::DCPS::Discovery::Config.
Definition at line 774 of file InfoRepoDiscovery.cpp.
References OpenDDS::DCPS::convertToInteger(), OpenDDS::DCPS::DCPS_debug_level, OpenDDS::DCPS::Discovery::DEFAULT_REPO, OpenDDS::DCPS::InfoRepoDiscovery::InfoRepoDiscovery(), OpenDDS::DCPS::processSections(), OpenDDS::DCPS::pullValues(), OpenDDS::DCPS::REPO_SECTION_NAME, and TheServiceParticipant.
00775 { 00776 const ACE_Configuration_Section_Key& root = cf.root_section(); 00777 ACE_Configuration_Section_Key repo_sect; 00778 00779 if (cf.open_section(root, REPO_SECTION_NAME, 0, repo_sect) != 0) { 00780 if (DCPS_debug_level > 0) { 00781 // This is not an error if the configuration file does not have 00782 // any repository (sub)section. The code default configuration will be used. 00783 ACE_DEBUG((LM_NOTICE, 00784 ACE_TEXT("(%P|%t) NOTICE: InfoRepoDiscovery::Config::discovery_config ") 00785 ACE_TEXT("failed to open [%s] section.\n"), 00786 REPO_SECTION_NAME)); 00787 } 00788 00789 return 0; 00790 00791 } else { 00792 // Ensure there are no properties in this section 00793 ValueMap vm; 00794 if (pullValues(cf, repo_sect, vm) > 0) { 00795 // There are values inside [repo] 00796 ACE_ERROR_RETURN((LM_ERROR, 00797 ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ") 00798 ACE_TEXT("repo sections must have a subsection name\n")), 00799 -1); 00800 } 00801 // Process the subsections of this section (the individual repos) 00802 KeyList keys; 00803 if (processSections( cf, repo_sect, keys ) != 0) { 00804 ACE_ERROR_RETURN((LM_ERROR, 00805 ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ") 00806 ACE_TEXT("too many nesting layers in the [repo] section.\n")), 00807 -1); 00808 } 00809 00810 // Loop through the [repo/*] sections 00811 for (KeyList::const_iterator it=keys.begin(); it != keys.end(); ++it) { 00812 std::string repo_name = (*it).first; 00813 00814 ValueMap values; 00815 pullValues( cf, (*it).second, values ); 00816 Discovery::RepoKey repoKey = Discovery::DEFAULT_REPO; 00817 bool repoKeySpecified = false, bitIpSpecified = false, 00818 bitPortSpecified = false; 00819 std::string repoIor; 00820 int bitPort = 0; 00821 std::string bitIp; 00822 for (ValueMap::const_iterator it=values.begin(); it != values.end(); ++it) { 00823 std::string name = (*it).first; 00824 if (name == "RepositoryKey") { 00825 repoKey = (*it).second; 00826 repoKeySpecified = true; 00827 if (DCPS_debug_level > 0) { 00828 ACE_DEBUG((LM_DEBUG, 00829 ACE_TEXT("(%P|%t) [repository/%C]: RepositoryKey == %C\n"), 00830 repo_name.c_str(), repoKey.c_str())); 00831 } 00832 00833 } else if (name == "RepositoryIor") { 00834 repoIor = (*it).second; 00835 00836 if (DCPS_debug_level > 0) { 00837 ACE_DEBUG((LM_DEBUG, 00838 ACE_TEXT("(%P|%t) [repository/%C]: RepositoryIor == %C\n"), 00839 repo_name.c_str(), repoIor.c_str())); 00840 } 00841 } else if (name == "DCPSBitTransportIPAddress") { 00842 bitIp = (*it).second; 00843 bitIpSpecified = true; 00844 if (DCPS_debug_level > 0) { 00845 ACE_DEBUG((LM_DEBUG, 00846 ACE_TEXT("(%P|%t) [repository/%C]: DCPSBitTransportIPAddress == %C\n"), 00847 repo_name.c_str(), bitIp.c_str())); 00848 } 00849 } else if (name == "DCPSBitTransportPort") { 00850 std::string value = (*it).second; 00851 bitPort = ACE_OS::atoi(value.c_str()); 00852 bitPortSpecified = true; 00853 if (convertToInteger(value, bitPort)) { 00854 } else { 00855 ACE_ERROR_RETURN((LM_ERROR, 00856 ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ") 00857 ACE_TEXT("Illegal integer value for DCPSBitTransportPort (%C) in [repository/%C] section.\n"), 00858 value.c_str(), repo_name.c_str()), 00859 -1); 00860 } 00861 if (DCPS_debug_level > 0) { 00862 ACE_DEBUG((LM_DEBUG, 00863 ACE_TEXT("(%P|%t) [repository/%C]: DCPSBitTransportPort == %d\n"), 00864 repo_name.c_str(), bitPort)); 00865 } 00866 } else { 00867 ACE_ERROR_RETURN((LM_ERROR, 00868 ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ") 00869 ACE_TEXT("Unexpected entry (%C) in [repository/%C] section.\n"), 00870 name.c_str(), repo_name.c_str()), 00871 -1); 00872 } 00873 } 00874 00875 if (values.find("RepositoryIor") == values.end()) { 00876 ACE_ERROR_RETURN((LM_ERROR, 00877 ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ") 00878 ACE_TEXT("Repository section [repository/%C] section is missing RepositoryIor value.\n"), 00879 repo_name.c_str()), 00880 -1); 00881 } 00882 00883 if (!repoKeySpecified) { 00884 // If the RepositoryKey option was not specified, use the section 00885 // name as the repo key 00886 repoKey = repo_name; 00887 } 00888 InfoRepoDiscovery_rch discovery = 00889 new InfoRepoDiscovery(repoKey, repoIor.c_str()); 00890 if (bitPortSpecified) discovery->bit_transport_port(bitPort); 00891 if (bitIpSpecified) discovery->bit_transport_ip(bitIp); 00892 TheServiceParticipant->add_discovery( 00893 DCPS::static_rchandle_cast<Discovery>(discovery)); 00894 } 00895 } 00896 00897 return 0; 00898 }