C++ main module for emicrom Package  1.0
EMMH_HysteresisFile.h
Go to the documentation of this file.
1 #ifndef EMMH_HysteresisFile_H
2 #define EMMH_HysteresisFile_H
3 
4 #include "EMM_IO.h"
5 
6 
7 #include "EMM_RealArray.h"
8 
36 class EMMH_HysteresisFile : public EMM_IO {
38 
39  //attributes
40 public :
41 
42 
43 private :
44 
45  static const tUIndex MAX_LINES;
46 
47 protected:
48  // CONSTRUCTORS
52 
53  }
54 
55  // DESTRUCTORS
58  virtual ~EMMH_HysteresisFile(void) {
59  }
60 
61 public:
65  inline static SP::EMMH_HysteresisFile New() {
66  SP::EMMH_HysteresisFile p(new EMMH_HysteresisFile(),EMMH_HysteresisFile::Delete());
67  p->setThis(p);
68  return p;
69  };
70 
71 
72 
73 
74  //APPEND methods
75  //==============
76 
93  tBoolean append(const EMM_RealArray& M,const tUSInt& D,
94  const EMM_RealArray& data,const tUSInt& dataDim,
95  const tUSInt& n) const;
96 
97 private:
98 
114  template<class T>
115  tBoolean append(const tString& fileName,const EMM_Array<T>& values,const tUSInt& d,const tUSInt& n) const;
116 
117 
118  //SAVE Methods
119  //============
120 public:
131  tBoolean save(const EMM_RealArray& Hext,const vector<tString>& dataNames,
132  const tUInteger& nMaxHCycles,const tUSInt& flowSize) const;
133 
149  tBoolean save(const EMM_RealArray& H,
150  const EMM_RealArray& M,
151  const tUSInt& D,
152  const tUInteger& i,
153  const tUInteger& c,
154  const tUSInt& s) const;
155 
156 
157 private:
167  tBoolean save(const tString& fileName,const tString& comment,const tUSInt& dim,
168  const EMM_RealArray& H,const tUInteger& nMaxHCycles,const tUSInt& flowSize) const;
169 
187  template<class T>
188  tBoolean save(const tString& fileName,
189  const tString& comment,
190  const EMM_RealArray& H,
191  const EMM_Array<T>& M,
192  const tUSInt& D,
193  const tUInteger& i,
194  const tUInteger& c,
195  const tUSInt& s) const;
196 
197 public:
198  //LOADER METHODS
199  //==============
200 
214  EMM_RealArray& M,
215  tUSInt& D,
216  tUInteger& i,
217  tUInteger& c,
218  tUSInt& s) const;
219 
229  tUSInt& D,
230  tUInteger& i,
231  tUInteger& c,
232  tUSInt& s) const;
233 
234 private:
249  template<class T>
250  tBoolean load(const tString& fileName,
251  EMM_RealArray* H,
252  EMM_Array<T>* M,
253  tUIndex& n,
254  tUSInt& D,
255  tUInteger& i,
256  tUInteger& c,
257  tUSInt& s) const;
258 
259 
260 
261 public:
262 
266  inline tBoolean isEmpty() const {
267  //ge the prefix without extension
268  tString prefix=getPrefix();
269 
270  //get the extension .hys
271  tString ext="";
272 
273  tUIndex index=prefix.rfind(".");
274  if (index!=tString::npos) {
275  ext=prefix.substr(index);
276  prefix=prefix.substr(0,index);
277  }
278  return (!CORE_IO::exists(getPath()+prefix+".hys"));
279  }
280 
281 
285  virtual tString toString() const {
286  return getPath()+getPrefix();
287  }
288 };
289 
290 #include "EMMH_HysteresisFile.hpp"
291 #endif
DEFINE_SPTR(EMMH_HysteresisFile)
EMMH_HysteresisFile(void)
create
Definition: EMMH_HysteresisFile.h:51
This class is a I/O class for E-MicroM core package.
Definition: EMM_IO.h:16
virtual ~EMMH_HysteresisFile(void)
destroy
Definition: EMMH_HysteresisFile.h:58
virtual tString toString() const
turn the hsteresis file into string
Definition: EMMH_HysteresisFile.h:285
#define tUInteger
Definition: types.h:91
tBoolean isEmpty() const
return true if the file is empty
Definition: EMMH_HysteresisFile.h:266
tBoolean load(EMM_RealArray &H, EMM_RealArray &M, tUSInt &D, tUInteger &i, tUInteger &c, tUSInt &s) const
load the file and fill the H values and the M values
Definition: EMMH_HysteresisFile.cpp:153
Definition: EMMH_HysteresisFile.h:36
#define tUSInt
Definition: types.h:28
static tBoolean exists(const tString &filename)
test if the file or path exists
Definition: CORE_IO.cpp:409
#define tBoolean
Definition: types.h:139
tBoolean append(const EMM_RealArray &M, const tUSInt &D, const EMM_RealArray &data, const tUSInt &dataDim, const tUSInt &n) const
append the data to the hysteresis file & relaxation return code
Definition: EMMH_HysteresisFile.cpp:120
static SP::EMMH_HysteresisFile New()
create a run class
Definition: EMMH_HysteresisFile.h:65
const tString & getPath() const
get the path
Definition: EMM_IO.h:88
static const tUIndex MAX_LINES
Definition: EMMH_HysteresisFile.h:45
#define tUIndex
Definition: types.h:126
This class describes a real array.
Definition: EMM_RealArray.h:16
#define tString
Definition: types.h:135
const tString & getPrefix() const
get the prefix
Definition: EMM_IO.h:95
tBoolean save(const EMM_RealArray &Hext, const vector< tString > &dataNames, const tUInteger &nMaxHCycles, const tUSInt &flowSize) const
save all the external field for all hysteresis files:
Definition: EMMH_HysteresisFile.cpp:6
SP_OBJECT(EMMH_HysteresisFile)
This class describes a general array.
Definition: EMM_Array.h:18
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141