C++ main module for mmsd Package  1.0
MM_ClassFactory.h
Go to the documentation of this file.
1 #ifndef MM_ClassFactory_H
2 #define MM_ClassFactory_H
3 
4 #include "UI_ClassFactory.h"
5 
6 #include "MM_Attribute.h"
7 #include "MM_Class.h"
8 #include "MM_Structure.h"
9 
10 #include "CORE_File.h"
11 
18 
19 class MM_ClassFactory : public UI_ClassFactory{ // class
20 
21  // ASSOCIATION
22  SP_OBJECT(MM_ClassFactory);
23 
24  // ATTRIBUTES
25 
26 protected:
27  static const tString ID;
28 
29 private:
30 
31 
32 
33  // file type
34  static const tFlag R;
35 
36  tFlag mFileType;
37 
38 
39  // METHODS
40 
41 
42 protected:
43  // CONSTRUCTORS
46  MM_ClassFactory();
47 
48 
49 
50 
51  // DESTRUCTORS
55  virtual ~MM_ClassFactory(void);
56 
57 
58 
59 
60 
61 public:
62  // NEW
63 
66  inline static SP::MM_ClassFactory New() {
67  SP::MM_ClassFactory p(new MM_ClassFactory(),
69  p->setThis(p);
70  return p;
71  }
72 
73  // SET
74 
75  // GET
76 
77  // OTHERS
78 
79 public:
80 
83  virtual tBoolean saveIntoFile(const CORE_Object& obj,
84  SP::CORE_ClassFactory cfactory,
85  const tString& fileName) {
86  return saveIntoFile(obj,UI_Class::INTERFACE,cfactory,"x",fileName);
87  }
88 
89 
90 
94  const tFlag& interfaceType,
95  SP::CORE_ClassFactory cfactory,
96  const tString& varName,
97  const tString& fileName);
98 
99 
102  virtual tBoolean saveIntoFile(const CORE_Object& obj,
103  const tString& fileName) {
104  SP::CORE_ClassFactory fact=CORE_ClassFactory::New();
105  return saveIntoFile(obj,UI_Class::INTERFACE,fact,"x",fileName);
106  }
107 
110  inline tBoolean saveIntoFile(SPC::CORE_Object obj,
111  SP::CORE_ClassFactory cfactory,
112  const tString& varName,
113  const tString& fileName) {
114  if (obj.get()!=null) return saveIntoFile(*obj.get(),UI_Class::INTERFACE,
115  cfactory,varName,fileName);
116  return true;
117  };
120  inline tBoolean saveIntoFile(SPC::CORE_Object obj,
121  const tFlag& interfaceType,
122  const tString& varName,
123  const tString& fileName) {
124  SP::CORE_ClassFactory fact=CORE_ClassFactory::New();
125  if (obj.get()!=null) return saveIntoFile(*obj.get(),interfaceType,
126  fact,varName,fileName);
127  return true;
128  };
129 
130 
133  virtual SP::CORE_Object loadFromFile(const tFlag& interfaceType,
134  SP::CORE_ClassFactory cfactory,
135  const tString& fileName);
136 
139  virtual tBoolean loadFromFile(SP::CORE_Object object,
140  const tFlag& interfaceType,
141  SP::CORE_ClassFactory cfactory,
142  const tString& fileName);
143 private:
146  tBoolean saveIntoFile(const tString& varName,
147  const MM_Attribute& ui,
148  CORE_File& f) const;
151  tBoolean saveIntoFile(const tString& varName,
152  const MM_Class& ui,
153  CORE_File& f) const;
154 
157  SP::MM_Class readClass(CORE_File& f) const;
160  static void read(const tString& v,const tString& sep,vector<tString>& vect);
163  static void read(const tString& v,const tString& sep,vector<double>& vect);
164 
165 
168  inline void setFileType(const tString& ext) {
169  if (ext.compare("R")==0) mFileType=R;
170  else mFileType=R;
171 
172  }
175  inline tString getFileType() const {
176  return "R";
177  }
178 
181  inline tString getClassHeader() const {
182 
183  return "list(";
184 
185  }
188  inline tString getClassFooter() const {
189  return ")\n";
190  }
193  inline tString getClassFieldSeparator() const {
194  return ",\n";
195  }
198  inline tString getListHeader() const {
199  return "list(";
200  }
203  inline tString getListFooter() const {
204  return ")\n";
205  }
208  inline tString getListSeparator() const {
209  return ",\n";
210  }
211 
214  inline tString getVectorHeader() const {
215 
216  return "c(";
217 
218  }
221  inline tString getVectorFooter() const {
222  return ")";
223  }
226  inline tString getVectorSeparator() const {
227  return ",";
228  }
231  inline tString getMatrixHeader() const {
232  return "matrix(";
233  }
236  inline tString getMatrixFooter() const {
237  return ")";
238  }
241  inline tString getMatrixSeparator() const {
242  return ",";
243  }
244 
245 
246 };
247 
248 #endif
This class is a primary field.
Definition: MM_Attribute.h:15
virtual tBoolean saveIntoFile(const CORE_Object &obj, SP::CORE_ClassFactory cfactory, const tString &fileName)
save into file
Definition: MM_ClassFactory.h:83
DEFINE_SPTR(MM_ClassFactory)
virtual tBoolean saveIntoFile(const CORE_Object &obj, const tString &fileName)
save the obj into an xml file
Definition: MM_ClassFactory.h:102
this class describes the output by default write on standart output
Definition: CORE_File.h:20
this class describes a class factory to generate classes for User Interface Software ...
Definition: MM_ClassFactory.h:19
#define tBoolean
Definition: types.h:48
this class describes a class factory to generate classes for User Interface Software ...
Definition: UI_ClassFactory.h:21
#define null
Definition: types.h:13
This class is a description of class.
Definition: MM_Class.h:17
virtual SP::CORE_Object loadFromFile(const tFlag &interfaceType, SP::CORE_ClassFactory cfactory, const tString &fileName)
load from R file
Definition: MM_ClassFactory.cpp:157
abstract base class for most classes.
Definition: CORE_Object.h:30
#define tString
Definition: types.h:49
virtual ~MM_ClassFactory(void)
destroy a MM_ClassFactory
Definition: MM_ClassFactory.cpp:20
static SP::CORE_ClassFactory New()
Definition: CORE_ClassFactory.h:62
static SP::MM_ClassFactory New()
create an instance of class
Definition: MM_ClassFactory.h:66
tBoolean saveIntoFile(SPC::CORE_Object obj, SP::CORE_ClassFactory cfactory, const tString &varName, const tString &fileName)
save the obj into an xml file
Definition: MM_ClassFactory.h:110
static const tString ID
Definition: MM_ClassFactory.h:27
tBoolean saveIntoFile(SPC::CORE_Object obj, const tFlag &interfaceType, const tString &varName, const tString &fileName)
save the obj into an xml file
Definition: MM_ClassFactory.h:120
MM_ClassFactory()
build a MM_ClassFactory
Definition: MM_ClassFactory.cpp:13
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14