本文整理汇总了C++中ConfigMap::find方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigMap::find方法的具体用法?C++ ConfigMap::find怎么用?C++ ConfigMap::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigMap
的用法示例。
在下文中一共展示了ConfigMap::find方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: smLock
ompl::tools::SelfConfig::SelfConfig(const base::SpaceInformationPtr &si, const std::string &context) :
context_(context.empty() ? "" : context + ": ")
{
typedef std::map<base::SpaceInformation*, boost::shared_ptr<SelfConfigImpl> > ConfigMap;
static ConfigMap SMAP;
static boost::mutex LOCK;
boost::mutex::scoped_lock smLock(LOCK);
// clean expired entries from the map
ConfigMap::iterator dit = SMAP.begin();
while (dit != SMAP.end())
{
if (dit->second->expired())
SMAP.erase(dit++);
else
++dit;
}
ConfigMap::const_iterator it = SMAP.find(si.get());
if (it != SMAP.end())
impl_ = it->second.get();
else
{
impl_ = new SelfConfigImpl(si);
SMAP[si.get()].reset(impl_);
}
}
示例2: main
/* main method {{{ */
int main(int argc, char *argv[]) {
ConfigMap config;
if(!parseOptions(argc,argv,config)) { //Parse cmd line options
cerr << "==> Try '" << argv[0] << " --usage'" << endl;
return -1;
}
if(config.find("usage")!=config.end()||config.find("help")!=config.end()) {
usage(argv[0]);
return -1;
}
if(!parseConfig(config)) {
cerr << "==> Try 'man " << argv[0] << "'" << endl;
return -1;
}
return mainFunction(config);
}
示例3: tokenizedValue
StringArray
getMultiConfigItem(const ConfigMap& configItems, const String &itemName, const StringArray& defRetVal, const char* tokenizeSeparator)
{
ConfigMap::const_iterator item = configItems.find(itemName);
if (item != configItems.end())
{
StringArray rv;
rv.reserve(item->second.size());
for (size_t i = 0; i < item->second.size(); ++i)
{
if (tokenizeSeparator)
{
StringArray tokenizedValue(item->second[i].value.tokenize(tokenizeSeparator));
rv.insert(rv.end(), tokenizedValue.begin(), tokenizedValue.end());
}
else
{
rv.push_back(item->second[i].value);
}
}
return rv;
}
else
{
return defRetVal;
}
}
示例4: selectedConfigs
Command::ConfigList Command::selectedConfigs(MasterDevice &m)
{
unsigned int i;
ec_ioctl_master_t master;
ec_ioctl_config_t config;
ConfigList list;
stringstream err;
m.getMaster(&master);
if (aliases == "-" && positions == "-") { // shortcut
for (i = 0; i < master.config_count; i++) {
m.getConfig(&config, i);
list.push_back(config);
}
} else { // take the long way home...
ConfigMap configs;
uint16_t maxAlias = 0;
// fill cascaded map structure with all configs
for (i = 0; i < master.config_count; i++) {
m.getConfig(&config, i);
AliasMap &aliasMap = configs[config.alias];
aliasMap[config.position] = config;
if (config.alias > maxAlias) {
maxAlias = config.alias;
}
}
ConfigAliasParser ap(maxAlias);
NumberListParser::List aliasList = ap.parse(aliases.c_str());
NumberListParser::List::const_iterator ai;
for (ai = aliasList.begin(); ai != aliasList.end(); ai++) {
ConfigMap::iterator ci = configs.find(*ai);
if (ci == configs.end()) {
continue;
}
AliasMap &aliasMap = configs[*ai];
AliasPositionParser pp(aliasMap);
NumberListParser::List posList = pp.parse(positions.c_str());
NumberListParser::List::const_iterator pi;
for (pi = posList.begin(); pi != posList.end(); pi++) {
AliasMap::const_iterator ci;
ci = aliasMap.find(*pi);
if (ci != aliasMap.end()) {
list.push_back(ci->second);
}
}
}
}
list.sort();
return list;
}
示例5: getConfig
/* getConfig: {{{ */
int getConfig(ConfigMap &config, const string &name, int def) {
ConfigMap::iterator it=config.find(name);
if(it!=config.end())
return atoi(config[name].c_str());
cerr << "[W] Key : '" << name << "' not found, using default value : "
<< def << endl;
return def;
}
示例6: GetConfigValue
bool GetConfigValue(ConfigMap& configMap, std::string key, std::string& value) {
if(configMap.find(key) != configMap.end()) {
value = configMap[key];
string trimmedKey = trim(value);
if(trimmedKey == "") {
return false;
}
return true;
}
return false;
}
示例7:
String
getConfigItem(const ConfigMap& configItems, const String &itemName, const String& defRetVal)
{
ConfigMap::const_iterator i = configItems.find(itemName);
if (i != configItems.end() && i->second.size() > 0)
{
return i->second.back().value;
}
else
{
return defRetVal;
}
}
示例8: if
void
setConfigItem(ConfigMap& configItems, const String& itemName,
const String& value, EOverwritePreviousFlag overwritePrevious)
{
ConfigMap::iterator it = configItems.find(itemName);
if (it == configItems.end())
{
configItems[itemName].push_back(ItemData("", value));
}
else if (overwritePrevious == E_OVERWRITE_PREVIOUS)
{
ItemDataArray& values = configItems[itemName];
values.clear();
values.push_back(ItemData("", value));
}
// else overwritePrevious == E_PRESERVE_PREVIOUS, and do nothing
}
示例9: smLock
ompl::tools::SelfConfig::SelfConfig(const base::SpaceInformationPtr &si, const std::string &context) : context_(context)
{
typedef std::map<base::SpaceInformation*, boost::shared_ptr<SelfConfigImpl> > ConfigMap;
static ConfigMap SMAP;
static boost::mutex LOCK;
boost::mutex::scoped_lock smLock(LOCK);
ConfigMap::const_iterator it = SMAP.find(si.get());
if (it != SMAP.end())
impl_ = it->second.get();
else
{
impl_ = new SelfConfigImpl(si);
SMAP[si.get()].reset(impl_);
}
}
示例10: parseConfig
/* parseConfig: {{{ */
bool parseConfig(ConfigMap &config) {
string appKey("");
ifstream file(config["configFile"].c_str(),ios::in);
if(!file.good()) {
cerr << "[E] Error opening the configuration file : '"
<< config["configFile"] << "' !" << endl;
return false;
}
bool res=true;
bool verbose=false;
ConfigMap::iterator it=config.find("general::verbose");
if(it!=config.end())
verbose=true;
while(file) {
string s;
getline(file,s);
s=strip(s);
res=res && readString(s,config,appKey,verbose);
}
file.close();
return res;
}
示例11: mainFunction
/* mainFunction method {{{ */
int mainFunction(ConfigMap &config) {
if(config.find("general::equation")==config.end()) {
cerr << "[E] No problem defined!" << endl;
return -1;
}
cerr << "[I] Initializing problem...\n";
Expression *eqn=parseString(config["general::equation"]);
Expression *pot=parseString(config["general::potential"]);
cerr << "[I] Equation: " << eqn << endl;
cerr << "[I] Potential: " << pot << endl;
VarDef params;
cerr << "[I] Getting parameters:\n";
for(ConfigMap::iterator it=config.begin();it!=config.end();it++) {
if((it->first).find("parameters::")!=string::npos) {
string name=(it->first).substr(12);
params[name]=parseString(it->second);
cerr << "[I]\t" << name << "=" << it->second << "\n";
}
}
cerr.flush();
eqn=eqn->simplify(params);
pot=pot->simplify(params);
GPE *gpe=0;
if(pot->find("X")) {
if(pot->find("Y")) {
if(pot->find("Z")) {
if(eqn->find("LZ"))
gpe=new GPE3DROT(config,eqn,pot);
else
gpe=new GPE3D(config,eqn,pot);
} else {
if(eqn->find("LZ"))
gpe=new GPE2DROT(config,eqn,pot);
else
gpe=new GPE2D(config,eqn,pot);
}
} else
gpe=new GPE1D(config,eqn,pot);
} else if(eqn->find("R"))
gpe=new Polar1D(config,eqn,pot);
if(gpe==0) {
cerr << "[E] Unknown problem type!" << std::endl;
return -1;
}
gpe->initialize(pot);
if(config["in"].size()>0) {
gpe->load(config["in"]);
}
string out="psi1.dat";
if(config["out"].size()>0) {
out=config["out"];
}
string log="";
if(config.find("log")!=config.end()) {
log="log.txt";
if(config["log"].size()>0) {
log=config["log"];
}
}
if(config.find("imprint")!=config.end()) {
int l=getConfig(config,string("imprint"),1);
std::cerr << "[I] Imprinting a l=" << l << " circulation" << endl;
gpe->imprint(l);
}
if(config.find("groundstate")!=config.end()) {
double dt=getConfig(config,string("general::dt"),1e-3);
double tol=getConfig(config,string("general::tol"),1e-12);
double dttol=getConfig(config,string("general::dttol"),0.999);
gpe->findGroundState(dt,tol,dttol,log);
gpe->save(out);
}
if(config.find("spectrum")!=config.end()) {
range<int> def={0,0,1};
range<int> m=getConfig(config,string("spectrum"),def);
for(int i=m.min;i<=m.max;i+=m.incr)
gpe->spectrum(log,i);
}
if(config.find("evolve")!=config.end()) {
range<double> def={0.,1.,1e-3};
range<double> t=getConfig(config,string("evolve"),def);
gpe->evolve(t.min,t.incr,t.max,out);
}
if(config.find("plot")!=config.end()) {
int n=5; //getConfig(config,string("plot"),0);
gpe->plot(n,config["plot"]);
}
if(config.find("measure")!=config.end()) {
std::cout << gpe->measure() << std::endl;
}
return 0;
};
示例12: borderColor
void Text3D::init() {
// load the mask id form file
FILE *f = fopen("./id.txt", "r");
if(f) {
fscanf(f, "%d", &maskId);
fclose(f);
maskId = 1 << (maskId - 1);
}
// Register for node information:
/*
std::string groupName, dataName;
control->nodes->getDataBrokerNames(id, &groupName, &dataName);
control->dataBroker->registerTimedReceiver(this, groupName, dataName, "mars_sim/simTimer", 10, 0);
*/
/* get or create cfg_param
example = control->cfg->getOrCreateProperty("plugin", "example",
0.0, this);
*/
textFactory = libManager->getLibraryAs<osg_text::TextFactoryInterface>("osg_text_factory");
if(textFactory) {
ConfigMap map;
map = ConfigMap::fromYamlFile("Text3DConfig.yml", true);
ConfigVector::iterator it;
osg_text::TextInterface *text;
if(map.find("Labels") != map.end()) {
TextData *td;
double fixedWidth, fixedHeight;
bool drawFrame;
double fontsize;
osg_text::TextAlign align;
for(it = map["Labels"].begin(); it!=map["Labels"].end(); ++it) {
td = new TextData;
td->name = (std::string)it->children["name"][0];
td->value = (std::string)it->children["value"][0];
td->posX = it->children["posX"][0];
td->posY = it->children["posY"][0];
fixedWidth = fixedHeight = -1;
drawFrame = false;
fontsize = 30;
align = osg_text::ALIGN_LEFT;
osg_text::Color c, bgColor(0.0, 0.5, 0.0, 0.5);
osg_text::Color borderColor(1.0, 1.0, 1.0, 0.5);
if(it->children.find("fixedWidth") != it->children.end()) {
fixedWidth = it->children["fixedWidth"][0];
}
if(it->children.find("fixedHeight") != it->children.end()) {
fixedHeight = it->children["fixedHeight"][0];
}
if(it->children.find("frame") != it->children.end()) {
drawFrame = it->children["frame"][0];
}
if(it->children.find("fontsize") != it->children.end()) {
fontsize = it->children["fontsize"][0];
}
if(it->children.find("align") != it->children.end()) {
std::string sAlign = (std::string)it->children["align"][0];
if(sAlign == "right") align = osg_text::ALIGN_RIGHT;
else if(sAlign == "center") align = osg_text::ALIGN_CENTER;
}
if(it->children.find("color") != it->children.end()) {
c.a = it->children["color"][0]["a"][0];
c.r = it->children["color"][0]["r"][0];
c.g = it->children["color"][0]["g"][0];
c.b = it->children["color"][0]["b"][0];
}
if(it->children.find("bgColor") != it->children.end()) {
bgColor.a = it->children["bgColor"][0]["a"][0];
bgColor.r = it->children["bgColor"][0]["r"][0];
bgColor.g = it->children["bgColor"][0]["g"][0];
bgColor.b = it->children["bgColor"][0]["b"][0];
}
if(it->children.find("borderColor") != it->children.end()) {
borderColor.a = it->children["borderColor"][0]["a"][0];
borderColor.r = it->children["borderColor"][0]["r"][0];
borderColor.g = it->children["borderColor"][0]["g"][0];
borderColor.b = it->children["borderColor"][0]["b"][0];
}
td->text = textFactory->createText(td->value, fontsize,
c, td->posX, td->posY, align);
if(drawFrame) {
td->text->setBackgroundColor(bgColor);
td->text->setBorderWidth(4.0);
}
else {
td->text->setBackgroundColor(osg_text::Color(0.0, 0.0, 0.0, 0.0));
td->text->setBorderWidth(0.0);
}
td->text->setBorderColor(borderColor);
td->text->setPadding(10., 10., 10., 10.);
td->text->setFixedWidth(fixedWidth);
td->text->setFixedHeight(fixedHeight);
example = control->cfg->getOrCreateProperty("Text3D",
td->name+"/value",
td->value, this);
td->vId = example.paramId;
//.........这里部分代码省略.........