Changeset 10707 for trunk/FACT++
- Timestamp:
- 05/13/11 15:48:57 (14 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Configuration.cc
r10634 r10707 92 92 po::options_description config("Section"); 93 93 config.add_options() 94 ("option1", po_string(), "This is option1") 95 ("option2", po_int(22), "This is option2") 96 ("option3,o", po_double()->required(), "This option is mandatory") 97 ("option4", po_int(&opt), "This is option 4") 98 ("option5", po_strings(), "A list of strings") 99 ("option6", po_strings(), "A list of strings") 100 ("option7", po_strings(), "A list of strings") 94 ("option1", var<string>(), "This is option1") 95 ("option2", var<int>(22), "This is option2") 96 ("option3,o", var<double>->required(), "This option is mandatory") 97 ("option4", var<int>(&opt), "This is option 4") 98 ("option5", vars<string>(), "A list of strings") 99 ("option6", vars<string>(), "A list of strings") 100 ("option7", vars<string>, "A list of strings") 101 ("option8", var<string>()->implicit_value("val"), "Just a string") 102 ("option9", var<string>()->default_value("def"), "Just a string") 103 ("optionA", var<string>("def"), "Just a string") 104 ("bool", po_bool(), "A special switch") 101 105 ; 102 106 … … 119 123 Abbreviations po_ints(), po_doubles() and po_strings() are available. 120 124 121 In addition to options introduced by a minus, so calles positional options 122 can be given on the command line. To describe these options use 125 There are several ways to define the behaviour of the options. In the 126 example above Parse will throw an exception if the "--option3" or "-o" 127 option is not given. "option9" will evaluate to "def" if it is not 128 given on the command line. The syntax of "optionA" is just an 129 abbreviation. "option8" will evaluate to "val" if just "--option5" but 130 no argument is given. Note, that these modifiers can be concatenated. 131 132 A special type po_bool() is provided which is an abbreviation of 133 var<bool>()->implicit_value(true)->default_value(false). In 134 contradiction to po_switch() this allows to set a true and 135 false value in the setup file. 136 137 In addition to options introduced by a minus or double minus, so called 138 positional options can be given on the command line. To describe these 139 options use 123 140 124 141 \code -
trunk/FACT++/src/Configuration.h
r10372 r10707 143 143 { return po::bool_switch(); } 144 144 145 inline po::typed_value<bool> *po_bool() 146 { return po::value<bool>()->implicit_value(true)->default_value(false); } 147 145 148 #endif -
trunk/FACT++/src/argv.cc
r10372 r10707 80 80 // (",A", po_float(), "include path") 81 81 ("radec", po::value<vector<double>>(), "include path") 82 ("switch", po_switch(), "include path") 83 ("bool", var<bool>()->implicit_value(true), "include path") 82 84 ; 83 85 … … 167 169 168 170 cout << "Program " << argv[0] << " started successfully." << endl; 171 172 cout << conf.Has("switch") << " " << conf.Get<bool>("switch") << endl; 173 cout << conf.Has("bool") << " " << conf.Get<bool>("bool") << endl; 174 169 175 return 0; 170 176 /* -
trunk/FACT++/src/dataLogger.cc
r10693 r10707 318 318 public: 319 319 // void setBlackWhiteList(const std::string& , bool); 320 void Setup(Configuration& conf);320 bool SetConfiguration(Configuration& conf); 321 321 322 322 private: … … 681 681 682 682 //services parameters 683 fDebugIsOn = true;//false;683 fDebugIsOn = false; 684 684 fStatsPeriodDuration = 1.0f; 685 685 fOpenedFilesIsOn = true; … … 1269 1269 Message("Run Path: " + actualTargetDir); 1270 1270 stringstream str; 1271 str << "Run Number: " << fRun FileName;1271 str << "Run Number: " << fRunNumber; 1272 1272 Message(str.str()); 1273 1273 Message("----------- OPENED FILES ----------------"); … … 1387 1387 Message("Server "+it->first); 1388 1388 for (std::map<std::string, SubscriptionType>::const_iterator it2=it->second.begin(); it2!=it->second.end(); it2++) 1389 Message(" -> "+it2->first);1389 Message(" -> "+it2->first); 1390 1390 } 1391 1391 if (fIsBlackList) … … 1395 1395 Message("----------- ALLOW LIST ------------------"); 1396 1396 for (set<string>::iterator it=fGreyList.begin(); it != fGreyList.end(); it++) 1397 Message(*it); 1397 Message(*it); 1398 1399 if (fGreyList.size()==0) 1400 Message(" <empty>"); 1401 1398 1402 return GetCurrentState(); 1399 1403 } … … 2083 2087 } 2084 2088 2085 void DataLogger::Setup(Configuration& conf) 2086 { 2089 bool DataLogger::SetConfiguration(Configuration& conf) 2090 { 2091 fDebugIsOn = conf.Get<bool>("debug"); 2092 2087 2093 //Set the block or allow list 2088 2094 fGreyList.clear(); … … 2113 2119 } 2114 2120 } 2121 2122 return true; 2115 2123 } 2116 2124 /* … … 2148 2156 // Start io_service.run to only use the commandHandler command detaching 2149 2157 DataLogger logger(wout); 2158 if (!logger.SetConfiguration(conf)) 2159 return -1; 2160 2150 2161 logger.Run(true); 2151 2162 … … 2174 2185 2175 2186 DataLogger logger(wout); 2187 if (!logger.SetConfiguration(conf)) 2188 return -1; 2176 2189 2177 logger.Setup(conf);2178 2179 2190 shell.SetReceiver(logger); 2180 2191 … … 2256 2267 const string n = conf.GetName()+".log"; 2257 2268 2258 po::options_description config ("Program options");2259 config .add_options()2269 po::options_description configp("Program options"); 2270 configp.add_options() 2260 2271 ("dns", var<string>("localhost"), "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)") 2261 2272 ("log,l", var<string>(n), "Write log-file") 2262 2273 ("console,c", var<int>(), "Use console (0=shell, 1=simple buffered, X=simple unbuffered)") 2263 ("block,b", vars<string>(), "Black-list of services")2264 ("allow,a", vars<string>(), "White-list of services")2265 2274 ; 2266 2275 2276 po::options_description configs("Scheduler options"); 2277 configs.add_options() 2278 ("block,b", vars<string>(), "Black-list of services") 2279 ("allow,a", vars<string>(), "White-list of services") 2280 ("debug", po_bool(), "Debug mode. Print clear text of received service reports to log-stream") 2281 ; 2282 2267 2283 conf.AddEnv("dns", "DIM_DNS_NODE"); 2268 2284 2269 conf.AddOptions(config); 2285 conf.AddOptions(configp); 2286 conf.AddOptions(configs); 2270 2287 } 2271 2288 … … 2312 2329 Dim::Setup(conf.Get<string>("dns")); 2313 2330 2314 try2331 // try 2315 2332 { 2316 2333 // No console access at all … … 2324 2341 return RunShell<LocalConsole>(conf); 2325 2342 } 2326 catch (std::exception& e)2343 /* catch (std::exception& e) 2327 2344 { 2328 2345 cerr << "Exception: " << e.what() << endl; 2329 2346 return -1; 2330 } 2347 }*/ 2331 2348 2332 2349 return 0; -
trunk/FACT++/src/ftmctrl.cc
r10700 r10707 1707 1707 ("dns", var<string>("localhost"), "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)") 1708 1708 ("log,l", var<string>(n), "Write log-file") 1709 ("no-dim,d", po_ switch(),"Disable dim services")1709 ("no-dim,d", po_bool(), "Disable dim services") 1710 1710 ("console,c", var<int>(), "Use console (0=shell, 1=simple buffered, X=simple unbuffered)") 1711 1711 ; … … 1714 1714 control.add_options() 1715 1715 ("addr,a", var<string>("localhost:5000"), "Network address of FTM") 1716 ("quiet,q", po_ switch(),"Disable printing contents of all received messages (except dynamic data) in clear text.")1717 ("hex-out", po_ switch(),"Enable printing contents of all printed messages also as hex data.")1718 ("dynamic-out", po_ switch(),"Enable printing received dynamic data.")1716 ("quiet,q", po_bool(), "Disable printing contents of all received messages (except dynamic data) in clear text.") 1717 ("hex-out", po_bool(), "Enable printing contents of all printed messages also as hex data.") 1718 ("dynamic-out", po_bool(), "Enable printing received dynamic data.") 1719 1719 // ("default-setup", var<string>(), "Binary file with static data loaded whenever a connection to the FTM was established.") 1720 1720 ; -
trunk/FACT++/src/triggerschedule.cc
r10683 r10707 13 13 config.add_options() 14 14 ("dns", var<string>("localhost"), "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)") 15 ("schedule-database", var<string>() ,"Database name for scheduling preview")15 ("schedule-database", var<string>()->required(), "Database name for scheduling preview") 16 16 ; 17 17 … … 64 64 vm = conf.Parse(argc, argv); 65 65 } 66 #if BOOST_VERSION > 104000 67 catch (po::multiple_occurrences &e) 68 { 69 cout << "Error: " << e.what() << " of '" << e.get_option_name() << "' option." << endl; 70 cout << endl; 71 return -1; 72 } 73 #endif 66 74 catch (std::exception &e) 67 75 { 68 #if BOOST_VERSION > 104000 69 po::multiple_occurrences *MO = dynamic_cast<po::multiple_occurrences*>(&e); 70 if (MO) 71 cout << "Error: " << e.what() << " of '" << MO->get_option_name() << "' option." << endl; 72 else 73 #endif 74 cout << "Error: " << e.what() << endl; 76 cout << "Error: " << e.what() << endl; 75 77 cout << endl; 76 78 … … 93 95 } 94 96 95 if (!conf.Has("schedule-database"))96 {97 cout << "Please provide which database you want to use for scheduling using --schedule-database=<dbname>." << endl;98 return -1;99 }100 101 97 const char* dbname = conf.Get<string>("schedule-database").c_str(); 102 98
Note:
See TracChangeset
for help on using the changeset viewer.