ldrblock.h
1 /***************************************************************************
2  ldrblock.h - description
3  -------------------
4  begin : Sun Jun 6 2004
5  copyright : (C) 2000-2015 by Thies H. Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef LDRBLOCK_H
19 #define LDRBLOCK_H
20 
21 #include <tjutils/tjstatic.h>
22 #include <tjutils/tjlist.h>
23 
24 #include <odinpara/ldrbase.h>
25 
26 
34 
35 
42 class LDRblock : public virtual LDRbase, public LDRlist, public StaticHandler<LDRblock> {
43 
44  public:
45 
50  LDRblock(const STD_string& title="Parameter List");
51 
52 
57  LDRblock(const LDRblock& block);
58 
59 
64  ~LDRblock();
65 
66 
71  LDRblock& operator = (const LDRblock& block);
72 
77  LDRblock& merge(LDRblock& block, bool onlyUserPars=true);
78 
83  LDRblock& unmerge(LDRblock& block);
84 
85 
91  STD_string printval(const STD_string& parameterName, bool append_unit=false) const;
92 
98  bool parseval(const STD_string& parameterName, const STD_string& value);
99 
100 
106  int parseblock(const STD_string& source, const LDRserBase& serializer=LDRserJDX());
107 
112  unsigned int numof_pars() const;
113 
114 
118  LDRbase* get_parameter(const STD_string& ldrlabel);
119 
120 
126  bool parameter_exists(const STD_string& ldrlabel) const;
127 
133  LDRblock& set_prefix(const STD_string& prefix);
134 
140  LDRblock& set_embedded(bool embedded) {embed=embedded; return *this;}
141 
147  bool is_embedded() const {return embed;}
148 
149 
150 
151 
155  LDRbase& operator [] (unsigned int i);
156 
160  const LDRbase& operator [] (unsigned int i) const;
161 
165  LDRbase& get_parameter_by_id(int id);
166 
167 
172  LDRblock& create_copy(const LDRblock& src);
173 
178  LDRblock& append_copy(const LDRbase& src);
179 
183  LDRblock& copy_ldr_vals(const LDRblock& src);
184 
185 
191  bool operator == (const LDRblock& rhs) const {return !( ((*this)<rhs) || ((rhs<(*this))) );}
192 
193 
194 
201  bool operator < (const LDRblock& rhs) const {return compare(rhs);}
202 
203 
210  bool compare(const LDRblock& rhs, const STD_list<STD_string>* exclude=0, double accuracy=0.0) const;
211 
212 
213 #ifndef NO_CMDLINE
214  LDRblock& parse_cmdline_options(int argc, char *argv[], bool modify=true);
215  STD_map<STD_string,STD_string> get_cmdline_options() const;
216  STD_string get_cmdline_usage(const STD_string& lineprefix="") const;
217 #endif
218 
219 
220  // functions for StaticHandler
221  static void init_static();
222  static void destroy_static();
223 
224  // overwriting virtual functions from LDRbase
225  STD_string print(const LDRserBase& serializer=LDRserJDX()) const;
226  LDRbase& set_parmode(parameterMode parameter_mode);
227  LDRbase& set_filemode(fileMode file_mode);
228  STD_string get_parx_code(parxCodeType type) const;
229  STD_ostream& print2stream(STD_ostream& os, const LDRserBase& serializer) const;
230  bool parsevalstring(const STD_string&, const LDRserBase* ser=0) {return true;}
231  bool parse(STD_string& parstring, const LDRserBase& serializer);
232  STD_string printvalstring(const LDRserBase* ser=0) const {return "";}
233  LDRbase* create_copy() const {LDRblock* result=new LDRblock; result->create_copy(*this); return result;}
234  STD_string get_typeInfo(bool parx_equivtype=false) const {return "LDRblock";}
235  LDRblock* cast(LDRblock*) {return this;}
236  int load(const STD_string &filename, const LDRserBase& serializer=LDRserJDX());
237  int write(const STD_string &filename, const LDRserBase& serializer=LDRserJDX()) const;
238 
239  protected:
240 
245  LDRblock& append_member(LDRbase& ldr,const STD_string ldrlabel="");
246 
247 
248 
249 
250  private:
251  friend class LDRwidget;
252 
253 
254  LDRlist::constiter ldr_exists(const STD_string& label) const;
255  int parse_ldr_list(STD_string& parstring, const LDRserBase& serializer);
256 
257  STD_list<LDRbase*>* garbage;
258  bool embed;
259 
260 };
261 
262 
263 
269 #endif
270 
271 
bool parseval(const STD_string &parameterName, const STD_string &value)
STD_ostream & print2stream(STD_ostream &os, const LDRserBase &serializer) const
LDRbase * get_parameter(const STD_string &ldrlabel)
STD_string print(const LDRserBase &serializer=LDRserJDX()) const
LDRblock & operator=(const LDRblock &block)
parxCodeType
Definition: ldrbase.h:216
LDRblock(const STD_string &title="Parameter List")
bool parameter_exists(const STD_string &ldrlabel) const
bool parsevalstring(const STD_string &, const LDRserBase *ser=0)
Definition: ldrblock.h:230
LDRblock & unmerge(LDRblock &block)
LDRbase & set_parmode(parameterMode parameter_mode)
LDRblock & merge(LDRblock &block, bool onlyUserPars=true)
LDRblock & copy_ldr_vals(const LDRblock &src)
STD_string get_typeInfo(bool parx_equivtype=false) const
Definition: ldrblock.h:234
LDRblock & append_member(LDRbase &ldr, const STD_string ldrlabel="")
LDRblock & create_copy(const LDRblock &src)
bool operator<(const LDRblock &rhs) const
Definition: ldrblock.h:201
int write(const STD_string &filename, const LDRserBase &serializer=LDRserJDX()) const
LDRbase & get_parameter_by_id(int id)
LDRblock & set_prefix(const STD_string &prefix)
int load(const STD_string &filename, const LDRserBase &serializer=LDRserJDX())
Definition: tjlist.h:105
LDRblock & set_embedded(bool embedded)
Definition: ldrblock.h:140
bool parse(STD_string &parstring, const LDRserBase &serializer)
bool compare(const LDRblock &rhs, const STD_list< STD_string > *exclude=0, double accuracy=0.0) const
parameterMode
Definition: ldrbase.h:44
LDRbase & set_filemode(fileMode file_mode)
LDRblock & append_copy(const LDRbase &src)
LDRbase * create_copy() const
Definition: ldrblock.h:233
bool operator==(const LDRblock &rhs) const
Definition: ldrblock.h:191
int parseblock(const STD_string &source, const LDRserBase &serializer=LDRserJDX())
fileMode
Definition: ldrbase.h:54
STD_list< P >::const_iterator constiter
Definition: tjlist.h:156
STD_string get_parx_code(parxCodeType type) const
STD_string printval(const STD_string &parameterName, bool append_unit=false) const
bool is_embedded() const
Definition: ldrblock.h:147
STD_string printvalstring(const LDRserBase *ser=0) const
Definition: ldrblock.h:232
LDRbase & operator[](unsigned int i)
unsigned int numof_pars() const