本文整理汇总了C++中ACE_Configuration_Heap::root_section方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Configuration_Heap::root_section方法的具体用法?C++ ACE_Configuration_Heap::root_section怎么用?C++ ACE_Configuration_Heap::root_section使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Configuration_Heap
的用法示例。
在下文中一共展示了ACE_Configuration_Heap::root_section方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start_scheduler_algorithm
int KSGateway::start_scheduler_algorithm()
{
std::string config_path = KSGOSUtil::JoinPath(_configuration._basedir,KSG_CONFIG_FILENAME);
ACE_Configuration_Heap config;
if(config.open() == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_Ini_ImpExp config_importer(config);
if(config_importer.import_config(config_path.c_str()) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_Configuration_Section_Key section;
if(config.open_section(config.root_section(),ACE_TEXT(KSG_COMMON_SECT)
,0,section) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_TString v;
if(config.open_section(config.root_section(),ACE_TEXT(KSG_SCHEDULER_SECT)
,0,section) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
if(config.get_string_value(section,KSG_SCHD_ALG,v) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
std::string algs = v.c_str();
std::list<std::string> idstr;
std::back_insert_iterator<std::list<std::string> > iter(idstr);
// 从配置中读取需要启动的任务号
xutil::StringUtil::SpliteString(algs,",",iter);
int count = 0;
for(std::list<std::string>::iterator i = idstr.begin();i != idstr.end();++i,++count)
{
if(init_scheduler_algorithm(*i))
return -1;
}
ACE_DEBUG((LM_TRACE,"启动[%d]个调度算法",count));
return 0;
}
示例2: iniIO
int
Service_Monitor::import_svc_ini(const char* ini_file)
{
int rc = -1;
// load ini file
ACE_Configuration_Heap config;
config.open();
ACE_Ini_ImpExp iniIO(config);
rc = iniIO.import_config(ini_file);
if ( rc != 0 )
return rc;
// clear monitors
monitors_.clear();
ini_file_ = "";
// read ini
ACE_TString name;
for(int i = 0;
config.enumerate_sections(config.root_section(), i, name) == 0;
++i)
{
// not [service] section
if ( !ACE_OS::ace_isalnum(*(name.c_str())) )
continue;
ACE_Configuration_Section_Key sec;
config.open_section(config.root_section(), name.c_str(), 0, sec);
// read svm
ACE_TString str_svm;
config.get_string_value(sec, ACE_TEXT("svm"), str_svm);
// no svm value
if ( str_svm.is_empty() )
continue;
int monitor_sec = ACE_OS::atoi(str_svm.c_str());
if ( monitor_sec >= 0 )
monitors_.insert(std::make_pair(name.c_str(), monitor_sec));
}
return rc;
}
示例3: get_scheduler_alg_thr_count
int KSGateway::get_scheduler_alg_thr_count(const std::string &alg_name)
{
int count = 0;
std::string config_path = KSGOSUtil::JoinPath(_configuration._basedir,KSG_CONFIG_FILENAME);
ACE_Configuration_Heap config;
if(config.open() == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_Ini_ImpExp config_importer(config);
if(config_importer.import_config(config_path.c_str()) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_Configuration_Section_Key section;
if(config.open_section(config.root_section(),ACE_TEXT(KSG_COMMON_SECT)
,0,section) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_TString v;
if(config.open_section(config.root_section(),ACE_TEXT(KSG_SCHEDULER_SECT)
,0,section) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
std::string key_name = alg_name;
key_name += "_thr_count";
if(config.get_string_value(section,key_name.c_str(),v) == -1)
{
count = 5;
}
else
{
count = ACE_OS::atoi(v.c_str());
count = (count <= 0) ? 5 : count;
}
return count;
}
示例4: init
//---------------------------------------------------------------------------------------------
int HA_ccifs::init ( int argc , ACE_TCHAR *argv[] )
{
ACE_Trace _( ACE_TEXT( "%D HA_ccifs::init" ) , __LINE__ );
//command line
//-------------------------------------------------------------------------------
static const ACE_TCHAR options[] = ACE_TEXT (":f:");
ACE_Get_Opt cmd_opts (argc, argv, options, 0);
if (cmd_opts.long_option
(ACE_TEXT ( "config" ), 'f', ACE_Get_Opt::ARG_REQUIRED) == -1)
{ return -1; }
int option;
ACE_TCHAR config_file[MAXPATHLEN];
ACE_OS::strcpy ( config_file, ACE_TEXT ( conf_path.c_str() ) );
while ( ( option = cmd_opts ()) != EOF)
switch ( option )
{
case 'f' :
ACE_OS::strncpy (config_file , cmd_opts.opt_arg () , MAXPATHLEN );
break;
case ':':
ACE_ERROR_RETURN ( ( LM_ERROR , ACE_TEXT ( "-%c requires an argument\n" ) ,
cmd_opts.opt_opt ()) , -1 );
default:
ACE_ERROR_RETURN ( ( LM_ERROR , ACE_TEXT ( "parse error.\n" ) ) ,
- 1);
}
//configuration file
//-------------------------------------------------------------------------------
ACE_Configuration_Heap config;
config.open ();
ACE_Registry_ImpExp config_importer (config);
if ( config_importer.import_config (config_file) == -1 )
{ ACE_ERROR_RETURN ( ( LM_ERROR , ACE_TEXT ("%p\n") , config_file ) , -1 ); }
ACE_Configuration_Section_Key dispatcher_section;
if (config.open_section (config.root_section (),
ACE_TEXT ("HA_ccifs"),
0,
dispatcher_section) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ( "can't open HA_ccifs section" ) ) ,
-1 );
//fifo
u_int dispatcher_port;
if (config.get_integer_value ( dispatcher_section,
ACE_TEXT ( "fifo" ) ,
dispatcher_port ) == -1 )
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("HA_ccifs fifo")
ACE_TEXT (" does not exist\n") ) ,
-1 );
//ccifs
ACE_TString ccifs;
if (config.get_string_value ( dispatcher_section,
ACE_TEXT ( "ccifs_tmpfs_mount" ) ,
ccifs ) == -1 )
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("HA_ccifs ccifs_mount")
ACE_TEXT (" does not exist\n") ) ,
-1 );
if( ACE_Thread_Manager::instance()->spawn( ACE_THR_FUNC (ccifs_func) ,
(void*) this ,
THR_NEW_LWP ,
&m_thread_id ) )
{
ACE_DEBUG
((LM_DEBUG, ACE_TEXT ("(%t) ..spawned ccifs notify thread..\n")));
}
else
{
ACE_DEBUG
((LM_DEBUG, ACE_TEXT ("(%t) ..spawning ccifs notify failed..\n")));
}
return 0;
}
示例5: if
int
TransportRegistry::load_transport_configuration(const OPENDDS_STRING& file_name,
ACE_Configuration_Heap& cf)
{
const ACE_Configuration_Section_Key &root = cf.root_section();
// Create a vector to hold configuration information so we can populate
// them after the transports instances are created.
typedef std::pair<TransportConfig_rch, OPENDDS_VECTOR(OPENDDS_STRING) > ConfigInfo;
OPENDDS_VECTOR(ConfigInfo) configInfoVec;
// Record the transport instances created, so we can place them
// in the implicit transport configuration for this file.
OPENDDS_LIST(TransportInst_rch) instances;
ACE_TString sect_name;
for (int index = 0;
cf.enumerate_sections(root, index, sect_name) == 0;
++index) {
if (ACE_OS::strcmp(sect_name.c_str(), TRANSPORT_SECTION_NAME) == 0) {
// found the [transport/*] section, now iterate through subsections...
ACE_Configuration_Section_Key sect;
if (cf.open_section(root, sect_name.c_str(), 0, sect) != 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("failed to open section %s\n"),
sect_name.c_str()),
-1);
} else {
// Ensure there are no properties in this section
ValueMap vm;
if (pullValues(cf, sect, vm) > 0) {
// There are values inside [transport]
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("transport sections must have a section name\n"),
sect_name.c_str()),
-1);
}
// Process the subsections of this section (the individual transport
// impls).
KeyList keys;
if (processSections( cf, sect, keys ) != 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("too many nesting layers in [%s] section.\n"),
sect_name.c_str()),
-1);
}
for (KeyList::const_iterator it=keys.begin(); it != keys.end(); ++it) {
OPENDDS_STRING transport_id = (*it).first;
ACE_Configuration_Section_Key inst_sect = (*it).second;
ValueMap values;
if (pullValues( cf, (*it).second, values ) != 0) {
// Get the factory_id for the transport.
OPENDDS_STRING transport_type;
ValueMap::const_iterator vm_it = values.find("transport_type");
if (vm_it != values.end()) {
transport_type = (*vm_it).second;
} else {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("missing transport_type in [transport/%C] section.\n"),
transport_id.c_str()),
-1);
}
// Create the TransportInst object and load the transport
// configuration in ACE_Configuration_Heap to the TransportInst
// object.
TransportInst_rch inst = this->create_inst(transport_id,
transport_type);
if (inst == 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("Unable to create transport instance in [transport/%C] section.\n"),
transport_id.c_str()),
-1);
}
instances.push_back(inst);
inst->load(cf, inst_sect);
} else {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("missing transport_type in [transport/%C] section.\n"),
transport_id.c_str()),
-1);
}
}
}
} else if (ACE_OS::strcmp(sect_name.c_str(), CONFIG_SECTION_NAME) == 0) {
// found the [config/*] section, now iterate through subsections...
ACE_Configuration_Section_Key sect;
if (cf.open_section(root, sect_name.c_str(), 0, sect) != 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("failed to open section [%s]\n"),
sect_name.c_str()),
-1);
//.........这里部分代码省略.........
示例6: cmd_opts
// Listing 1 code/ch19
int
HA_Status::init (int argc, ACE_TCHAR *argv[])
{
static const ACE_TCHAR options[] = ACE_TEXT (":f:");
ACE_Get_Opt cmd_opts (argc, argv, options, 0);
if (cmd_opts.long_option
(ACE_TEXT ("config"), 'f', ACE_Get_Opt::ARG_REQUIRED) == -1)
return -1;
int option;
ACE_TCHAR config_file[MAXPATHLEN];
ACE_OS::strcpy (config_file, ACE_TEXT ("HAStatus.conf"));
while ((option = cmd_opts ()) != EOF)
switch (option)
{
case 'f':
ACE_OS::strncpy (config_file,
cmd_opts.opt_arg (),
MAXPATHLEN);
break;
case ':':
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("-%c requires an argument\n"),
cmd_opts.opt_opt ()),
-1);
default:
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Parse error.\n")),
-1);
}
ACE_Configuration_Heap config;
config.open ();
ACE_Registry_ImpExp config_importer (config);
if (config_importer.import_config (config_file) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
config_file),
-1);
ACE_Configuration_Section_Key status_section;
if (config.open_section (config.root_section (),
ACE_TEXT ("HAStatus"),
0,
status_section) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("Can't open HAStatus section")),
-1);
u_int status_port;
if (config.get_integer_value (status_section,
ACE_TEXT ("ListenPort"),
status_port) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("HAStatus ListenPort ")
ACE_TEXT ("does not exist\n")),
-1);
this->listen_addr_.set (static_cast<u_short> (status_port));
if (this->acceptor_.open (this->listen_addr_) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("HAStatus %p\n"),
ACE_TEXT ("accept")),
-1);
return 0;
}
示例7: loadConfig
int KSGConfig::loadConfig(const std::string& file_name)
{
ACE_Configuration_Heap config;
if(config.open() == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_Ini_ImpExp config_importer(config);
if(config_importer.import_config(file_name.c_str()) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_Configuration_Section_Key section;
if(config.open_section(config.root_section(),ACE_TEXT(KSG_COMMON_SECT)
,0,section) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_TString v;
if(config.get_string_value(section,ACE_TEXT(KSG_MAJOR_VER),v) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
_majorVer = ACE_OS::atoi(v.c_str());
if(config.get_string_value(section,KSG_MINOR_VER,v) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
_minorVer = ACE_OS::atoi(v.c_str());
if(config.open_section(config.root_section(),ACE_TEXT(KSG_SERVER_SECT)
,0,section) == -1 )
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
if(config.get_string_value(section,KSG_SVR_IP,v) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
_drtpSvrIP = v.c_str();
if(config.get_string_value(section,KSG_SVR_PORT,v) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
_drtpSvrPort = ACE_OS::atoi(v.c_str());
if(config.get_string_value(section,KSG_SVR_BRANCE_NO,v) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
_drtpNo = ACE_OS::atoi(v.c_str());
if(config.get_string_value(section,KSG_SVR_MAINFUNC,v) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
_drtpMainFunc = ACE_OS::atoi(v.c_str());
if(config.get_string_value(section,KSG_SVR_POOL_CONN,v) == -1)
_drtpPoolMaxCnt = 5;
else
_drtpPoolMaxCnt = ACE_OS::atoi(v.c_str());
if(_drtpPoolMaxCnt < 0)
_drtpPoolMaxCnt = 5;
if(_drtpPoolMaxCnt > 30)
_drtpPoolMaxCnt = 30;
if(config.get_string_value(section,KSG_SVR_BCC,v) == -1)
_start_bcc = 0;
else
_start_bcc = ACE_OS::atoi(v.c_str());
/// 是否加载卡状态
if(config.get_string_value(section,KSG_SVR_LOAD_CARD_STATE,v) == -1)
_loadCardState = 0;
else
_loadCardState = ACE_OS::atoi(v.c_str());
if(config.open_section(config.root_section(),ACE_TEXT(KSG_GATEWAY_SECT)
,0,section) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
if(config.get_string_value(section,KSG_GW_IP,v) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
_localIP = v.c_str();
if(config.open_section(config.root_section(),ACE_TEXT(KSG_SCHEDULER_SECT)
,0,section) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
_runTaskIds = "";
if(config.get_string_value(section,KSG_SCHD_IDS,v) != -1)
{
_runTaskIds = v.c_str();
}
_listenerIds = "";
if(config.get_string_value(section,KSG_LISTENER_IDS,v) != -1)
{
_listenerIds = v.c_str();
}
if(config.get_string_value(section,"conn_interval",v)==-1)
_conn_interval = 100;
else
//.........这里部分代码省略.........
示例8: InfoRepoDiscovery
int
InfoRepoDiscovery::Config::discovery_config(ACE_Configuration_Heap& cf)
{
const ACE_Configuration_Section_Key& root = cf.root_section();
ACE_Configuration_Section_Key repo_sect;
if (cf.open_section(root, REPO_SECTION_NAME, 0, repo_sect) != 0) {
if (DCPS_debug_level > 0) {
// This is not an error if the configuration file does not have
// any repository (sub)section. The code default configuration will be used.
ACE_DEBUG((LM_NOTICE,
ACE_TEXT("(%P|%t) NOTICE: InfoRepoDiscovery::Config::discovery_config ")
ACE_TEXT("failed to open [%s] section.\n"),
REPO_SECTION_NAME));
}
return 0;
} else {
// Ensure there are no properties in this section
ValueMap vm;
if (pullValues(cf, repo_sect, vm) > 0) {
// There are values inside [repo]
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
ACE_TEXT("repo sections must have a subsection name\n")),
-1);
}
// Process the subsections of this section (the individual repos)
KeyList keys;
if (processSections( cf, repo_sect, keys ) != 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
ACE_TEXT("too many nesting layers in the [repo] section.\n")),
-1);
}
// Loop through the [repo/*] sections
for (KeyList::const_iterator it=keys.begin(); it != keys.end(); ++it) {
std::string repo_name = (*it).first;
ValueMap values;
pullValues( cf, (*it).second, values );
Discovery::RepoKey repoKey = Discovery::DEFAULT_REPO;
bool repoKeySpecified = false, bitIpSpecified = false,
bitPortSpecified = false;
std::string repoIor;
int bitPort = 0;
std::string bitIp;
for (ValueMap::const_iterator it=values.begin(); it != values.end(); ++it) {
std::string name = (*it).first;
if (name == "RepositoryKey") {
repoKey = (*it).second;
repoKeySpecified = true;
if (DCPS_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) [repository/%C]: RepositoryKey == %C\n"),
repo_name.c_str(), repoKey.c_str()));
}
} else if (name == "RepositoryIor") {
repoIor = (*it).second;
if (DCPS_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) [repository/%C]: RepositoryIor == %C\n"),
repo_name.c_str(), repoIor.c_str()));
}
} else if (name == "DCPSBitTransportIPAddress") {
bitIp = (*it).second;
bitIpSpecified = true;
if (DCPS_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) [repository/%C]: DCPSBitTransportIPAddress == %C\n"),
repo_name.c_str(), bitIp.c_str()));
}
} else if (name == "DCPSBitTransportPort") {
std::string value = (*it).second;
bitPort = ACE_OS::atoi(value.c_str());
bitPortSpecified = true;
if (convertToInteger(value, bitPort)) {
} else {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
ACE_TEXT("Illegal integer value for DCPSBitTransportPort (%C) in [repository/%C] section.\n"),
value.c_str(), repo_name.c_str()),
-1);
}
if (DCPS_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) [repository/%C]: DCPSBitTransportPort == %d\n"),
repo_name.c_str(), bitPort));
}
} else {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
ACE_TEXT("Unexpected entry (%C) in [repository/%C] section.\n"),
name.c_str(), repo_name.c_str()),
-1);
}
//.........这里部分代码省略.........