This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core_unique.h
125 lines (113 loc) · 3.67 KB
/
core_unique.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#pragma once
#include "plug.h"
namespace Konnekt {
/**
*/
namespace Unique {
enum enDomainId {
domainOther,
domainDomain,
domainRange,
domainTable,
domainIMessage,
domainMessageType,
domainAction,
domainNet,
domainIcon,
domainNotFound = -1
};
enum enRangeId {
rangeMain = 0,
rangeStatic,
rangeUnique,
rangeUniqueLow,
rangeDefault = -1,
rangeNotFound = -1
};
typedef enDomainId tDomainId;
typedef enRangeId tRangeId;
typedef unsigned int tId;
const tId idNotFound = -1;
const tId commonUniqueStart = 0x00800000;
class Range {
public:
/** Rodzaj zakresu
*/
enum enType {
typeBoth = 3,
// Zakres tylko dla identyfikatorów statycznych
typeStatic = 1,
// Zakres tylko dla identyfikatorów unikalnych
typeUnique = 2
};
/** Tworzy zakres identyfikatorów
*
* \param id Unikalny identyfikator zakresu
* \param priority Priorytet zakresu okreœlaj¹cy jego szczegó³owoœæ. Bardziej ogólne zakresy powinny mieæ ni¿szy priorytet. Zakres domyœlny powinien mieæ priorytet 0.
* \param type Rodzaj zakresu
* \param minimum Minimalny identyfikator
* \param maximum Maxymalny identyfikator
* \param uniqueStart Pierwszy identyfikator do automatycznego nadawania. -1 ustawia ten parametr na wartoϾ @a minimum.
* \return
*/
Range(tRangeId rangeId, enType type, unsigned int priority, unsigned int minimum = 1, unsigned int maximum = 0x7FFFFFFF, unsigned int uniqueStart=-1)
:_rangeId(rangeId), _priority(priority), _type(type), _minimum(minimum), _maximum(maximum)
{
this->_nextUnique = (uniqueStart == -1)? minimum : uniqueStart;
}
Range(const Range & r) {
*this = r;
}
virtual ~Range() {}
virtual unsigned int getClassSize() const {return sizeof(*this);}
tRangeId getRangeId() const {return _rangeId;}
unsigned int getPriority() const {return _priority;}
enType getType() const {return _type;}
unsigned int getMinimum() const {return _minimum;}
unsigned int getMaximum() const {return _maximum;}
unsigned int getNextUnique() const {return _nextUnique;}
protected:
tRangeId _rangeId;
unsigned int _priority;
enType _type;
unsigned int _minimum;
unsigned int _maximum;
unsigned int _nextUnique;
};
namespace IM {
const unsigned int domainExists = 500;
const unsigned int removeDomain = 501;
const unsigned int addRange = 502;
const unsigned int registerId = 503;
const unsigned int registerName = 504;
const unsigned int unregister = 505;
struct _addRange: public sIMessage_base {
_addRange(tDomainId domainId, const Range & range, bool setAsDefault = false)
:sIMessage_base(IM::addRange, 0, 0), domainId(domainId), range(&range), setAsDefault(setAsDefault)
{
this->s_size = sizeof(*this);
}
tDomainId domainId;
const Range * range;
bool setAsDefault;
};
struct _rangeIM: public sIMessage_base {
_rangeIM(unsigned int IMid)
:sIMessage_base(IMid, 0, 0)
,domainId(domainNotFound), rangeId(rangeNotFound), identifier(idNotFound), name(0) {
this->s_size = sizeof(*this);
}
tDomainId domainId;
tRangeId rangeId;
tId identifier;
const char * name;
};
};
bool domainExists(tDomainId domainId);
bool removeDomain(tDomainId domainId);
bool addRange(tDomainId domainId, const Range & range, bool setAsDefault = false);
bool registerId(tDomainId domainId, tId id, const char * name);
tId registerName(tDomainId domainId, const char * name, tRangeId rangeId = rangeDefault);
bool unregister(tDomainId domainId, tId id);
};
};