本文整理汇总了C++中Option::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Option::set方法的具体用法?C++ Option::set怎么用?C++ Option::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Option
的用法示例。
在下文中一共展示了Option::set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throw
bool
OptionsCont::set(const std::string &name, const std::string &value) throw(InvalidArgument) {
Option *o = getSecure(name);
if (!o->isWriteable()) {
reportDoubleSetting(name);
return false;
}
try {
if (!o->set(value)) {
return false;
}
} catch (InvalidArgument &e) {
MsgHandler::getErrorInstance()->inform("While processing option '" + name + "':\n " + e.what());
return false;
}
return true;
}
示例2: getSecure
bool
OptionsCont::set(const std::string& name, const std::string& value) {
Option* o = getSecure(name);
if (!o->isWriteable()) {
reportDoubleSetting(name);
return false;
}
try {
if (!o->set(value)) {
return false;
}
} catch (ProcessError& e) {
WRITE_ERROR("While processing option '" + name + "':\n " + e.what());
return false;
}
return true;
}
示例3: InvalidArgument
bool
OptionsCont::set(const std::string &name, bool value) throw(InvalidArgument) {
Option *o = getSecure(name);
if (!o->isBool()) {
throw InvalidArgument("The option '" + name + "' is not a boolean attribute and requires an argument.");
}
if (!o->isWriteable()) {
reportDoubleSetting(name);
return false;
}
try {
if (!o->set(value)) {
return false;
}
} catch (InvalidArgument &e) {
MsgHandler::getErrorInstance()->inform("While processing option '" + name + "':\n " + e.what());
return false;
}
return true;
}
示例4: operator
bool operator()(Option & o) { return (o.set(_v))[Option::F_ADJUSTED]; };
示例5: main
int main ( int argc, char **argv )
{
string appName ( argv[0] );
string appExample ( "partitionConfigFile outputBaseName [ options] \
\n\nDetails:\n\
\tthis program reads a series of connectivity pattern files, and trains a connectomic profile for each ROI\n\
\tpartitionConfigFile contains the names of output from the pipeline.\n\
\tgrpProfile is the output for resultant profiles, written in arma format\n" );
Option<bool> helpOpt ( string ( "-h" ),false,string ( "display this help information. " ),false,no_argument );
Option<int> modeOpt ( "--mode",3,"the mode of engergy functions, e.g., L1COEFFS(0), L2ERROR(1), PENALTY(2), SPARSITY(3), L2ERROR2(4), PENALTY2(5), default: 3", false, requires_argument );
Option<int> modeDOpt ( "--modeD",3,"the constraints on dictionary: L2(0), L1L2(1), L1L2FL(2), L1L2MU(3), default: 3",false,requires_argument );
Option<int> modePOpt ( "--modeP",0,"the method to minimization: AUTO(0), PARAM1(1), PARAM2(2), PARAM3(3), default: 0",false,requires_argument );
Option<float> lambdaOpt ( "--lamda",1," lambda, default: 1", false,requires_argument );
Option<float> lambda2Opt ( "--lamda2", 0.15, "lambda2, default: 0", false,requires_argument );
Option<float> gamma1Opt ( "--gamma1",0.4,"gamma1, default:0.4",false,requires_argument );
Option<float> gamma2Opt ( "--gamma2",0,"gamma2, default:0",false,requires_argument );
Option<bool> posAlphaOpt ( "--posAlpha",true,"where or not constrain alpha to be positive, default: true",false,no_argument );
Option<bool> posDOpt ( "--posD",false,"whether or not constrain Dictionary to be positive, default: false",false,no_argument );
Option<int> iterOpt ( "--iter", 300,"the number of iteration, default: 300",false,requires_argument );
Option<bool> verboseOpt ( "-v",false,"verbose or not,default, false",false,no_argument );
Option<int> numDicOpt ( "-K",5,"the number of dic elems, default: 5",false,requires_argument );
Option<int> batchSizeOpt ( "-b",30,"the number of batch, default: 30", false,requires_argument );
Option<string> aplibFullNameOpt ( "--aplib","/home/kli/bin/apclusterunix64.so","the full path name of ap lib;", false,requires_argument );
Option<float> prefrenceOpt ( "-p",0,"the prefrence of ap clustering, if not set, will use mean similarity.", false,requires_argument );
Option<string> leftPartCenterSphereOpt ( "--leftParts","lh.resx.200.CentersonSphere.vtk","the name of left part centers at reg space, default: lh.parts.200.CentersonSphere.vtk",false,requires_argument );
Option<string> rightPartCenterSphereOpt ( "--rightParts","rh.resx.200.CentersonSphere.vtk","the name of right part centers at reg space, default: rh.parts.200.CentersonSphere.vtk",false,requires_argument );
Option<string> leftLabelMatchAtSubjOpt ( "--leftMatch","labelMatch.lh.resx.200.tmplAtSubj", "the name of left label match for tmpl at subject space, default: labelMatch.lh.resx.200.tmplAtSubj", false,requires_argument );
Option<string> rightLabelMatchAtSubjOpt ( "--rightMatch","labelMatch.rh.resx.200.tmplAtSubj", "the name of right label match for tmpl at subject space, default: labelMatch.rh.resx.200.tmplAtSubj", false,requires_argument );
Option<string> subjDirsListOpt ( "-L","","the list of allReg directory for subjects, no default, must be set", true, requires_argument );
OptionParser cmdParser ( appName,appName+"\t"+appExample );
cmdParser.add ( helpOpt );
cmdParser.add ( verboseOpt );
cmdParser.add ( numDicOpt );
cmdParser.add ( batchSizeOpt );
cmdParser.add ( prefrenceOpt );
cmdParser.add ( modeOpt );
cmdParser.add ( modePOpt );
cmdParser.add ( modeDOpt );
cmdParser.add ( lambdaOpt );
cmdParser.add ( lambda2Opt );
cmdParser.add ( gamma2Opt );
cmdParser.add ( gamma1Opt );
cmdParser.add ( posDOpt );
cmdParser.add ( posAlphaOpt );
cmdParser.add ( iterOpt );
cmdParser.add ( aplibFullNameOpt );
cmdParser.add ( leftLabelMatchAtSubjOpt );
cmdParser.add ( rightLabelMatchAtSubjOpt );
cmdParser.add ( leftPartCenterSphereOpt );
cmdParser.add ( rightPartCenterSphereOpt );
cmdParser.add ( subjDirsListOpt );
cmdParser.parse_command_line ( argc,argv,2 );
if ( 3 > argc || cmdParser.check_compulsory_arguments ( true ) == false ) {
cmdParser.usage();
exit ( EXIT_FAILURE );
}
//set up parameters for dic learning;
ParamDictLearn<float> parameters;
parameters.mode = SPAMS::constraint_type ( modeOpt.value() );
parameters.posAlpha = posAlphaOpt.value();
parameters.lambda= lambdaOpt.value();
parameters.modeD=SPAMS::constraint_type_D ( modeDOpt.value() );
parameters.gamma1=gamma1Opt.value();
parameters.modeParam=SPAMS::mode_compute ( modePOpt.value() );
parameters.gamma2 = gamma2Opt.value(); // for modeD=2;
parameters.iter=iterOpt.value();
parameters.verbose=verboseOpt.value();
//setup input connectivity files;
vector<string> allConfigNames;
KML::ReadNameList(argv[1],allConfigNames);
CfMRIDicccol objfMRIDicccol;
objfMRIDicccol.SetConnectivityFileName(allConfigNames[8]);
objfMRIDicccol.SetNames4TmplLabelMatchAtSubj ( allConfigNames[6],allConfigNames[7]);
objfMRIDicccol.SetNames4PartitionCenterSurfAtRegSpace ( allConfigNames[10],allConfigNames[11] );
objfMRIDicccol.SetData ( subjDirsListOpt.value() );
objfMRIDicccol.SetParamDicLearn ( parameters );
objfMRIDicccol.SetTrainer ( numDicOpt.value(),batchSizeOpt.value(),-1 );
objfMRIDicccol.LearnProfileAndCoordModels();
objfMRIDicccol.SaveProfileAndCoordModels ( argv[2] );
//now clustering profiles;
list<int> v1,v2;
list<float> sims;
float meanSim = objfMRIDicccol.ComputeSims4Profiles ( v1,v2,sims,string ( argv[2] ) +".cluster.sims" );
CAPClustering apc;
apc.SetNPoints ( objfMRIDicccol.GetNROIs() );
apc.SetAplibName ( aplibFullNameOpt.value() );
//.........这里部分代码省略.........
示例6: main
int main(int argc, char *argv[]) {
//parsing options
OptionParser options(title, examples);
options.add(outline);
options.add(mask);
options.add(skull);
options.add(no_output);
options.add(fractional_threshold);
options.add(gradient_threshold);
options.add(radiusarg);
options.add(centerarg);
options.add(apply_thresholding);
options.add(generate_mesh);
options.add(verbose);
options.add(help);
if (argc < 3) {
if (argc == 1) {options.usage(); exit(0);};
if (argc>1)
{
string s = argv[1];
if (s.find("-h")!=string::npos | s.find("--help")!=string::npos )
{options.usage(); exit (0);}
}
cerr<<"error: not enough arguments, use bet -h for help"<<endl;
exit (-1);
}
vector<string> strarg;
for (int i=0; i<argc; i++)
strarg.push_back(argv[i]);
string inputname=strarg[1];
string outputname=strarg[2];
if (inputname.find("-")==0 || outputname.find("-")==0 )
{cerr<<"error : two first arguments should be input and output names, see bet -h for help"<<endl; exit(-1);};
/*
int c=0;
for (int i=0; i<argc; i++)
if (i!=1 & i!=2)
{
strcpy(argv[c], strarg[i].c_str());
c++;
}
argc -=2;
*/
try {
options.parse_command_line(argc, argv, 2); // skip first 2 argv
}
catch(X_OptionError& e) {
options.usage();
cerr << endl << e.what() << endl;
exit(EXIT_FAILURE);
}
catch(std::exception &e) {
cerr << e.what() << endl;
}
if (help.value()) {options.usage(); return 0;};
string out = outputname;
if (out.find(".hdr")!=string::npos) out.erase(out.find(".hdr"), 4);
if (out.find(".img")!=string::npos) out.erase(out.find(".hdr"), 4);
string in = inputname;
if (in.find(".hdr")!=string::npos) in.erase(in.find(".hdr"), 4);
if (in.find(".img")!=string::npos) in.erase(in.find(".hdr"), 4);
if (out == "default__default") {out=in+"_brain";}
//set a memory hanlder that displays an error message
set_new_handler(noMoreMemory);
//the real program
double xarg = 0, yarg = 0, zarg = 0;
if (centerarg.set())
{
/*
if (centerarg.value().size()!=3)
{
cerr<<"three parameters expected for center option !"<<endl;
cerr<<"please check there is no space after commas."<<endl;
exit (-1);
}
else
*/
{
xarg = (double) centerarg.value(0);
yarg = (double) centerarg.value(1);
zarg = (double) centerarg.value(2);
}
}
const double bet_main_parameter = pow(fractional_threshold.value(), .275);
//.........这里部分代码省略.........