00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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;
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
00090 STD_string printval(const STD_string& parameterName) const;
00091
00097 bool parseval(const STD_string& parameterName, const STD_string& value);
00098
00099
00105 int parseblock(const STD_string& source);
00106
00111 unsigned int numof_pars() const;
00112
00113
00117 JcampDxClass* get_parameter(const STD_string& ldrlabel);
00118
00119
00125 bool parameter_exists(const STD_string& ldrlabel) const;
00126
00132 JcampDxBlock& set_prefix(const STD_string& prefix);
00133
00139 JcampDxBlock& set_embedded(bool embedded) {embed=embedded; return *this;}
00140
00146 bool is_embedded() const {return embed;}
00147
00148
00149
00150
00154 JcampDxClass& operator [] (unsigned int i);
00155
00159 const JcampDxClass& operator [] (unsigned int i) const;
00160
00164 JcampDxClass& get_parameter_by_id(int id);
00165
00166
00171 JcampDxBlock& create_copy(const JcampDxBlock& src);
00172
00177 JcampDxBlock& append_copy(const JcampDxClass& src);
00178
00182 JcampDxBlock& copy_ldr_vals(const JcampDxBlock& src);
00183
00184
00190 bool operator == (const JcampDxBlock& rhs) const {return !( ((*this)<rhs) || ((rhs<(*this))) );}
00191
00192
00193
00200 bool operator < (const JcampDxBlock& rhs) const {return compare(rhs);}
00201
00202
00209 bool compare(const JcampDxBlock& rhs, const STD_list<STD_string>* exclude=0, double accuracy=0.0) const;
00210
00211
00212 #ifndef NO_CMDLINE
00213 JcampDxBlock& parse_cmdline_options(int argc, char *argv[], bool modify=true);
00214 STD_map<STD_string,STD_string> get_cmdline_options() const;
00215 STD_string get_cmdline_usage(const STD_string& lineprefix="") const;
00216 #endif
00217
00218
00219
00220 static void init_static();
00221 static void destroy_static();
00222
00223
00224 STD_string print() const;
00225 JcampDxClass& set_compatmode(compatMode compat_mode);
00226 JcampDxClass& set_parmode(parameterMode parameter_mode);
00227 JcampDxClass& set_filemode(fileMode file_mode);
00228 STD_string get_parx_code(parxCodeType type, const ParxEquiv& equiv=ParxEquiv()) const;
00229 STD_ostream& print2stream(STD_ostream& os) const;
00230 bool parsevalstring (const STD_string&) {return true;}
00231 bool parse(STD_string& parstring);
00232 STD_string printvalstring() const {return "";}
00233 JcampDxClass* create_copy() const {JcampDxBlock* result=new JcampDxBlock; result->create_copy(*this); return result;}
00234 const char* get_typeInfo() const {return "JcampDxBlock";}
00235 JcampDxBlock* cast(JcampDxBlock*) {return this;}
00236 int load(const STD_string &filename);
00237 int write(const STD_string &filename) const;
00238 STD_string get_jdx_prefix() const {return "";}
00239 STD_string get_jdx_postfix() const {return "";}
00240
00241 protected:
00242
00247 JcampDxBlock& append_member(JcampDxClass& ldr,const STD_string ldrlabel="");
00248
00249
00250
00251
00252 private:
00253 friend class JDXwidget;
00254
00255 static STD_string extract_parlabel(const STD_string& parstring);
00256
00257 STD_string print_header() const;
00258 STD_string print_tail() const;
00259
00260
00261 JDXList::constiter ldr_exists(const STD_string& label) const;
00262 int parse_ldr_list(STD_string& parstring);
00263
00264 STD_list<JcampDxClass*>* garbage;
00265 bool embed;
00266
00267 };
00268
00269
00270
00276 #endif
00277
00278