11 #ifndef __Pulsar_Config_h
12 #define __Pulsar_Config_h
14 #include "Configuration.h"
15 #include "TextInterfaceInterpreter.h"
16 #include "CommandParser.h"
62 bool databases_loaded;
74 Option (
const std::string& name,
const T& default_value,
75 const std::string& description =
"none",
76 const std::string& detailed_description =
"none" );
80 const std::string& name,
81 const std::string& default_value,
82 const std::string& description =
"none",
83 const std::string& detailed_description =
"none" );
87 const std::string& name,
const T& default_value,
88 const std::string& description =
"none",
89 const std::string& detailed_description =
"none" );
93 const std::string& name,
94 const std::string& description =
"none",
95 const std::string& detailed_description =
"none" );
100 const std::string& name,
101 const std::string& default_value,
102 const std::string& description =
"none",
103 const std::string& detailed_description =
"none" );
109 std::string description;
110 std::string detailed_description;
114 std::ostream& operator << (std::ostream& ostr,
const Option<T>& o)
118 std::istream& operator >> (std::istream& istr, Option<T>& option)
119 { T val; istr >> val; option.set_value (val);
return istr; }
135 typename Element<T>::Type* add (Option<T>* option)
139 typename Element<T>::Type* getset;
141 getset = gen (option->get_key(),
145 getset->instance = option;
146 getset->set_description (option->description);
147 getset->set_detailed_description (option->detailed_description);
153 template<
typename T,
typename Parser>
154 void add (Option<T>* option, Parser* parser)
156 add_value( TextInterface::new_Interpreter( option->get_key(),
158 option->detailed_description,
160 &CommandParser::empty,
161 &CommandParser::parse ) );
170 const std::string& _description,
171 const std::string& _detailed_description)
174 DEBUG(
"Pulsar::Option<T> name=" << _name \
175 <<
" description=" << _description <<
" default=" << _default);
177 description = _description;
178 detailed_description = _detailed_description;
180 DEBUG(
"Pulsar::Option<T> add to interface");
182 Config::get_interface()->add (
this);
184 DEBUG(
"Pulsar::Option<T> return");
189 const std::string& _name,
190 const std::string& _default,
191 const std::string& _description,
192 const std::string& _detailed_description )
196 DEBUG(
"Pulsar::Option<T> parser around Configuration::parameter");
198 description = _description;
199 detailed_description = _detailed_description;
201 DEBUG(
"Pulsar::Option<T> parser add to interface");
203 Config::get_interface()->add (
this, parser);
205 DEBUG(
"Pulsar::Option<T> parser return");
210 const std::string& _name,
const T& _default,
211 const std::string& _description,
212 const std::string& _detailed_description )
215 DEBUG(
"Pulsar::Option<T> wrap Configuration::parameter");
217 description = _description;
218 detailed_description = _detailed_description;
219 parameter.set_key (_name);
221 parameter.set_loader( this->loader );
224 DEBUG(
"Pulsar::Option<T> wrap add to interface");
226 Config::get_interface()->add(
this)->instance = ¶meter;
228 DEBUG(
"Pulsar::Option<T> wrap return");
233 const std::string& _name,
234 const std::string& _description,
235 const std::string& _detailed_description )
238 DEBUG(
"Pulsar::Option<T> wrap Configuration::parameter");
240 description = _description;
241 detailed_description = _detailed_description;
242 parameter.set_key (_name);
244 parameter.set_loader( this->loader );
247 DEBUG(
"Pulsar::Option<T> wrap add to interface");
249 Config::get_interface()->add(
this)->instance = ¶meter;
251 DEBUG(
"Pulsar::Option<T> wrap return");
257 const std::string& _name,
258 const std::string& _default,
259 const std::string& _description,
260 const std::string& _detailed_description )
264 DEBUG(
"Pulsar::Option<T> wrap parser around Configuration::parameter");
266 description = _description;
267 detailed_description = _detailed_description;
268 parameter.set_key (_name);
270 DEBUG(
"Pulsar::Option<T> wrap parser that=" << ¶meter <<
" loader=" << this->loader);
272 parameter.set_loader( this->loader );
275 DEBUG(
"Pulsar::Option<T> wrap parser add to interface");
277 Config::get_interface()->add (
this, parser);
279 DEBUG(
"Pulsar::Option<T> wrap parser return");