MAK Data Logger API Documentation for DIS
datatypeManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *******************************************************************************/
7 #pragma once
8 
9 #pragma warning(disable : 4100)
10 
11 #include "datatypeRep.h"
12 
13 #define UNDEFINED_STR "---"
14 
15 #include <map>
16 #include <vlutil/vlString.h>
17 #include <vector>
18 #include <list>
19 #include <mtl/mtl.h>
20 #include <mtl/lispEnv.h>
21 
22 class DtOMTTree;
23 class DtOMTNode;
29 class DtDatatypeFedNode;
30 class DtStringTree;
31 class DtObjectHistory;
32 
37 {
38 public:
39 
41  SIMPLE = 1,
48  DATATYPE_MAX
49  };
50 
53 
55  virtual ~DtDatatypeManager();
56 
59  virtual void initOMTData(DtOMTTree* omtTree);
60 
61  virtual DtOMTTree* omtTree() {return myOMTTree;};
62 
63 //--- The following functions are used to setup the representation list ---
64 
66  virtual void fillDefaultDatatypeRepList();
67 
68  //Fill in more representations manually. Note that this datatype
69  //now gets owned by this function and takes care of deleting it.
70  virtual void addDatatypeRep(DtDatatypeRep*);
71 
72  //This is a special type of Mapping
73  virtual void addDefinedDatatypeRep(DtDatatypeRep*);
74 
75  //Returns the class representation of a datatype. This only works with simple
76  //Reps since more complicated datatypes build the string out of multiple representations.
77  virtual DtDatatypeRep* getSimpleDatatypeRep(const DtString& datatypeName);
78 
80  virtual std::map<DtString,DtDatatypeRep*>::iterator getNameRepMapList();
81  virtual std::map<DtString,DtDatatypeRep*>::iterator getNameRepMapListEnd();
82 
83 
84  //--- The following functions are used to setup the delimiter mappings ---
85 
87  // For example, if the delimiter is :. Then a location(x,y,z) would look
89  virtual void addDelimiterMap(const DtString& datatype, const DtString& delimiter);
90  virtual void removeDelimiterMap(const DtString& datatype);
91 
93  virtual void setDefaultDelimiter(const DtString& str);
94 
96  virtual DtString getDelimiterMap(const DtString& datatypeName, bool* isAvailable = 0);
97  virtual std::map<DtString,DtString>::iterator getDelimiterList();
98  virtual std::map<DtString,DtString>::iterator getDelimiterListEnd();
99 
100  //--- The following functions are used to setup the array bracket mappings ---
101 
105  virtual void addArrayBracketMap(const DtString& datatype, bool valueIsBracketed);
106  virtual void removeArrayBracketMap(const DtString& datatype);
107 
109  virtual void setDefaultArrayBracket(bool valueIsBracketed);
110 
112  virtual bool getArrayBracketMap(const DtString& datatypeName, bool* isAvailable = 0);
113  virtual std::map<DtString,bool>::iterator getArrayBracketList();
114  virtual std::map<DtString,bool>::iterator getArrayBracketListEnd();
115 
116  //--- The following functions are used to setup the representation to datatype mappings ---
117 
118 
120  virtual void readFile(DtString str);
121 
123  virtual void writeFile(DtString str);
124 
125  //Add a mapping between a datatype and a representation
126  virtual void addRepMapping(const DtString& datatype, const DtString& rep);
127  virtual void removeRepMapping(const DtString& datatype);
128 
129 
132  virtual bool modifyRepMapping(const DtString& datatype, const DtString& rep);
133 
135  virtual std::map<DtString,DtString>::iterator getRepMapList();
136  virtual std::map<DtString,DtString>::iterator getRepMapListEnd();
137 
138  //--- The following functions are used to convert objects to their representation ---
139 
149  virtual DtString getFedNodeStringRep(const DtDatatypeFedNode* currFedNode,
150  const void* value, int size, int& returnSize);
151  virtual DtString getStringRep(const DtString& datatypeName,
152  const void* value, int size, int& returnSize);
153 
165  virtual DtStringTree* createStringTreeRep(const DtDatatypeFedNode* currFedNode,
166  const void* value, int size, int& returnSize, unsigned int currentOffset = 0,
167  DtObjectHistory* = 0);
168  virtual DtStringTree* createStringTreeRep(const DtString& datatypeName,
169  const void* value, int size, int& returnSize, const DtOMTNode* omtNode = 0,
170  unsigned int currentOffset = 0, DtStringTree* strParentTree = 0,
171  DtObjectHistory* = 0);
172 
176  virtual DtString convertStringTreeToString (DtStringTree*, const DtString& delimiter);
177 
178 
179  //--- The following functions are used to gather extra information about a datatype ---
180 
181  //Find what type of datatype an item is (Simple, Enum, Complex, etc)
182  virtual DtDatatypeEnum getDatatypeEnum(const DtString& datatypeName);
183 
184 
185 protected:
186 
189 
191  DtDatatypeManager& operator=(const DtDatatypeManager& rhs);
192 
193  virtual void checkOrphanMappings();
194  virtual void checkObjOrphans(DtObjectClassFedNode* objClass);
195  virtual void checkIntOrphans(DtInteractionClassFedNode* intClass);
196 
198  virtual void getDefaultRep(const void* value, int size, int& returnSize, DtString& returnString);
199  virtual void getDatatypeRep(const DtString& datatypeName, const void* value, int size, int& returnSize, DtString& returnString);
200  virtual void getEnumRep(const DtString& datatypeName, const void* value, int size, int& returnSize, DtString& returnString);
201  virtual void getVariantRep(const DtString& datatypeName, const void* value, int size, int& returnSize, DtString& returnString);
202  virtual void getArrayRepBySize(const DtString& datatypeName, const void* value, int size, int& returnSize, DtString& returnString);
203  virtual void getArrayRepByCount(DtArrayDatatypeNode* arrayNode, const void* value, int size, int& returnSize, DtString& returnString);
204  virtual void getArrayRep(const DtString& datatypeName, const void* value, int size, int& returnSize, DtString& returnString);
205 
207  virtual void createComplexTreeRep(
208  const DtString& datatypeName, const void* value, int size,
209  int& returnSize, DtStringTree* strTree, DtStringTree* strParentTree = 0,
210  unsigned int currentOffset = 0,
211  DtObjectHistory* = 0);
212  virtual void createArrayTreeRep(
213  const DtString& datatypeName, const void* value, int size,
214  int& returnSize, DtStringTree* strTree, DtStringTree* strParentTree = 0,
215  unsigned int currentOffset = 0,
216  DtObjectHistory* = 0);
217  virtual void createDefinedTreeRep(
218  const DtString& datatypeName, const void* value, int size,
219  int& returnSize, DtStringTree* strTree, DtStringTree* strParentTree = 0,
220  unsigned int currentOffset = 0,
221  DtObjectHistory* = 0);
222  virtual void createVariantTreeRep(
223  const DtString& datatypeName, const void* value, int size,
224  int& returnSize, DtStringTree* strTree, DtStringTree* strParentTree = 0,
225  unsigned int currentOffset = 0,
226  DtObjectHistory* = 0);
227  virtual void createFixedTreeRep(
228  const DtString& datatypeName, const void* value, int size,
229  int& returnSize, DtStringTree* strTree, DtStringTree* strParentTree = 0,
230  unsigned int currentOffset = 0,
231  DtObjectHistory* = 0);
232 
233 
235  virtual void processMappings(DtlObjPtr& ptr);
236 
240  virtual int getComplexDatatypeCount(DtComplexComponentNode* compNode, DtComplexDatatypeNode* parentNode,
241  const void* value, int valueSize, int alreadyRead,
242  const DtStringTree* strTree = 0, const DtStringTree* parentTree = 0);
243 
244  virtual int getArrayDatatypeCount(DtArrayDatatypeNode* arrayNode,
245  const void* value, int valueSize,
246  const DtStringTree* strTree = 0, const DtStringTree* parentTree = 0);
247 
248 protected:
249 
251  std::map<DtString,DtDatatypeEnum> myDatatypeTypeMap;
252 
253  typedef std::map<DtString,DtString> DatatypeNameRepNameMap;
255 
256  typedef std::map<DtString,DtDatatypeRep*> RepNamePtrMap;
258 
260  std::map<DtString,DtString> myDelimiterMap;
261 
263  std::map<DtString,bool> myArrayBracketMap;
264 
265 };
266 
267 
268 

Document ID: Generated on Thu Apr 11 12:13:00 EDT 2013 from SVN revision 126011
Copyright © 2005-2012 VT MÄK. All Rights Reserved (www.mak.com)