BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
shiftModel.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 // $Id: shiftModel.h,v 1.17 2005/12/23 17:01:56 amoll Exp $
5 //
6 
7 #ifndef BALL_NMR_SHIFTMODEL_H
8 #define BALL_NMR_SHIFTMODEL_H
9 
10 #ifndef BALL_NMR_SHIFTMODULE_H
11 # include <BALL/NMR/shiftModule.h>
12 #endif
13 
14 #ifndef BALL_DATATYPE_OPTIONS_H
15 # include <BALL/DATATYPE/options.h>
16 #endif
17 
18 #ifndef BALL_FORMAT_PARAMETERS_H
19 # include <BALL/FORMAT/parameters.h>
20 #endif
21 
22 namespace BALL
23 {
33  : public ShiftModule
34  {
35  public:
36 
38 
39 
42 
45  typedef std::list<ShiftModule*> ModuleList;
46 
51  typedef void * (*CreateMethod) ();
52 
57  typedef StringHashMap<CreateMethod> CreateMethodMap;
58 
60 
63 
66  static const char* MODULE_LIST_SECTION;
67 
69 
72 
75  ShiftModel();
76 
79  ShiftModel(const String& filename);
80 
83  ShiftModel(const ShiftModel& model);
84 
87  virtual ~ShiftModel();
88 
93  void clear();
94 
96 
99 
102  Parameters& getParameters();
103 
106  ModuleList& getModuleList();
107 
110  void setFilename(const String& filename)
111  throw(Exception::FileNotFound);
112 
115  const String& getFilename() const;
116 
119  void registerModule(const String& name, CreateMethod method)
120  throw(Exception::NullPointer);
121 
124  void unregisterModule(const String& name) ;
125 
127 
130 
133  bool isValid() const;
134 
137  bool isRegistered(const String& name) const;
138 
140 
143 
146  const ShiftModel& operator = (const ShiftModel& model);
147 
150  const ShiftModel& operator = (const String& filename);
151 
153 
156 
159  Options options;
160 
162 
165 
168  bool start();
169 
172  bool finish();
173 
176  Processor::Result operator () (Composite& composite);
178 
179  protected:
180 
181  /*_ Initialize the model from the parameter file.
182  This method assumes that object has a valid parameter file assigned.
183  It sets {\tt valid_} to <b> true </b> if it could create a shift model
184  from the contents of the parameter file.
185  */
186  bool init_()
187  throw(Exception::FileNotFound);
188 
189  /*_ Create a ShiftModule from a symbolic name.
190  This method create a shift module from the symbolic
191  name if this name is contained in the hash map \Ref{registered_modules_}.
192  */
193  ShiftModule* createModule_(const String& type, const String& name) const;
194 
195  /*_ Register the standard modules.
196  */
197  void registerStandardModules_();
198 
199  /*_ The parameters object
200  */
201  Parameters parameters_;
202 
203  /*_ The list of shift modules of this model
204  */
205  ModuleList modules_;
206 
207  /*_ A hash map containing all registered module types and their creation methods.
208  */
209  CreateMethodMap registered_modules_;
210 
211  /*_ The validity flag.
212  Set to <b> true </b> if the object was initialized correctly.
213  */
214  bool valid_;
215  };
216 
217 } // namespace BALL
218 
219 #endif // BALL_NMR_SHIFTMODEL_H