1 #if !defined(_DATAMAPSMEMORY_H_) 2 #define _DATAMAPSMEMORY_H_ 4 #include "MemoryManager.h" 14 uint32 typesBitFieldSize;
16 uint32 contextsMaxCount;
17 uint32 contextsBitFieldSize;
20 uint32 tagsBitFieldSize;
22 uint32 cranksMaxCount;
23 uint32 cranksBitFieldSize;
28 uint32 requestsMaxCount;
29 uint32 requestsBitFieldSize;
46 char name[MAXKEYNAMELEN+1];
48 return utils::StringFormat(
"\t<type id=\"%u\" name=\"%s\" status=\"%u\" time=\"%llu\" />\n",
id, name, status, time);
50 static std::string GetOuterXMLName() {
return "types"; }
52 if (!msg)
return false;
53 msg->
setInt((int64)n,
"ID",
id);
54 msg->
setInt((int64)n,
"Status", status);
56 msg->
setTime((int64)n,
"CreatedTime", time);
59 bool writeIDToMsg(
const char* arrayname, uint32 n,
DataMessage* msg) {
60 if (!msg)
return false;
61 msg->
setString((int64)n, arrayname, name);
70 char name[MAXKEYNAMELEN+1];
72 return utils::StringFormat(
"\t<context id=\"%u\" name=\"%s\" status=\"%u\" time=\"%llu\" />\n",
id, name, status, time);
74 static std::string GetOuterXMLName() {
return "contexts"; }
76 if (!msg)
return false;
77 msg->
setInt((int64)n,
"ID",
id);
78 msg->
setInt((int64)n,
"Status", status);
80 msg->
setTime((int64)n,
"CreatedTime", time);
83 bool writeIDToMsg(
const char* arrayname, uint32 n,
DataMessage* msg) {
84 if (!msg)
return false;
85 msg->
setString((int64)n, arrayname, name);
94 char name[MAXKEYNAMELEN+1];
96 return utils::StringFormat(
"\t<tag id=\"%u\" name=\"%s\" status=\"%u\" time=\"%llu\" />\n",
id, name, status, time);
98 static std::string GetOuterXMLName() {
return "tags"; }
100 if (!msg)
return false;
101 msg->
setInt((int64)n,
"ID",
id);
102 msg->
setInt((int64)n,
"Status", status);
104 msg->
setTime((int64)n,
"CreatedTime", time);
107 bool writeIDToMsg(
const char* arrayname, uint32 n,
DataMessage* msg) {
108 if (!msg)
return false;
109 msg->
setString((int64)n, arrayname, name);
119 char name[MAXKEYNAMELEN + 1];
120 char language[MAXKEYNAMELEN + 1];
121 char function[MAXKEYNAMELEN+1];
122 char libraryFilename[MAXKEYNAMELEN+1];
123 char script[MAXSCRIPTLEN+1];
124 std::string toXML() {
126 return utils::StringFormat(
"\t<crank id=\"%u\" name=\"%s\" status=\"%u\" time=\"%llu\" compid=\"%u\" function=\"%s\" library=\"%s\">\n\t\t%s\n\t</crank>\n",
127 id, name, status, time, compID,
function, libraryFilename, script);
129 return utils::StringFormat(
"\t<crank id=\"%u\" name=\"%s\" status=\"%u\" time=\"%llu\" compid=\"%u\" function=\"%s\" library=\"%s\" />\n",
130 id, name, status, time, compID,
function, libraryFilename);
132 static std::string GetOuterXMLName() {
return "cranks"; }
134 if (!msg)
return false;
135 msg->
setInt((int64)n,
"ID",
id);
136 msg->
setInt((int64)n,
"CompID", compID);
137 msg->
setInt((int64)n,
"Status", status);
139 msg->
setString((int64)n,
"Language", language);
140 msg->
setString((int64)n,
"Function",
function);
141 msg->
setString((int64)n,
"LibraryFilename", libraryFilename);
142 msg->
setString((int64)n,
"Script", script);
143 msg->
setTime((int64)n,
"CreatedTime", time);
146 bool writeIDToMsg(
const char* arrayname, uint32 n,
DataMessage* msg) {
147 if (!msg)
return false;
148 msg->
setString((int64)n, arrayname, name);
153 #define REQ_CREATED 1 154 #define REQ_RECEIVED_LOCAL 2 155 #define REQ_RECEIVED_REMOTE 3 156 #define REQ_PROCESSING_LOCAL 4 157 #define REQ_PROCESSING_REMOTE 5 158 #define REQ_REPLY_READY 6 159 #define REQ_FAILED_TO_SEND 7 161 #define REQ_FAILED_DATA 9 162 #define REQ_FAILED_NODATA 10 163 #define REQ_FAILED_DATA_EOL 11 164 #define REQ_SUCCESS 12 165 #define REQ_SUCCESS_DATA 13 166 #define REQ_SUCCESS_NODATA 14 167 #define REQ_SUCCESS_DATA_EOL 15 172 char name[MAXKEYNAMELEN+1];
178 uint64 dataMessageID;
179 uint64 dataMessageEOL;
180 std::string toXML() {
181 return utils::StringFormat(
"\t<request id=\"%u\" name=\"%s\" status=\"%u\" time=\"%llu\" lastupdate=\"%llu\" from=\"%u\" to=\"%u\" remoteid=\"%u\" msgid=\"%llu\" msgeol=\"%llu\" />\n",
182 id, name, status, time, lastUpdate, from, to, remoteID, dataMessageID, dataMessageEOL);
184 static std::string GetOuterXMLName() {
return "requests"; }
187 #define CHECKDATAMAPSMEMORYSERIAL if (serial != master->getDataMapsShmemSerial()) {if (!open()) {mutex->leave();return 0;}} 196 bool create(uint32 typesMaxCount, uint32 contextsMaxCount, uint32 tagsMaxCount, uint32 cranksMaxCount, uint32 requestsMaxCount);
198 bool getMemoryUsage(uint64& alloc, uint64& usage);
201 std::string printFriendlyHTML();
208 bool confirmTypeLevelID(uint16
id);
209 bool cancelTypeLevelID(uint16
id);
210 bool createNewTypeLevel(uint16
id,
const char* name, uint64 time, uint16& existingID);
212 bool getTypeLevelName(uint16
id,
char* name, uint32 maxSize);
213 bool getTypeLevelID(
const char* name, uint16 &
id);
214 uint8 lookupTypeLevelID(
const char* name, uint16 &
id);
215 bool deleteTypeLevel(
const char* name);
216 bool deleteTypeLevel(uint16
id);
217 uint64 getTypeLevelCreateTime(uint16
id);
218 std::string printAllTypes();
222 bool confirmContextLevelID(uint16
id);
223 bool cancelContextLevelID(uint16
id);
224 bool createNewContextLevel(uint16
id,
const char* name, uint64 time, uint16& existingID);
226 bool getContextLevelName(uint16
id,
char* name, uint32 maxSize);
227 bool getContextLevelID(
const char* name, uint16 &
id);
228 uint8 lookupContextLevelID(
const char* name, uint16 &
id);
229 bool deleteContextLevel(
const char* name);
230 bool deleteContextLevel(uint16
id);
231 uint64 getContextLevelCreateTime(uint16
id);
232 std::string printAllContexts();
236 bool confirmTagID(uint32
id);
237 bool cancelTagID(uint32
id);
238 bool createNewTag(uint32
id,
const char* name, uint64 time, uint32& existingID);
240 bool getTagName(uint32
id,
char* name, uint32 maxSize);
241 bool getTagID(
const char* name, uint32 &
id);
242 uint8 lookupTagID(
const char* name, uint32 &
id);
243 bool deleteTag(
const char* name);
244 bool deleteTag(uint32
id);
245 uint64 getTagCreateTime(uint32
id);
249 bool confirmCrankID(uint16
id);
250 bool cancelCrankID(uint16
id);
251 bool createNewCrank(uint16
id, uint32 compID,
const char* name,
const char*
function,
const char* libraryFilename,
const char* language,
const char* script, uint64 time, uint16& existingID);
253 bool getCrankName(uint16
id,
char* name, uint32 maxSize);
254 bool getCrankFunction(uint16
id,
char*
function, uint32 maxSize);
255 bool getCrankLanguage(uint16
id,
char* language, uint32 maxSize);
256 bool getCrankLibraryFilename(uint16
id,
char* libraryFilename, uint32 maxSize);
257 bool getCrankID(
const char* name, uint16 &
id);
258 uint8 lookupCrankID(
const char* name, uint16 &
id);
259 uint32 getCrankCompID(uint16
id);
260 bool getCrankScript(uint16
id,
char* script, uint32 maxSize);
261 bool deleteCrank(uint16
id);
262 bool deleteCrank(
const char* name);
263 uint64 getCrankCreateTime(uint16
id);
266 bool createNewRequest(uint32 from, uint32 to, uint32 remoteID, uint32 &
id);
267 bool getRequestInfo(uint32
id, uint32& from, uint32& to, uint32& remoteID);
268 bool getRequestStatus(uint32
id, uint8& status, uint64& time, uint64& msgID, uint64& msgEOL);
269 bool setRequestStatus(uint32
id, uint8 status);
270 bool setRequestStatus(uint32
id, uint8 status, uint64 msgID, uint64 msgEOL);
271 bool waitForRequestReply(uint32
id, uint32 timeout, uint8& status, uint64& time, uint64& msgID, uint64& msgEOL);
272 bool deleteRequest(uint32
id);
273 uint32 getRequestCount();
276 bool resize(uint16 port, uint32 serial, uint32 typesMaxCount, uint32 contextsMaxCount, uint32 tagsMaxCount, uint32 cranksMaxCount, uint32 requestsMaxCount);
294 template <
typename T,
typename ID>
298 static T* CreateEntry(
char* data, ID
id,
const char* name);
299 static T* CreateFirstFreeEntry(
char* data, ID &
id,
const char* name);
300 static T* GetEntry(
char* data, ID
id);
301 static bool ConfirmEntry(
char* data, ID
id);
302 static bool CancelEntry(
char* data, ID
id);
303 static bool DeleteEntry(
char* data, ID
id);
304 static uint64 GetEntryTime(
char* data, ID
id);
305 static bool GetEntryName(
char* data, ID
id,
char* name, uint32 maxSize);
306 static ID GetEntryID(
char* data,
const char* name,
bool force =
false);
307 static uint8 LookupEntryID(
char* data,
const char* name, ID&
id);
308 static uint32 GetCount(
char* data);
309 static uint32 GetUsage(
char* data);
310 static std::string PrintAllEntries(
char* data);
311 static std::string PrintAllEntriesHTML(
char* data);
312 static std::string ToXML(
char* data);
313 static bool WriteAllEntriesToMsg(
char* data,
DataMessage* msg);
314 static bool WriteAllIDsToMsg(
const char* arrayname,
char* data,
DataMessage* msg);
319 #include "MemoryMaps.tpl.h" 321 #endif //_DATAMAPSMEMORY_H_ Definition: MemoryManager.h:169
Definition: DataMapsMemory.h:66
Definition: DataMapsMemory.h:9
Definition: DataMapsMemory.h:190
bool setTime(const char *key, uint64 value)
Definition: DataMessage.cpp:1782
Definition: DataMapsMemory.h:114
Definition: DataMapsMemory.h:295
Definition: DataMapsMemory.h:169
Definition: DataMapsMemory.h:90
bool setString(const char *key, const char *value)
Definition: DataMessage.cpp:1776
bool setInt(const char *key, int64 value)
Definition: DataMessage.cpp:1786
Definition: DataMapsMemory.h:42
Definition: DataMessage.h:95