20#if !defined(__types_h)
31#define FACTORYPRIORITY 90
38#pragma GCC diagnostic ignored "-Wformat"
44 typedef signed char int8;
45 typedef unsigned char uint8;
47 typedef unsigned short uint16;
49 typedef unsigned int uint32;
50 typedef long long int64;
51 typedef unsigned long long uint64;
52 typedef float float32;
53 typedef double float64;
59 typedef signed char int8;
60 typedef unsigned char uint8;
62 typedef unsigned short uint16;
64 typedef unsigned int uint32;
65 typedef float float32;
66 typedef double float64;
70 typedef long long int64;
71 typedef unsigned long long uint64;
73 typedef int64_t int64;
74 typedef uint64_t uint64;
79#define INT32_NOVALUE 0x12345678
80#define INT64_NOVALUE 0x123456789ABCDEF0L
81#define FLOAT64_NOVALUE 0.123456789123456789
83#define MAXVALUINT8 ((uint8)~((uint8)0))
84#define MAXVALINT8 ((int8)(MAXVALUINT8 >> 1))
85#define MAXVALUINT16 ((uint16)~((uint16)0))
86#define MAXVALINT16 ((int16)(MAXVALUINT16 >> 1))
87#define MAXVALUINT32 ((uint32)~((uint32)0))
88#define MAXVALINT32 ((int32)(MAXVALUINT32 >> 1))
89#define MAXVALUINT64 ((uint64)~((uint64)0))
90#define MAXVALINT64 ((int64)(MAXVALUINT64 >> 1))
92#define MERGEUINT3264(a,b) (((uint64)a)<<32)|((uint64)b)
93#define GET1UINT3264(a) (uint32)((a & 0xffffffff00000000L)>>32)
94#define GET2UINT3264(a) (uint32)(a & 0x00000000ffffffffL)
95#define MERGEUINT1632(a,b) (((uint32)a)<<16)|((uint32)b)
96#define GET1UINT1632(a) (uint16)((a & 0xffff0000L)>>16)
97#define GET2UINT1632(a) (uint16)(a & 0x0000ffffL)
100#define PSYTYPELEVELS 16
198 std::stringstream ss;
208 std::string
toString(std::map<uint16, std::string>* subtypes) {
214 std::map<uint16, std::string>::iterator i, e = subtypes->end();
215 std::stringstream ss;
216 if ((i = subtypes->find(
levels[0])) != e)
222 if ((i = subtypes->find(
levels[n])) != e)
223 ss <<
'.' << i->second;
238 const char* pstr = text;
239 const char* src = text;
240 char *temp =
new char[16];
243 while (pstr = strstr(src,
".")) {
245 memcpy(temp, src, pstr - src);
246 temp[pstr - src] = 0;
254 pstr = src + strlen(src);
256 memcpy(temp, src, pstr - src);
257 temp[pstr - src] = 0;
267#define PSYCONTEXTLEVELS 16
333 (othercontext.
levels[n] != 0xFFFF) &&
335 (othercontext.
levels[n] != 0)
344 std::stringstream ss;
352 std::string
toString(std::map<uint16, std::string>* subcontexts) {
358 std::map<uint16, std::string>::iterator i, e = subcontexts->end();
359 std::stringstream ss;
360 if ((i = subcontexts->find(
levels[0])) != e)
366 if ((i = subcontexts->find(
levels[n])) != e)
367 ss <<
'.' << i->second;
379 const char* pstr = text;
380 const char* src = text;
381 char *temp =
new char[16];
384 while (pstr = strstr(src,
".")) {
386 memcpy(temp, src, pstr - src);
387 temp[pstr - src] = 0;
395 pstr = src + strlen(src);
397 memcpy(temp, src, pstr - src);
398 temp[pstr - src] = 0;
406 #define CONTEXT_OTHER_ROOT 0
407 #define CONTEXT_EQUAL 1
408 #define CONTEXT_SUPERSEDES 2
409 #define CONTEXT_INCLUDED 3
419 else if (
levels[n] == 0) {
420 if (othercontext.
levels[n] == 0)
436static struct PsyType NOTYPE = { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
437static struct PsyContext NOCONTEXT = { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
Platform/compiler detection and base portability macros for all of CMSDK.
#define CONTEXT_OTHER_ROOT
compare(): the contexts differ already at the root level.
static struct PsyType NOTYPE
The empty/unset message type (isValid() == false).
#define CONTEXT_EQUAL
compare(): the contexts are equal (up to wildcards).
static struct PsyContext NOCONTEXT
The empty/unset context (isValid() == false).
#define CONTEXT_INCLUDED
compare(): this context is more general and includes the other.
#define CONTEXT_SUPERSEDES
compare(): this context is more specific than / supersedes the other.
#define PSYCONTEXTLEVELS
Number of hierarchy levels in a PsyContext.
#define PSYTYPELEVELS
Number of hierarchy levels in a PsyType.
Hierarchical execution-context identifier.
bool fromString(const char *text)
bool operator<(const PsyContext &othercontext) const
bool operator!=(const PsyContext &othercontext) const
uint8 compare(const PsyContext &othercontext) const
Classify the hierarchical relationship between this context and another.
bool operator>(const PsyContext &othercontext) const
bool matches(const PsyContext &othercontext) const
Wildcard-aware context matching: levels are considered matching when equal, or when either side is 0x...
uint16 levels[PSYCONTEXTLEVELS]
Hierarchy levels, most significant first; 0 terminates (and wildcards in matches()),...
std::string toString(std::map< uint16, std::string > *subcontexts)
bool setLevel(int i, uint16 value)
uint16 operator[](int i) const
bool operator==(const PsyContext &othercontext) const
Hierarchical message type identifier — the key used for publish/subscribe matching in Psyclone.
bool matches(PsyType &otherType) const
Wildcard-aware type matching used by the subscription system.
bool fromString(const char *text)
Parse dotted decimal notation (e.g.
std::string toString()
Render as dotted decimal notation, e.g. "2.201.3"; empty string if invalid.
bool setLevel(int i, uint16 value)
Set an individual hierarchy level.
uint16 levels[PSYTYPELEVELS]
Hierarchy levels, most significant first; 0 terminates, 0xFFFF is a wildcard.
std::string toString(std::map< uint16, std::string > *subtypes)
Render as dotted notation, substituting readable names for level ids where available.
bool operator!=(const PsyType &othertype) const
Exact byte-wise inequality (wildcards NOT honoured).
bool isValid()
A type is valid if its root level is non-zero.
uint16 operator[](int i) const
bool operator<(const PsyType &othertype) const
Lexicographic level-by-level ordering, so PsyType can be used as a std::map/stdmultimap key.
bool operator==(const PsyType &othertype) const
Exact byte-wise equality of all levels (wildcards NOT honoured; use matches() for that).
bool operator>(const PsyType &othertype) const