CMSDK  2.0.1
MemoryMaps.h
1 #if !defined(_MEMORYMAPS_H_)
2 #define _MEMORYMAPS_H_
3 
4 #include "MemoryManager.h"
5 
6 namespace cmlabs {
7 
8 #define ID_SYSPAGE 0
9 #define ID_PAGEPOOL 1
10 #define ID_EOLPAGE 2
11 #define ID_QUEUEPAGE 3
12 #define ID_COMPMAPPAGE 4
13 #define ID_TYPEMAPPAGE 5
14 #define ID_TOPICMAPPAGE 6
15 //#define ID_NODEMAPPAGE 7
16 #define ID_QUEUEMAPPAGE 7
17 #define ID_PROCESSMAPPAGE 8
18 #define ID_REQUESTMAPPAGE 9
19 #define ID_CRANKMAPPAGE 10
20 #define ID_CONTEXTMAPPAGE 11
21 #define RESERVEDPAGECOUNT 12
22 
23 #define SIGNALQ_ID 0
24 #define MSGQ_ID 1
25 #define REQQ_ID 2
26 #define CMDQ_ID 3
27 
28 struct TypeMapHeader {
29  uint32 size; // total size of map structure in bytes
30  uint32 count; // number of entries
31  uint32 bitFieldSize; // number of bytes in the bitfield
32  // Bitfield
33  // Entries
34 };
35 
36 struct TypeMapEntry {
37  uint16 id; // id, corresponds to the index in map
38  uint64 time; // timestamp when entered
39  char name[MAXKEYNAMELEN+1]; // name in text
40  uint32 key;
41 };
42 
44  uint32 size; // total size of map structure in bytes
45  uint32 count; // number of entries
46  uint32 bitFieldSize; // number of bytes in the bitfield
47  // Bitfield
48  // Entries
49 };
50 
51 struct ContextMapEntry {
52  uint16 id; // id, corresponds to the index in map
53  uint64 time; // timestamp when entered
54  char name[MAXKEYNAMELEN+1]; // name in text
55  uint32 key;
56 };
57 
59  uint32 size; // total size of map structure in bytes
60  uint32 count; // number of entries
61  uint32 bitFieldSize; // number of bytes in the bitfield
62  // Bitfield
63  // Entries
64 };
65 
66 struct TopicMapEntry {
67  uint32 id; // id, corresponds to the index in map
68  uint64 time; // timestamp when entered
69  char name[MAXKEYNAMELEN+1]; // name in text
70  uint32 key;
71 };
72 
73 //struct NodeMapHeader {
74 // uint32 size; // total size of map structure in bytes
75 // uint32 count; // number of entries
76 // uint32 bitFieldSize; // number of bytes in the bitfield
77 // // Bitfield
78 // // Entries
79 //};
80 //
81 //struct NodeMapEntry {
82 // uint16 id; // id, corresponds to the index in map
83 // uint64 time; // timestamp when entered
84 // char name[MAXKEYNAMELEN+1]; // name in text
85 // uint64 key; // 32bit IP4, 16bit port, 16bit unused
86 //};
87 
89  uint32 size; // total size of map structure in bytes
90  uint32 count; // number of entries
91  uint32 bitFieldSize; // number of bytes in the bitfield
92  // Bitfield
93  // Entries
94 };
95 
96 struct CrankMapEntry {
97  uint16 id; // id, corresponds to the index in map
98  uint64 time; // timestamp when entered
99  char name[MAXKEYNAMELEN+1]; // name in text
100  char function[MAXKEYNAMELEN+1]; // name in text
101  char libraryFilename[MAXKEYNAMELEN+1]; // name in text
102  char script[MAXSCRIPTLEN+1]; // script in text
103  uint64 key; // 32bit IP4, 16bit port, 16bit unused
104 };
105 
107  uint32 size; // total size of map structure in bytes
108  uint32 count; // number of entries
109  uint32 bitFieldSize; // number of bytes in the bitfield
110  // Bitfield
111  // Entries
112 };
113 
115  uint16 id; // id, corresponds to the index in map
116  uint64 time; // timestamp when entered
117  char name[MAXKEYNAMELEN+1]; // name in text
118  uint32 key; // 32bit IP4, 16bit port, 16bit unused
119 };
120 
121 #define PROC_ERROR 0
122 #define PROC_INIT 1
123 #define PROC_IDLE 2
124 #define PROC_READY 3
125 #define PROC_ACTIVE 4
126 
128  uint32 size; // total size of map structure in bytes
129  uint32 count; // number of entries
130  uint32 bitFieldSize; // number of bytes in the bitfield
131  // Bitfield
132  // Entries
133 };
134 
136  uint32 id; // id, corresponds to the index in map
137  uint64 time; // timestamp when entered
138  uint64 lastseen; // timestamp when entered
139  uint8 status; // status of the process
140  char name[MAXKEYNAMELEN+1]; // name in text
141  uint32 key;
142  char commandline[MAXCOMMANDLINELEN+1]; // commandline in text
143  uint32 signalQID; // id of Signal queue
144  uint32 messageQID; // id of Message queue
145  uint32 timeQID; // id of Time queue
146  uint32 requestQID; // id of Request queue
147  uint32 commandQID; // id of Command queue
148 };
149 
151  uint32 size; // total size of map structure in bytes
152  uint32 count; // number of entries
153  uint32 bitFieldSize; // number of bytes in the bitfield
154  // Bitfield
155  // Entries
156 };
157 
158 struct RequestMapEntry {
159  uint32 id; // id, corresponds to the index in map
160  uint64 time; // timestamp when entered
161  char name[MAXKEYNAMELEN+1]; // name in text
162  uint32 key;
163  uint8 status; // status of the process
164  uint32 from; // id of component making the request
165  uint32 to; // id of component processing the request
166  uint64 dataMessageID; // id of Data Message
167  uint64 dataMessageEOL; // eol of Data Message
168 };
169 
170 struct GenericMapHeader {
171  uint32 size; // total size of map structure in bytes
172  uint32 count; // number of entries
173  uint32 bitFieldSize; // number of bytes in the bitfield
174  // Bitfield
175  // Entries
176 };
177 
178 
179 inline uint16 TypePageID(TypeMapEntry* e) {return ID_TYPEMAPPAGE;}
180 inline uint16 TypePageID(TopicMapEntry* e) {return ID_TOPICMAPPAGE;}
181 //inline uint16 TypePageID(NodeMapEntry* e) {return ID_NODEMAPPAGE;}
182 inline uint16 TypePageID(QueueMapEntry* e) {return ID_QUEUEMAPPAGE;}
183 inline uint16 TypePageID(ProcessMapEntry* e) {return ID_PROCESSMAPPAGE;}
184 inline uint16 TypePageID(RequestMapEntry* e) {return ID_REQUESTMAPPAGE;}
185 inline uint16 TypePageID(CrankMapEntry* e) {return ID_CRANKMAPPAGE;}
186 inline uint16 TypePageID(ContextMapEntry* e) {return ID_CONTEXTMAPPAGE;}
187 
188 #define REQ_CREATED 1
189 #define REQ_RECEIVED_LOCAL 2
190 #define REQ_RECEIVED_REMOTE 3
191 #define REQ_PROCESSING_LOCAL 4
192 #define REQ_PROCESSING_REMOTE 5
193 #define REQ_REPLY_READY 6
194 #define REQ_FAILED 7
195 #define REQ_FAILED_DATA 8
196 #define REQ_FAILED_NODATA 9
197 #define REQ_FAILED_DATA_EOL 10
198 #define REQ_SUCCESS 11
199 #define REQ_SUCCESS_DATA 12
200 #define REQ_SUCCESS_NODATA 13
201 #define REQ_SUCCESS_DATA_EOL 14
202 
203 
204 
205 class MemoryMaps {
206 public:
207  // TypeLevelMap
208  static bool CreateNewTypeLevel(uint16 id, const char* name, uint64 time = 0);
209  static bool GetTypeLevelName(uint16 id, char* name, uint32 maxSize);
210  static bool GetTypeLevelID(const char* name, uint16 &id);
211  static bool DeleteTypeLevel(const char* name);
212  static bool DeleteTypeLevel(uint16 id);
213  static uint64 GetTypeLevelCreateTime(uint16 id);
214 
215  // ContextLevelMap
216  static bool CreateNewContextLevel(uint16 id, const char* name, uint64 time = 0);
217  static bool GetContextLevelName(uint16 id, char* name, uint32 maxSize);
218  static bool GetContextLevelID(const char* name, uint16 &id);
219  static bool DeleteContextLevel(const char* name);
220  static bool DeleteContextLevel(uint16 id);
221  static uint64 GetContextLevelCreateTime(uint16 id);
222 
223  // TopicMap
224  static bool CreateNewTopic(uint8 id, const char* name);
225  static bool GetTopicName(uint32 id, char* name, uint32 maxSize);
226  static bool GetTopicID(const char* name, uint32 &id);
227  static bool DeleteTopic(const char* name);
228  static bool DeleteTopic(uint32 id);
229  static uint64 GetTopicCreateTime(uint32 id);
230 
231  // NodeMap
232  //static bool CreateNewNode(uint8 id, const char* name, uint64 address);
233  //static uint64 GetNodeAddress(uint16 id);
234  //static bool GetNodeID(uint64 address, uint16 &id);
235  //static bool GetNodeName(uint16 id, char* name, uint32 maxSize);
236  //static bool GetNodeID(const char* name, uint16 &id);
237  //static bool DeleteNode(uint64 address);
238  //static bool DeleteNode(uint16 id);
239  //static bool DeleteNode(const char* name);
240  //static uint64 GetNodeCreateTime(uint16 id);
241 
242  // CrankMap
243  static bool CreateNewCrank(uint16 id, const char* name, const char* function, const char* libraryFilename, uint64 time = 0);
244  static bool GetCrankName(uint16 id, char* name, uint32 maxSize);
245  static bool GetCrankFunction(uint16 id, char* function, uint32 maxSize);
246  static bool GetCrankLibraryFilename(uint16 id, char* libraryFilename, uint32 maxSize);
247  static bool GetCrankID(const char* name, uint16 &id);
248  static bool GetCrankScript(uint16 id, char* script, uint32 maxSize);
249  static bool SetCrankScript(uint16 id, const char* script);
250  static bool DeleteCrank(uint16 id);
251  static bool DeleteCrank(const char* name);
252  static uint64 GetCrankCreateTime(uint16 id);
253 
255  //static bool CreateNewQueue(uint32 pageID, const char* name, uint32 &id);
256  //static bool GetQueueName(uint32 id, char* name, uint32 maxSize);
257  //static uint32 GetQueuePageID(uint32 id);
258  //static bool GetQueueID(const char* name, uint32 &id);
259  //static bool GetQueueID(uint32 pageID, uint32 &id);
260  //static bool DeleteQueue(uint32 id);
261  //static bool DeleteQueue(const char* name);
262  //static uint64 GetQueueCreateTime(uint32 id);
263 
265  //static bool CreateNewProcess(const char* name, uint16 &id);
266  //static bool GetProcessName(uint16 id, char* name, uint32 maxSize);
267  //static bool GetProcessID(const char* name, uint16 &id);
268  //static bool GetProcessQueueID(uint16 id, uint8 queueType, uint32& qid);
269  //static uint8 GetProcessStatus(uint16 id, uint64& lastseen);
270  //static bool GetProcessCommandLine(uint16 id, char* cmdline, uint32 maxSize);
271  //static bool SetProcessQueueID(uint16 id, uint8 queueType, uint32 qid);
272  //static bool SetProcessStatus(uint16 id, uint8 status);
273  //static bool SetProcessCommandLine(uint16 id, const char* cmdline);
274  //static uint16 GetProcessIDFromOSID(uint32 osid);
275  //static uint32 GetProcessOSID(uint16 id);
276  //static bool SetProcessOSID(uint16 id, uint32 osid);
277  //static bool DeleteProcess(const char* name);
278  //static bool DeleteProcess(uint16 id);
279  //static uint64 GetProcessCreateTime(uint16 id);
280 
282  //static RequestMapEntry* CreateAndLockNewRequest(uint32 from, uint32 to, uint32 &id);
283  //static RequestMapEntry* GetAndLockRequestEntry(uint32 id);
284  //static bool UnlockRequestMap();
285  //static bool DeleteRequest(uint32 id);
286  //static bool GetRequestCount(uint32& count);
287 
288 protected:
289 // static ProcessMapEntry* GetAndLockProcessEntry(uint16 id);
290 // static bool UnlockProcessMap();
291 };
292 
293 
294 
295 
296 
297 
298 
299 
300 
301 
302 
303 
304 
305 
306 
307 
308 
309 
310 
311 template <typename T, typename ID, typename KEY>
312 class GenericMemoryMap {
313 public:
314  // Generic MemoryMap
315  static uint32 GetCount(char* data);
316  static T* CreateEntry(char* data, ID id, const char* name);
317  static T* GetEntry(char* data, ID id);
318  static bool DeleteEntry(char* data, ID id);
319  static uint64 GetEntryTime(char* data, ID id);
320  static const char* GetEntryName(char* data, ID id, uint32& size);
321  static ID GetEntryID(char* data, const char* name);
322 };
323 
324 
325 
326 } // namespace cmlabs
327 
328 #include "PsyTime.h"
329 #include "MemoryMaps.tpl.h"
330 
331 #endif // _MEMORYMAPS_H_
332 
333 
Definition: DataMapsMemory.h:66
Definition: MemoryMaps.h:205
Definition: MemoryMaps.h:106
Definition: Bitmap.h:7
Definition: MemoryMaps.h:28
Definition: MemoryMaps.h:88
Definition: DataMapsMemory.h:114
Definition: MemoryMaps.h:127
Definition: DataMapsMemory.h:295
Definition: DataMapsMemory.h:169
Definition: MemoryMaps.h:150
Definition: MemoryMaps.h:114
Definition: MemoryMaps.h:58
Definition: MemoryMaps.h:66
Definition: MemoryMaps.h:135
Definition: MemoryMaps.h:43
Definition: DataMapsMemory.h:42