00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef STEP_H
00019 #define STEP_H
00020
00021 #include <odindata/data.h>
00022
00028
00029
00034 template<class T>
00035 class Step {
00036
00037 public:
00038
00039 virtual ~Step() {}
00040
00044 virtual STD_string label() const = 0;
00045
00049 virtual STD_string description() const = 0;
00050
00054 virtual T* allocate() const = 0;
00055
00059 virtual void init() = 0;
00060
00064 T* clone() const;
00065
00069 void set_args(const STD_string& argstr);
00070
00071
00075 STD_string args_description() const;
00076
00077
00081 unsigned int numof_args() const {return args.numof_pars();}
00082
00083
00087 void append_opts(JcampDxBlock& parblock);
00088
00089
00090 protected:
00091
00092
00096 void append_arg(JcampDxClass& arg, const STD_string& arglabel);
00097
00098
00099 const char* c_label() const {if(!label_cache.size()) label_cache=label(); return label_cache.c_str();}
00100
00101 private:
00102
00103 JcampDxBlock args;
00104 mutable STD_string label_cache;
00105 };
00106
00107
00109
00114 template<class T>
00115 class StepFactory {
00116
00117 public:
00118
00122 StepFactory(JcampDxBlock* parblock=0);
00123
00124 ~StepFactory();
00125
00129 T* create(const STD_string& label) const;
00130
00134 STD_string manual() const;
00135
00139 STD_string get_cmdline_usage(const STD_string& lineprefix) const;
00140
00141 private:
00142
00143 typedef STD_map<STD_string,T*> StepMap;
00144 StepMap templates;
00145
00146 mutable STD_list<T*> garbage;
00147
00148 };
00149
00150
00153 #endif
00154