本文整理汇总了C++中ACE_Configuration_Heap类的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Configuration_Heap类的具体用法?C++ ACE_Configuration_Heap怎么用?C++ ACE_Configuration_Heap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ACE_Configuration_Heap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnFileNewTransientHeap
void MainFrame::OnFileNewTransientHeap(wxCommandEvent& event)
{
delete m_pConfig;
ACE_Configuration_Heap* pHeapConfig = new ACE_Configuration_Heap;
pHeapConfig->open();
SetNewConfig(pHeapConfig);
}
示例2: defined
int
TAO_IFR_Server::open_config (void)
{
if (OPTIONS::instance ()->using_registry ())
{
#if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY)
HKEY root =
ACE_Configuration_Win32Registry::resolve_key (
HKEY_LOCAL_MACHINE,
"Software\\TAO\\IFR"
);
ACE_NEW_THROW_EX (this->config_,
ACE_Configuration_Win32Registry (root),
CORBA::NO_MEMORY ());
#endif /* ACE_WIN32 && !ACE_LACKS_WIN32_REGISTRY */
return 0;
}
else
{
ACE_Configuration_Heap *heap = 0;
ACE_NEW_THROW_EX (heap,
ACE_Configuration_Heap,
CORBA::NO_MEMORY ());
if (OPTIONS::instance ()->persistent ())
{
const char *filename = OPTIONS::instance ()->persistent_file ();
if (heap->open (filename))
{
delete heap;
heap = 0;
ORBSVCS_ERROR_RETURN ((
LM_ERROR,
ACE_TEXT ("Error:: Opening persistent heap file '%s'\n"),
filename
),
-1
);
}
}
else
{
heap->open ();
}
this->config_ = heap;
return 0;
}
}
示例3: Dlg
void MainFrame::OnFileOpenPersistentHeap(wxCommandEvent& event)
{
wxFileDialog Dlg(this, "Choose a file", "", "", "*.*", wxOPEN);
if(Dlg.ShowModal() != wxID_OK)
{
return;
}
delete m_pConfig;
ACE_Configuration_Heap* pHeapConfig = new ACE_Configuration_Heap;
pHeapConfig->open(Dlg.GetFilename());
SetNewConfig(pHeapConfig);
}
示例4: ACE_NEW_RETURN
int
ACE::HTBP::Environment::open_persistent_config (const ACE_TCHAR *persistent_file)
{
ACE_Configuration_Heap *heap;
ACE_NEW_RETURN (heap,
ACE_Configuration_Heap,
-1);
// do this before trying to open so it isn't leaked if the open fails.
this->config_ = heap;
if (persistent_file == 0)
heap->open();
else
if (heap->open (persistent_file) != 0)
ACE_ERROR_RETURN (( LM_ERROR,
ACE_TEXT ("(%P|%t) ACE::HTBP::Environment::")
ACE_TEXT ("open_config: %p\n"),
persistent_file),
-1 );
return 0;
}
示例5: pullValues
int pullValues( ACE_Configuration_Heap& cf,
const ACE_Configuration_Section_Key& key,
ValueMap& values ) {
int index = 0;
ACE_TString name;
ACE_Configuration::VALUETYPE type;
while (cf.enumerate_values( key, index, name, type ) == 0) {
ACE_TString value;
if (type == ACE_Configuration::STRING) {
cf.get_string_value( key, name.c_str(), value );
values[ACE_TEXT_ALWAYS_CHAR(name.c_str())] =
ACE_TEXT_ALWAYS_CHAR(value.c_str());
} else {
ACE_DEBUG((LM_WARNING, "Unexpected value type in config file (ignored): "
"name=%s, type=%d\n", name.c_str(), type));
}
index++;
}
return index;
}
示例6: processSections
int processSections( ACE_Configuration_Heap& cf,
const ACE_Configuration_Section_Key& key,
KeyList& subsections ) {
int index = 0;
ACE_TString name;
while (cf.enumerate_sections( key, index, name ) == 0) {
ACE_Configuration_Section_Key subkey;
if (cf.open_section( key, name.c_str(), 0, subkey ) != 0) {
return 1;
}
subsections.push_back( SubsectionPair( ACE_TEXT_ALWAYS_CHAR(name.c_str()),
subkey ) );
int subindex = 0;
ACE_TString subname;
if (cf.enumerate_sections( subkey, subindex, subname ) == 0) {
// Found additional nesting of subsections that we don't care
// to allow (e.g. [transport/my/yours]), so return an error.
return 1;
}
index++;
}
return 0;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: _
//---------------------------------------------------------------------------------------------
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;
}
示例11: OPENDDS_VECTOR
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);
//.........这里部分代码省略.........
示例12: wxFrame
// frame constructor
MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)0, -1, title, pos, size),
m_pConfig(0)
{
m_pInstance = this;
// Create a persistent heap based configuration
ACE_Configuration_Heap* pHeapConfig = new ACE_Configuration_Heap;
pHeapConfig->open();
m_pConfig = pHeapConfig;
// set the frame icon
SetIcon(wxICON(mondrian));
// Create Splitter
m_pSplitter = new wxSplitterWindow(this, -1);
wxSize sz( m_pSplitter->GetSize() );
sz.SetWidth(sz.GetWidth() / 2);
// List Control
m_pListCtrl = new ValueListCtrl(m_pSplitter, -1, wxDefaultPosition, sz);
// Tree Control
m_pTreeCtrl = new ConfigTreeCtrl(m_pSplitter, FRAME_TREE, wxDefaultPosition, sz,
wxTR_EDIT_LABELS | wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT);
m_pTreeCtrl->SetpListCtrl(m_pListCtrl);
// Setup splitter
m_pSplitter->SplitVertically(m_pTreeCtrl, m_pListCtrl);
m_pSplitter->SetMinimumPaneSize(100);
m_pSplitter->SetSashPosition(size.GetWidth() / 3);
// create a menu bar
wxMenu *menuFile = new wxMenu("", wxMENU_TEAROFF);
menuFile->Append(FILE_NEW_PERSISTENT_HEAP, "New Persistent Heap", "Create a new persistent heap");
menuFile->Append(FILE_NEW_TRANSIENT_HEAP, "New Transient Heap", "Create a new transient heap");
menuFile->Append(FILE_OPEN_PERSISTENT_HEAP, "Open Persistent Heap", "Open Persistent Heap");
#if defined (ACE_WIN32)
menuFile->Append(FILE_OPEN_REGISTRY, "Open Win32 Registry", "Open Win32 Registry");
#endif
menuFile->AppendSeparator();
menuFile->Append(FILE_IMPORT, "Import from INI file", "Import from INI file");
menuFile->Append(FILE_EXPORT, "Export to INI file", "Export to INI file");
menuFile->AppendSeparator();
menuFile->Append(ABOUT, "&About...\tCtrl-A", "Show about dialog");
menuFile->AppendSeparator();
menuFile->Append(QUIT, "E&xit\tAlt-X", "Quit this program");
// now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(menuFile, "&File");
// ... and attach this menu bar to the frame
SetMenuBar(menuBar);
#if wxUSE_STATUSBAR
CreateStatusBar(2);
SetStatusText("Ready");
#endif // wxUSE_STATUSBAR
}
示例13: ACE_TEXT
// 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;
}
示例14: 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
//.........这里部分代码省略.........
示例15: 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);
}
//.........这里部分代码省略.........