Home
Install
Use
Develop
Support
News
Credits
hosted by
|
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; }
121 class Config::Interface : public TextInterface::Parser
131 typedef TextInterface::Attribute< Configuration::Parameter<T> > Type;
135 typename Element<T>::Type* add (Option<T>* option)
137 TextInterface::Allocator< Configuration::Parameter<T>,T > gen;
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");
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");
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");
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");
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");
279 DEBUG( "Pulsar::Option<T> wrap parser return");
void set_value(const T &val)
Configuration(const char *filename=0)
Configuration option. Definition Config.h:69
Option(Configuration::Parameter< T > ¶meter, CommandParser *parser, const std::string &name, const std::string &default_value, const std::string &description="none", const std::string &detailed_description="none") Wrap an existing Configuration::Parameter with an associated parser. Definition Config.h:255
Option(Configuration::Parameter< T > ¶meter, const std::string &name, const std::string &description="none", const std::string &detailed_description="none") Wrap an existing Configuration::Parameter with own default value. Definition Config.h:232
Option(const std::string &name, const T &default_value, const std::string &description="none", const std::string &detailed_description="none") Construct a new Configuration::Parameter. Definition Config.h:168
Option(CommandParser *parser, const std::string &name, const std::string &default_value, const std::string &description="none", const std::string &detailed_description="none") Construct a new Configuration::Parameter with an associated parser. Definition Config.h:188
Option(Configuration::Parameter< T > ¶meter, const std::string &name, const T &default_value, const std::string &description="none", const std::string &detailed_description="none") Wrap an existing Configuration::Parameter. Definition Config.h:209
Stores PSRCHIVE configuration parameters. Definition Config.h:22
static Config * get_configuration() Return the configuration key/value pairs. Definition Config.C:135
Config() Default constructor. Definition Config.C:27
void set_filename(const std::string &) Set the configuration filename. Definition Config.C:33
static std::string get_runtime() Return the name of the runtime directory. Definition Config.C:120
static Interface * get_interface() Return the text interface to the configuration parameters. Definition Config.C:144
static void ensure_linkage() Ensure that configuration options are linked.
static Interface * interface The global configuration interpreter. Definition Config.h:56
void load() Load the global configuration files. Definition Config.C:43
static Config * config The global configuration file. Definition Config.h:53
static std::string get_home() Return the name of the installation directory. Definition Config.C:125
Configuration option. Definition Config.h:69
Option(const std::string &name, const T &default_value, const std::string &description="none", const std::string &detailed_description="none") Construct a new Configuration::Parameter. Definition Config.h:168
T & operator=(const T &t) Set equal to T operator. Definition Config.h:106
void add_value(Value *value)
Defines the PSRCHIVE library. Definition CalSource.h:17
Generated using doxygen 1.14.0
|