Merge pull request #3835 from simpsont-oci/bench_config_name
[OpenDDS.git] / performance-tests / bench / builder / ConfigSectionManager.cpp
blobdd0c0e6672c1a3098abf4dd1fbb6912e4d702d8b
1 #include "ConfigSectionManager.h"
3 #include "dds/DCPS/Service_Participant.h"
5 #include "ace/Configuration.h"
7 #include <iostream>
9 namespace Builder {
11 ConfigSectionManager::ConfigSectionManager(const std::string& name, const ConfigSectionSeq& seq)
13 ACE_Configuration_Heap ach;
14 ach.open();
15 for (CORBA::ULong i = 0; i < seq.length(); ++i) {
16 const ConfigSection& section = seq[i];
17 std::vector<char> buff(std::strlen(section.name.in()) + 1);
18 std::strcpy(&(buff[0]), section.name.in());
19 char* token = std::strtok(&(buff[0]), "/");
20 std::vector<ACE_Configuration_Section_Key> keys;
21 keys.push_back(ach.root_section());
22 while (token != NULL) {
23 ACE_TString ttoken(ACE_TEXT_CHAR_TO_TCHAR(token));
24 if (ttoken.c_str()) {
25 ACE_Configuration_Section_Key sect_key;
26 ach.open_section(keys.back(), ttoken.c_str(), 1, sect_key);
27 keys.push_back(sect_key);
28 token = std::strtok(NULL, "/");
31 for (CORBA::ULong j = 0; j < section.properties.length(); ++j) {
32 if (!std::string(section.properties[j].name).empty()) {
33 Log::log()
34 << "Adding '" << section.properties[j].name
35 << "' = '" << section.properties[j].value
36 << "' to [" << section.name << "] configuration section" << std::endl;
37 ACE_TString tname(ACE_TEXT_CHAR_TO_TCHAR(section.properties[j].name.in()));
38 ACE_TString tvalue(ACE_TEXT_CHAR_TO_TCHAR(section.properties[j].value.in()));
39 ach.set_string_value(keys.back(), tname.c_str(), tvalue.c_str());
43 TheServiceParticipant->load_configuration(ach, ACE_TEXT_CHAR_TO_TCHAR(name.c_str()));