• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List

jdxblock.h

00001 /***************************************************************************
00002                           jdxblock.h  -  description
00003                              -------------------
00004     begin                : Sun Jun 6 2004
00005     copyright            : (C) 2001 by Thies H. Jochimsen
00006     email                : jochimse@cns.mpg.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef JDXBLOCK_H
00019 #define JDXBLOCK_H
00020 
00021 #include <tjutils/tjstatic.h>
00022 #include <tjutils/tjlist.h>
00023 
00024 #include <odinpara/jdxbase.h>
00025 #include <odinpara/jdxtypes.h>
00026 
00033 typedef List<JcampDxClass,JcampDxClass*,JcampDxClass&> JDXList; // alias
00034 
00035 
00042 class JcampDxBlock : public virtual JcampDxClass, public JDXList, public StaticHandler<JcampDxBlock> {
00043 
00044  public:
00045 
00050   JcampDxBlock(const STD_string& title="Parameter List",compatMode mode=notBroken);
00051 
00052 
00057   JcampDxBlock(const JcampDxBlock& block);
00058 
00059 
00064   ~JcampDxBlock();
00065 
00066 
00071   JcampDxBlock& operator = (const JcampDxBlock& block);
00072 
00077   JcampDxBlock& merge(JcampDxBlock& block, bool onlyUserPars=true);
00078 
00083   JcampDxBlock& unmerge(JcampDxBlock& block);
00084 
00085 
00091   STD_string printval(const STD_string& parameterName, bool append_unit=false) const;
00092 
00098   bool parseval(const STD_string& parameterName, const STD_string& value);
00099 
00100 
00106   int parseblock(const STD_string& source);
00107 
00112   unsigned int numof_pars() const;
00113 
00114 
00118   JcampDxClass* get_parameter(const STD_string& ldrlabel);
00119 
00120 
00126   bool parameter_exists(const STD_string& ldrlabel) const;
00127 
00133   JcampDxBlock& set_prefix(const STD_string& prefix);
00134 
00140   JcampDxBlock& set_embedded(bool embedded) {embed=embedded; return *this;}
00141 
00147   bool is_embedded() const {return embed;}
00148 
00149 
00150 
00151 
00155   JcampDxClass& operator [] (unsigned int i);
00156 
00160   const JcampDxClass& operator [] (unsigned int i) const;
00161 
00165   JcampDxClass& get_parameter_by_id(int id);
00166 
00167 
00172   JcampDxBlock& create_copy(const JcampDxBlock& src);
00173 
00178   JcampDxBlock& append_copy(const JcampDxClass& src);
00179 
00183   JcampDxBlock& copy_ldr_vals(const JcampDxBlock& src);
00184 
00185 
00191   bool operator == (const JcampDxBlock& rhs) const {return !( ((*this)<rhs) || ((rhs<(*this))) );}
00192 
00193 
00194 
00201   bool operator < (const JcampDxBlock& rhs) const {return compare(rhs);}
00202 
00203 
00210   bool compare(const JcampDxBlock& rhs, const STD_list<STD_string>* exclude=0, double accuracy=0.0) const;
00211 
00212 
00213 #ifndef NO_CMDLINE
00214   JcampDxBlock& parse_cmdline_options(int argc, char *argv[], bool modify=true);
00215   STD_map<STD_string,STD_string> get_cmdline_options() const;
00216   STD_string get_cmdline_usage(const STD_string& lineprefix="") const;
00217 #endif
00218 
00219 
00220   // functions for StaticHandler
00221   static void init_static();
00222   static void destroy_static();
00223 
00224   // overwriting virtual functions from JcampDxClass
00225   STD_string print() const;
00226   JcampDxClass& set_compatmode(compatMode compat_mode);
00227   JcampDxClass& set_parmode(parameterMode parameter_mode);
00228   JcampDxClass& set_filemode(fileMode file_mode);
00229   STD_string get_parx_code(parxCodeType type, const ParxEquiv& equiv=ParxEquiv()) const;
00230   STD_ostream& print2stream(STD_ostream& os) const;
00231   bool parsevalstring (const STD_string&) {return true;}
00232   bool parse(STD_string& parstring);
00233   STD_string printvalstring() const {return "";}
00234   JcampDxClass* create_copy() const {JcampDxBlock* result=new JcampDxBlock; result->create_copy(*this); return result;}
00235   const char* get_typeInfo() const {return "JcampDxBlock";}
00236   JcampDxBlock* cast(JcampDxBlock*) {return this;}
00237   int load(const STD_string &filename);
00238   int write(const STD_string &filename) const;
00239   STD_string get_jdx_prefix() const {return "";}
00240   STD_string get_jdx_postfix() const {return "";}
00241 
00242  protected:
00243 
00248   JcampDxBlock&  append_member(JcampDxClass& ldr,const STD_string ldrlabel="");
00249 
00250 
00251 
00252 
00253  private:
00254   friend class JDXwidget;
00255 
00256   static STD_string extract_parlabel(const STD_string& parstring);
00257 
00258   STD_string print_header() const;
00259   STD_string print_tail() const;
00260 
00261 
00262   JDXList::constiter ldr_exists(const STD_string& label) const;
00263   int parse_ldr_list(STD_string& parstring);
00264 
00265   STD_list<JcampDxClass*>* garbage;
00266   bool embed;
00267 
00268 };
00269 
00270 
00271 
00277 #endif
00278 
00279 

Generated on Tue Dec 18 2012 15:11:14 by  doxygen 1.7.1