1 #if !defined(_SUBSCRIPTIONS_H_) 2 #define _SUBSCRIPTIONS_H_ 8 #include "xml_parser.h" 9 #include "DataMessage.h" 12 #define COMP_WHITEBOARD 1 13 #define COMP_CATALOG 2 16 #define COMP_SERVICE 5 18 #define COMP_INTERNAL 6 19 #define COMP_EXTERNAL 7 22 #define COMP_MIGRATE_NO 0 23 #define COMP_MIGRATE_ALLOW 1 28 #define TRIGGERFILTER_HASKEY 1 29 #define TRIGGERFILTER_EQUALS 2 30 #define TRIGGERFILTER_NOTEQUALS 3 31 #define TRIGGERFILTER_EQUALSNUMERIC 4 32 #define TRIGGERFILTER_NOTEQUALSNUMERIC 5 33 #define TRIGGERFILTER_GREATERTHAN 6 34 #define TRIGGERFILTER_LESSTHAN 7 35 #define TRIGGERFILTER_MAXAGE 8 38 #define INDEX_STRING 2 39 #define INDEX_INTEGER 3 45 char key[MAXKEYNAMELEN+1];
46 char value[MAXVALUENAMELEN+1];
48 return utils::StringFormat(
"\t<filter filter=\"%u\" time=\"%llu\" key=\"%s\" value=\"%s\" />\n",
49 filter, time, key, value);
51 bool fromXML(
const char* xml) {
52 if (!xml)
return false;
54 XMLNode node = XMLNode::parseString(xml,
"filter", &xmlResults);
55 if (xmlResults.error != eXMLErrorNone)
57 if (node.isEmpty())
return false;
62 if (str = node.getAttribute(
"filter")) filter = (uint8)utils::Ascii2Uint32(str);
else return false;
63 if (str = node.getAttribute(
"time")) time = utils::Ascii2Uint64(str);
else return false;
64 if (str = node.getAttribute(
"key")) utils::strcpyavail(key, str, MAXKEYNAMELEN,
true);
else return false;
65 if (str = node.getAttribute(
"value")) utils::strcpyavail(value, str, MAXVALUENAMELEN,
true);
else return false;
79 char sourceName[MAXKEYNAMELEN+1];
80 char hostName[MAXKEYNAMELEN + 1];
81 char name[MAXKEYNAMELEN+1];
82 char key[MAXKEYNAMELEN+1];
83 char value[MAXVALUENAMELEN+1];
84 char type[MAXKEYNAMELEN+1];
85 char subdir[MAXKEYNAMELEN+1];
86 char ext[MAXKEYNAMELEN+1];
87 char operation[MAXKEYNAMELEN+1];
89 return utils::StringFormat(
"\t<query source=\"%u\" origin=\"%u\" maxage=\"%llu\" maxcount=\"%u\" binary=\"%s\" name=\"%s\" key=\"%s\" value=\"%s\" type=\"%s\" subdir=\"%s\" ext=\"%s\" operation=\"%s\" sourcename=\"%s\" hostname=\"%s\" iphost=\"%u\" port=\"%u\" />\n",
90 source, origin, maxage, maxcount, (binary ?
"yes" :
"no"), name, key, value, type, subdir, ext, operation,
91 sourceName, hostName, ipHost, ipPort);
93 bool fromXML(
const char* xml) {
94 if (!xml)
return false;
96 XMLNode node = XMLNode::parseString(xml,
"query", &xmlResults);
97 if (xmlResults.error != eXMLErrorNone)
99 if (node.isEmpty())
return false;
100 return fromXML(node);
104 if (str = node.getAttribute(
"source")) source = utils::Ascii2Uint32(str);
else return false;
105 if (str = node.getAttribute(
"origin")) origin = utils::Ascii2Uint32(str);
else return false;
106 if (str = node.getAttribute(
"maxage")) maxage = utils::Ascii2Uint64(str);
else return false;
107 if (str = node.getAttribute(
"maxcount")) maxcount = utils::Ascii2Uint32(str);
else return false;
108 if (str = node.getAttribute(
"context")) {
if (!context.fromString(str))
return false; }
else return false;
109 if (str = node.getAttribute(
"binary")) binary = (stricmp(str,
"yes") == 0);
else return false;
110 if (str = node.getAttribute(
"name")) utils::strcpyavail(name, str, MAXKEYNAMELEN,
true);
else return false;
111 if (str = node.getAttribute(
"key")) utils::strcpyavail(key, str, MAXKEYNAMELEN,
true);
else return false;
112 if (str = node.getAttribute(
"value")) utils::strcpyavail(value, str, MAXVALUENAMELEN,
true);
else return false;
113 if (str = node.getAttribute(
"type")) utils::strcpyavail(type, str, MAXKEYNAMELEN,
true);
else return false;
114 if (str = node.getAttribute(
"subdir")) utils::strcpyavail(subdir, str, MAXKEYNAMELEN,
true);
else return false;
115 if (str = node.getAttribute(
"ext")) utils::strcpyavail(ext, str, MAXKEYNAMELEN,
true);
else return false;
116 if (str = node.getAttribute(
"operation")) utils::strcpyavail(operation, str, MAXKEYNAMELEN,
true);
else return false;
117 if (str = node.getAttribute(
"sourcename")) utils::strcpyavail(sourceName, str, MAXKEYNAMELEN,
true);
else return false;
118 if (str = node.getAttribute(
"hostname")) utils::strcpyavail(hostName, str, MAXKEYNAMELEN,
true);
else return false;
119 if (str = node.getAttribute(
"iphost")) ipHost = utils::Ascii2Uint32(str);
else return false;
120 if (str = node.getAttribute(
"ipport")) ipPort = utils::Ascii2Uint32(str);
else return false;
133 char name[MAXKEYNAMELEN+1];
134 char key[MAXKEYNAMELEN+1];
144 char startString[MAXVALUENAMELEN+1];
145 char endString[MAXVALUENAMELEN+1];
146 std::string toXML() {
147 return utils::StringFormat(
"\t<retrieve source=\"%u\" origin=\"%u\" maxage=\"%llu\" maxcount=\"%u\" type=\"%s\" context=\"%s\" tag=\"%u\" name=\"%s\" key=\"%s\" keytype=\"%u\" from=\"%u\" to=\"%u\" starttime=\"%llu\" endtime=\"%llu\" startint=\"%lld\" endint=\"%lld\" startfloat=\"%f\" endfloat=\"%f\" startstring=\"%s\" endstring=\"%s\" />\n",
148 source, origin, maxage, maxcount, type.toString().c_str(), context.toString().c_str(),
149 tag, name, key, keytype, from, to,
150 startTime, endTime, startInt, endInt, startFloat, endFloat, startString, endString);
152 bool fromXML(
const char* xml) {
153 if (!xml)
return false;
155 XMLNode node = XMLNode::parseString(xml,
"retrieve", &xmlResults);
156 if (xmlResults.error != eXMLErrorNone)
158 if (node.isEmpty())
return false;
159 return fromXML(node);
163 if (str = node.getAttribute(
"source")) source = utils::Ascii2Uint32(str);
else return false;
164 if (str = node.getAttribute(
"origin")) origin = utils::Ascii2Uint32(str);
else return false;
165 if (str = node.getAttribute(
"maxage")) maxage = utils::Ascii2Uint64(str);
else return false;
166 if (str = node.getAttribute(
"maxcount")) maxcount = utils::Ascii2Uint32(str);
else return false;
167 if (str = node.getAttribute(
"type")) {
if (!type.fromString(str))
return false; }
else return false;
168 if (str = node.getAttribute(
"context")) {
if (!context.fromString(str))
return false; }
else return false;
169 if (str = node.getAttribute(
"tag")) tag = utils::Ascii2Uint32(str);
else return false;
170 if (str = node.getAttribute(
"name")) utils::strcpyavail(name, str, MAXKEYNAMELEN,
true);
else return false;
171 if (str = node.getAttribute(
"key")) utils::strcpyavail(key, str, MAXKEYNAMELEN,
true);
else return false;
172 if (str = node.getAttribute(
"keytype")) keytype = (uint8)utils::Ascii2Uint32(str);
else return false;
173 if (str = node.getAttribute(
"from")) from = utils::Ascii2Uint32(str);
else return false;
174 if (str = node.getAttribute(
"to")) to = utils::Ascii2Uint32(str);
else return false;
175 if (str = node.getAttribute(
"starttime")) startTime = utils::Ascii2Uint64(str);
else return false;
176 if (str = node.getAttribute(
"endtime")) endTime = utils::Ascii2Uint64(str);
else return false;
177 if (str = node.getAttribute(
"startint")) startInt = utils::Ascii2Int64(str);
else return false;
178 if (str = node.getAttribute(
"endint")) endInt = utils::Ascii2Int64(str);
else return false;
179 if (str = node.getAttribute(
"startfloat")) startFloat = utils::Ascii2Float64(str);
else return false;
180 if (str = node.getAttribute(
"endfloat")) endFloat = utils::Ascii2Float64(str);
else return false;
181 if (str = node.getAttribute(
"startstring")) utils::strcpyavail(startString, str, MAXVALUENAMELEN,
true);
else return false;
182 if (str = node.getAttribute(
"endstring")) utils::strcpyavail(endString, str, MAXVALUENAMELEN,
true);
else return false;
187 #define MESSAGE_NON_GUARANTEED 1 198 char name[MAXKEYNAMELEN+1];
200 char content[MAXCONTENTLEN + 1];
201 std::string toXML() {
204 const char* contentType, *key, *value;
205 std::string strContent;
206 std::vector<std::string> entries = utils::TextListSplit(content,
"||",
false,
true);
207 uint32 slotCount = 3 * contentCount;
209 if (entries.size() == slotCount) {
210 while (n < slotCount) {
211 contentType = entries[n++].c_str();
212 key = entries[n++].c_str();
213 value = entries[n++].c_str();
214 if (strcmp(contentType,
"S") == 0) {
215 strContent += utils::StringFormat(
"\t\t<content type=\"string\" key=\"%s\" value=\"%s\" />\n",
216 html::EncodeHTML(key).c_str(), html::EncodeHTML(value).c_str());
218 else if (strcmp(contentType,
"I") == 0) {
219 strContent += utils::StringFormat(
"\t\t<content type=\"integer\" key=\"%s\" value=\"%s\" />\n",
220 html::EncodeHTML(key).c_str(), html::EncodeHTML(value).c_str());
222 else if (strcmp(contentType,
"F") == 0) {
223 strContent += utils::StringFormat(
"\t\t<content type=\"float\" key=\"%s\" value=\"%s\" />\n",
224 html::EncodeHTML(key).c_str(), html::EncodeHTML(value).c_str());
228 return utils::StringFormat(
"\t<post to=\"%u\" type=\"%s\" context=\"%s\" contextchange=\"%s\" tag=\"%u\" ttl=\"%llu\" policy=\"%u\" name=\"%s\">\n%s</post>\n",
229 to, type.toString().c_str(), context.toString().c_str(), contextchange.toString().c_str(), tag, ttl, policy, name, strContent.c_str());
232 return utils::StringFormat(
"\t<post to=\"%u\" type=\"%s\" context=\"%s\" contextchange=\"%s\" tag=\"%u\" ttl=\"%llu\" policy=\"%u\" name=\"%s\" />\n",
233 to, type.toString().c_str(), context.toString().c_str(), contextchange.toString().c_str(), tag, ttl, policy, name);
236 bool fromXML(
const char* xml) {
237 if (!xml)
return false;
239 XMLNode node = XMLNode::parseString(xml,
"post", &xmlResults);
240 if (xmlResults.error != eXMLErrorNone)
242 if (node.isEmpty())
return false;
243 return fromXML(node);
247 if (str = node.getAttribute(
"to")) to = utils::Ascii2Uint32(str);
else return false;
248 if (str = node.getAttribute(
"type")) {
if (!type.fromString(str))
return false; }
250 if (str = node.getAttribute(
"context")) {
if (!context.fromString(str))
return false; }
252 if (str = node.getAttribute(
"contextchange")) {
if (!contextchange.fromString(str))
return false; }
254 if (str = node.getAttribute(
"tag")) tag = utils::Ascii2Uint32(str);
else return false;
255 if (str = node.getAttribute(
"ttl")) ttl = utils::Ascii2Uint64(str);
else return false;
256 if (str = node.getAttribute(
"policy")) policy = (uint8)utils::Ascii2Uint32(str);
else return false;
257 if (str = node.getAttribute(
"name")) utils::strcpyavail(name, str, MAXKEYNAMELEN,
true);
else return false;
258 contentFromXML(node);
261 bool contentFromXML(
XMLNode &node) {
262 std::string strContent;
263 const char* str, *key, *value;
264 if ((key = node.getAttribute(
"contentkey")) && (value = node.getAttribute(
"content"))) {
265 strContent = utils::StringFormat(
"%s||S||%s||%s", content, html::DecodeHTML(key).c_str(), html::DecodeHTML(value).c_str());
266 utils::strcpyavail(content, strContent.c_str(), MAXCONTENTLEN,
false);
271 uint32 i, count = node.nChildNode(
"content");
272 for (i = 0; i < count; i++) {
273 if (!(subNode = node.getChildNode(
"content", i)).isEmpty()) {
274 if (!(key = subNode.getAttribute(
"key")) || !strlen(key))
276 if ( (!(value = subNode.getAttribute(
"content")) || !strlen(value)) &&
277 (!(value = subNode.getAttribute(
"value")) || !strlen(value)) )
279 str = subNode.getAttribute(
"type");
280 if (str && stricmp(str,
"integer") == 0)
281 strContent = utils::StringFormat(
"%s||I||%s||%s", content, html::DecodeHTML(key).c_str(), html::DecodeHTML(value).c_str());
282 else if (str && ((stricmp(str,
"double") == 0) || (stricmp(str,
"float") == 0)))
283 strContent = utils::StringFormat(
"%s||F||%s||%s", content, html::DecodeHTML(key).c_str(), html::DecodeHTML(value).c_str());
285 strContent = utils::StringFormat(
"%s||S||%s||%s", content, html::DecodeHTML(key).c_str(), html::DecodeHTML(value).c_str());
286 utils::strcpyavail(content, strContent.c_str(), MAXCONTENTLEN,
false);
296 const char* contentType, *key, *value;
297 std::string strContent;
298 std::vector<std::string> entries = utils::TextListSplit(content,
"||",
false,
true);
299 uint32 slotCount = 3 * contentCount, n = 0;
300 if (entries.size() == slotCount) {
301 while (n < slotCount) {
302 contentType = entries[n++].c_str();
303 key = entries[n++].c_str();
304 value = entries[n++].c_str();
305 if (strcmp(contentType,
"S") == 0)
307 else if (strcmp(contentType,
"I") == 0)
308 msg->
setInt(key, utils::Ascii2Int64(value));
309 else if (strcmp(contentType,
"F") == 0)
310 msg->
setFloat(key, utils::Ascii2Float64(value));
320 char name[MAXKEYNAMELEN+1];
321 std::string toXML() {
322 return utils::StringFormat(
"\t<signal type=\"%s\" name=\"%s\" />\n", type.toString().c_str(), name);
324 bool fromXML(
const char* xml) {
325 if (!xml)
return false;
327 XMLNode node = XMLNode::parseString(xml,
"signal", &xmlResults);
328 if (xmlResults.error != eXMLErrorNone)
330 if (node.isEmpty())
return false;
331 return fromXML(node);
335 if (str = node.getAttribute(
"type")) {
if (!type.fromString(str))
return false; }
else return false;
336 if (str = node.getAttribute(
"name")) utils::strcpyavail(name, str, MAXKEYNAMELEN,
true);
else return false;
342 bool reset(uint32 s = 0) {
349 if (n >= filterCount)
return NULL;
354 if (n >= retrieveCount)
return NULL;
360 if (n >= queryCount)
return NULL;
365 QuerySpec* getQuerySpec(
const char* name);
366 std::list<PostSpec*>* getPostSpecs(
const char* name);
367 std::list<PostSpec*>* getPostSpecs(
PsyType type);
368 PostSpec* getPostSpec(
const char* name);
371 if (n >= postCount)
return NULL;
380 if (n >= signalCount)
return NULL;
404 char name[MAXKEYNAMELEN+1];
406 uint16 retrieveCount;
419 cid = COMPONENTSETUPDATA;
428 char name[MAXKEYNAMELEN+1];
429 char logfile[MAXKEYNAMELEN+1];
434 char function[MAXKEYNAMELEN+1];
435 char root[MAXKEYNAMELEN+1];
441 char subdir[MAXKEYNAMELEN+1];
442 char extension[MAXKEYNAMELEN+1];
443 char base[MAXKEYNAMELEN+1];
444 char keys[MAXVALUENAMELEN+1];
445 char value[MAXVALUENAMELEN+1];
446 char operation[MAXKEYNAMELEN+1];
455 char cmdline[MAXKEYNAMELEN+1];
458 char setup[1024*1024];
465 char name[MAXKEYNAMELEN+1];
466 char templateURL[MAXKEYNAMELEN+1];
478 while (triggers.size()) {
479 delete(triggers.front());
480 triggers.pop_front();
485 std::list<TriggerSpec*> triggers;
486 std::list<CustomView> customViews;
491 #endif //_SUBSCRIPTIONS_H_ Definition: Subscriptions.h:189
Definition: Subscriptions.h:415
Definition: Subscriptions.h:341
Definition: Subscriptions.h:42
Definition: Subscriptions.h:125
bool setFloat(const char *key, float64 value)
Definition: DataMessage.cpp:1795
bool setString(const char *key, const char *value)
Definition: DataMessage.cpp:1776
Definition: Subscriptions.h:469
Definition: Subscriptions.h:318
Definition: xml_parser.h:171
bool setInt(const char *key, int64 value)
Definition: DataMessage.cpp:1786
Definition: Subscriptions.h:70
Definition: xml_parser.h:153
Definition: Subscriptions.h:463
Definition: DataMessage.h:95