BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 // $Id: shiftModel.h,v 1.17 2005/12/23 17:01:56 amoll Exp $ 00005 // 00006 00007 #ifndef BALL_NMR_SHIFTMODEL_H 00008 #define BALL_NMR_SHIFTMODEL_H 00009 00010 #ifndef BALL_NMR_SHIFTMODULE_H 00011 # include <BALL/NMR/shiftModule.h> 00012 #endif 00013 00014 #ifndef BALL_DATATYPE_OPTIONS_H 00015 # include <BALL/DATATYPE/options.h> 00016 #endif 00017 00018 #ifndef BALL_FORMAT_PARAMETERS_H 00019 # include <BALL/FORMAT/parameters.h> 00020 #endif 00021 00022 namespace BALL 00023 { 00032 class BALL_EXPORT ShiftModel 00033 : public ShiftModule 00034 { 00035 public: 00036 00037 BALL_CREATE(ShiftModel) 00038 00039 00042 00045 typedef std::list<ShiftModule*> ModuleList; 00046 00051 typedef void * (*CreateMethod) (); 00052 00057 typedef StringHashMap<CreateMethod> CreateMethodMap; 00058 00060 00063 00066 static const char* MODULE_LIST_SECTION; 00067 00069 00072 00075 ShiftModel(); 00076 00079 ShiftModel(const String& filename); 00080 00083 ShiftModel(const ShiftModel& model); 00084 00087 virtual ~ShiftModel(); 00088 00093 void clear(); 00094 00096 00099 00102 Parameters& getParameters(); 00103 00106 ModuleList& getModuleList(); 00107 00110 void setFilename(const String& filename) 00111 throw(Exception::FileNotFound); 00112 00115 const String& getFilename() const; 00116 00119 void registerModule(const String& name, CreateMethod method) 00120 throw(Exception::NullPointer); 00121 00124 void unregisterModule(const String& name) ; 00125 00127 00130 00133 bool isValid() const; 00134 00137 bool isRegistered(const String& name) const; 00138 00140 00143 00146 const ShiftModel& operator = (const ShiftModel& model); 00147 00150 const ShiftModel& operator = (const String& filename); 00151 00153 00156 00159 Options options; 00160 00162 00165 00168 bool start(); 00169 00172 bool finish(); 00173 00176 Processor::Result operator () (Composite& composite); 00178 00179 protected: 00180 00181 /*_ Initialize the model from the parameter file. 00182 This method assumes that object has a valid parameter file assigned. 00183 It sets {\tt valid_} to <b> true </b> if it could create a shift model 00184 from the contents of the parameter file. 00185 */ 00186 bool init_() 00187 throw(Exception::FileNotFound); 00188 00189 /*_ Create a ShiftModule from a symbolic name. 00190 This method create a shift module from the symbolic 00191 name if this name is contained in the hash map \Ref{registered_modules_}. 00192 */ 00193 ShiftModule* createModule_(const String& type, const String& name) const; 00194 00195 /*_ Register the standard modules. 00196 */ 00197 void registerStandardModules_(); 00198 00199 /*_ The parameters object 00200 */ 00201 Parameters parameters_; 00202 00203 /*_ The list of shift modules of this model 00204 */ 00205 ModuleList modules_; 00206 00207 /*_ A hash map containing all registered module types and their creation methods. 00208 */ 00209 CreateMethodMap registered_modules_; 00210 00211 /*_ The validity flag. 00212 Set to <b> true </b> if the object was initialized correctly. 00213 */ 00214 bool valid_; 00215 }; 00216 00217 } // namespace BALL 00218 00219 #endif // BALL_NMR_SHIFTMODEL_H