NAVTOR SDK  v.3.0
Software Development Kit for fast and efficient development of ECDIS, ECS and generic marine applications
sdk_uuid.h
Go to the documentation of this file.
1 #ifndef SDK_UUID_H_
11 #define SDK_UUID_H_
12 
13 #if defined(__cplusplus)
14 #if defined(SDK_ARCH_32BITS) && defined(SDK_ARCH_ARM)
15 #include <string.h>
16 #endif
17 #endif
18 
19 #include <base/inc/platform.h>
20 #include <base/inc/base_types.h>
21 
22 #if defined(__cplusplus)
23 SDK_BEGIN_NAMESPACE
24 #endif
25 
26 #define SDK_DECLARE_IID(name) \
27  static const SDK_NAMESPACE::Uuid name##_uuid_ = #name; \
28  inline const SDK_NAMESPACE::Uuid& name::IID() { return name##_uuid_; }
29 
30 #define SDK_IMPLEMENT_IID(name) public: \
31  static const SDK_NAMESPACE::Uuid& IID();
32 
33 // #define SDK_END_INTERFACE(name) protected: virtual ~name() {}
34 #define SDK_END_INTERFACE(name)
35 
36 
37 typedef char UuidChar[48];
38 typedef UuidChar Uuid;
39 
42 typedef Uuid ComponentId;
45 typedef Uuid InterfaceId;
46 
49 static Uuid UuidNull = {'\0'};
50 
51 #define UuidUInt64(uuid) (reinterpret_cast<SDKUInt64*>(uuid))
52 #define UuidConstUInt64(uuid) (reinterpret_cast<const SDKUInt64*>(uuid))
53 
54 #if defined(__cplusplus)
55 
56 #if defined(SDK_ARCH_32BITS) && defined(SDK_ARCH_ARM)
57  inline bool IsEqualUuid(const Uuid& uuid1, const Uuid& uuid2) {
60  return memcmp(&uuid1, &uuid2, SDK_ARRAY_LENGTH(uuid1)) == 0;
61  }
62 
65  inline bool IsNullUuid(const Uuid & uuid) {
66  return memcmp(&uuid, &UuidNull, SDK_ARRAY_LENGTH(uuid)) == 0;
67  }
68 
71  inline void CopyUuid(const Uuid& uuid1, Uuid& uuid2) {
72  memcpy(&uuid2, &uuid1, SDK_ARRAY_LENGTH(uuid1));
73  }
74 #else
75  inline bool IsEqualUuid(const Uuid& uuid1, const Uuid& uuid2) {
78  return ((UuidConstUInt64(uuid1)[0] == UuidConstUInt64(uuid2)[0]) &&
79  (UuidConstUInt64(uuid1)[1] == UuidConstUInt64(uuid2)[1]) &&
80  (UuidConstUInt64(uuid1)[2] == UuidConstUInt64(uuid2)[2]) &&
81  (UuidConstUInt64(uuid1)[3] == UuidConstUInt64(uuid2)[3]) &&
82  (UuidConstUInt64(uuid1)[4] == UuidConstUInt64(uuid2)[4]) &&
83  (UuidConstUInt64(uuid1)[5] == UuidConstUInt64(uuid2)[5]));
84  }
87  inline bool IsNullUuid(const Uuid& uuid) {
88  return ((UuidConstUInt64(uuid)[0] == 0) &&
89  (UuidConstUInt64(uuid)[1] == 0) &&
90  (UuidConstUInt64(uuid)[2] == 0) &&
91  (UuidConstUInt64(uuid)[3] == 0) &&
92  (UuidConstUInt64(uuid)[4] == 0) &&
93  (UuidConstUInt64(uuid)[5] == 0));
94  }
95 
98  inline void CopyUuid(const Uuid& uuid1, Uuid& uuid2) {
99  UuidUInt64(uuid2)[0] = UuidConstUInt64(uuid1)[0];
100  UuidUInt64(uuid2)[1] = UuidConstUInt64(uuid1)[1];
101  UuidUInt64(uuid2)[2] = UuidConstUInt64(uuid1)[2];
102  UuidUInt64(uuid2)[3] = UuidConstUInt64(uuid1)[3];
103  UuidUInt64(uuid2)[4] = UuidConstUInt64(uuid1)[4];
104  UuidUInt64(uuid2)[5] = UuidConstUInt64(uuid1)[5];
105  }
106 
107 #endif
108 #endif
109 
110 #if defined(__cplusplus)
111 SDK_END_NAMESPACE
112 #endif
113 
114 #endif // SDK_UUID_H_
base_types.h
SDK base types.
InterfaceId
Uuid InterfaceId
Definition of interface UUID.
Definition: sdk_uuid.h:45
platform.h
Describes the platform constants.
UuidNull
static Uuid UuidNull
Null UUID.
Definition: sdk_uuid.h:49
ComponentId
Uuid ComponentId
Definition of component UUID.
Definition: sdk_uuid.h:42