MINT2
NamedParameterBase.h
Go to the documentation of this file.
1 #ifndef NAMED_PARAMETER_BASE_HH
2 #define NAMED_PARAMETER_BASE_HH
3 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
4 // status: Mon 9 Feb 2009 19:17:56 GMT
5 
6 #include <string>
7 #include <istream>
8 #include <sstream>
9 #include <iostream>
10 #include <vector>
11 
12 #include "Mint/INamedParameter.h"
13 
14 // forward declaration
15 namespace MINT{
16  class NamedParameterBase;
17 }
18 
19 // ... makes this possible as friend of NamedParameterBase
20 std::stringstream& operator>>(std::stringstream& is
22 
23 // back to main definitions/declarations:
24 namespace MINT{
25 
26 class ParsedParameterFile;
27 class ParsedParameterFileList; //forward declaration
28 
29 class NamedParameterBase : virtual public INamedParameter{
30  protected:
31  static bool IveSaidItOnce;
32  std::string _name;
33  // static ParsedParameterFile* _ppF;
36  static std::string _defaultFile; // if "", read default-stream
37  static std::istream* _defaultStreamPtr; // default of this default is &std:cin
38 
39  virtual bool setFromParsedLine(const ParsedParameterLine& line) = 0;
40  virtual bool setFromParsedFile();
42 
43  bool _quiet;
44 
45  public:
46  enum VERBOSITY{VERBOSE=0, QUIET=1};
47 
48  static bool setDefaultInputFile(const std::string& fname);
49  static bool setDefaultInputStream(std::istream& str = std::cin);
50 
51  bool setPPF(ParsedParameterFile* ppF_in = 0);
52  bool read();
53  bool read(std::istream& is);
54  bool read(const std::string& fname);
55 
56  bool reloadFile(const std::string& id);
57 
58  bool setFromInitString(const std::string& str);
59  bool setFromInitStringNoName(const std::string& str_in);
60 
61  NamedParameterBase(const std::string& name_in=""
62  , const char* fname=0
63  , VERBOSITY = VERBOSE);
65  virtual ~NamedParameterBase();
66 
67  virtual const std::string& name() const{
68  return _name;
69  }
70 
71  void quiet(bool beSo=true){_quiet = beSo;}
72  bool gotInitialised() const{return _gotInitialised;}
73 
74  friend std::stringstream& ::operator>>(std::stringstream& is
76 };
77 
78 }//namespace MINT
79 
80 
81 #endif
82 //
bool setPPF(ParsedParameterFile *ppF_in=0)
static std::istream * _defaultStreamPtr
virtual const std::string & name() const
std::stringstream & operator>>(std::stringstream &is, MINT::NamedParameterBase &npb)
void quiet(bool beSo=true)
static bool setDefaultInputFile(const std::string &fname)
ParsedParameterFile * _ppF
static std::string _defaultFile
virtual bool setFromParsedLine(const ParsedParameterLine &line)=0
static ParsedParameterFileList * getFlist()
bool reloadFile(const std::string &id)
static bool setDefaultInputStream(std::istream &str=std::cin)
bool setFromInitString(const std::string &str)
bool setFromInitStringNoName(const std::string &str_in)
NamedParameterBase(const std::string &name_in="", const char *fname=0, VERBOSITY=VERBOSE)