PGuid.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2018 Digital Barriers plc. All rights reserved.
3  * Contact: http://www.digitalbarriers.com/
4  *
5  * This file is part of the Papillon SDK.
6  *
7  * You can't use, modify or distribute any part of this file without
8  * the explicit written agreements of Digital Barriers.
9  */
10 
15 #pragma once
16 #include <PObject.h>
17 
18 PAPILLON_BEGIN_NAMESPACE
19 
28 class PAPILLON_API_CORE PGuid : public PObject
29 {
30 public:
37  static papillon::uint64 UndefinedPartId() { return 0xFFFFFFFFFFFFFFFFL; }
38 
44  static const PGuid& Null() { static const PGuid C_NULL; return C_NULL; }
45 
51  static const PGuid& Undefined() { static const PGuid C_UNDEFINED("ffffffff-ffff-ffff-ffff-ffffffffffff"); return C_UNDEFINED; }
52 
59  static const PGuid& Invalid() { static const PGuid C_INVALID("deaddead-dead-dead-dead-deaddeaddead"); return C_INVALID; }
60 
66  PGuid();
67 
71  PGuid(const PGuid& other);
72 
87  explicit PGuid(const char* str);
88 
104  explicit PGuid(const PString& str);
105 
110  PGuid(const papillon::uint8 buffer[16]);
111 
115  PGuid(papillon::uint64 storeId, papillon::uint64 objectId);
116 
120  virtual ~PGuid();
121 
125  PGuid& operator=(const PGuid& other);
126 
132  static PGuid CreateUniqueId();
133 
138  static PGuid CreateEntityId(papillon::uint64 storeId = UndefinedPartId());
139 
145  static PGuid CreateFromMD5(const PString& str);
146 
150  static PGuid CreateFrom2Ids(const PGuid& guid1, const PGuid& guid2);
151 
156  bool IsNull() const;
157 
162  bool IsUndefined() const;
163 
168  bool IsValid() const;
169 
174  bool IsInvalid() const;
175 
180  bool operator!=(const PGuid& other) const;
181 
186  bool operator==(const PGuid& other) const;
187 
191  bool operator<(const PGuid& other) const;
192 
196  bool IsNullStoreId() const;
197 
201  bool IsUndefinedStoreId() const;
202 
206  papillon::uint64 GetStoreId() const;
207 
211  bool IsNullObjectId() const;
212 
216  bool IsUndefinedObjectId() const;
217 
221  papillon::uint64 GetObjectId() const;
222 
226  PString ToStringUnderscores() const;
227 
231  PByteArray ToByteArray() const;
232 
233  friend class PGuidImpl;
234 };
235 
236 PAPILLON_END_NAMESPACE
static const PGuid & Invalid()
Returns the constant holding the invalid GUID (i.e.
Definition: PGuid.h:59
static const PGuid & Undefined()
Returns the constant holding the undefined GUID (i.e.
Definition: PGuid.h:51
The PString class provides an Unicode character strings.
Definition: PString.h:37
static papillon::uint64 UndefinedPartId()
Returns the constant holding the undefined 64-bit id, which can be Store id or Object id...
Definition: PGuid.h:37
The PByteArray class represents a resizable array of bytes.
Definition: PByteArray.h:40
The PObject class is the root class of all Papillon classes; all PObject behaves like shared referenc...
Definition: PObject.h:27
PByteArray ToByteArray() const
Returns a byte buffer representing a binary representation of this object (serialisation).
static const PGuid & Null()
Returns the constant holding the null GUID (i.e.
Definition: PGuid.h:44
The PGuid class represents a Globally Unique Identifier (GUID); PGuid instances are immutable (thread...
Definition: PGuid.h:28
Class PObject: the root class of all Papillon classes.
PObject & operator=(const PObject &obj)
Performs a shared copy of other to this object.
Definition: PObject.h:45