DgnHistory.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
10 
11 namespace Bentley {
12 class DataInternalizer;
13 class DataExternalizer;
14 };
15 
17 struct XAttributeChange;
18 namespace DgnHistory {
19 
20 //=======================================================================================
25 //=======================================================================================
27 {
28 // ***************************** PERSISTENT VALUES *********************************
29 // ***************************** DO NOT CHANGE *********************************
30 private:
31  /*-----------------------------------------------------------------------------------
32  Fields
33  -----------------------------------------------------------------------------------*/
34  /* We don't store a data format version # -- that would be too much space used
35  for such a small structure. Instead, we have reserved a couple of fields (zeroed!)
36  for future use. One of them could be used as a version # in the future. */
37  UInt8 length;
38  UInt8 flags;
39  UInt16 _unused2_;
40  UInt32* d;
41 
42 public:
45  DGNPLATFORM_EXPORT RevisionNumber (RevisionNumber const& r2);
46  DGNPLATFORM_EXPORT RevisionNumber& operator= (RevisionNumber const& r2);
47 
48  DGNPLATFORM_EXPORT bool operator< (RevisionNumber const& rn2) const;
49  DGNPLATFORM_EXPORT bool operator<= (RevisionNumber const& rn2) const;
50  DGNPLATFORM_EXPORT bool operator> (RevisionNumber const& rn2) const;
51  DGNPLATFORM_EXPORT bool operator>= (RevisionNumber const& rn2) const;
52  DGNPLATFORM_EXPORT bool operator== (RevisionNumber const& rn2) const;
53  DGNPLATFORM_EXPORT bool operator!= (RevisionNumber const& rn2) const;
54 
56  DGNPLATFORM_EXPORT static RevisionNumber Recent ();
57 
59  DGNPLATFORM_EXPORT bool IsRecent () const;
60 
62  DGNPLATFORM_EXPORT bool IsValid () const;
63 
64 /*---------------------------------------------------------------------------------**/
70  DGNPLATFORM_EXPORT WString Format () const;
71 
72 /*---------------------------------------------------------------------------------**/
79 DGNPLATFORM_EXPORT WString FormatCustom (WChar const* fmt) const;
81 
86 DGNPLATFORM_EXPORT static RevisionNumber ParseCustom (WChar const* fmt, WChar const* str);
87 
91 DGNPLATFORM_EXPORT static RevisionNumber Parse (WChar const *str);
92 
93 };
94 
95 
96 //=======================================================================================
103 //=======================================================================================
105 {
106 
107 WString m_user;
108 WString m_desc;
109 RevisionNumber m_revnum;
110 UInt32 m_flags;
111 
112 public:
116 DGNPLATFORM_EXPORT void SetUserName (WCharCP userName);
118 DGNPLATFORM_EXPORT bool IsValid () const;
119 };
120 
121 //=======================================================================================
125 //=======================================================================================
127 {
128 WString m_user;
129 WString m_desc;
130 double m_time;
131 RevisionNumber m_num;
132 RevisionNumber m_next;
133  UInt32 m_flags;
134 public:
135 
137 DGNPLATFORM_EXPORT RevisionInfo (RevisionInfo const&);
138 DGNPLATFORM_EXPORT RevisionInfo& operator= (RevisionInfo const&);
139 DGNPLATFORM_EXPORT ~RevisionInfo ();
140 
142 DGNPLATFORM_EXPORT WString GetUser() const;
144 DGNPLATFORM_EXPORT WString GetDescription() const;
146 DGNPLATFORM_EXPORT double GetTime() const;
148 DGNPLATFORM_EXPORT RevisionNumber GetRevisionNumber() const;
149 };
150 
151 typedef bvector<RevisionInfo> T_RevisionInfoVector;
152 
153 //=======================================================================================
158 //=======================================================================================
160 {
167 };
168 
169 //=======================================================================================
173 //=======================================================================================
174 // ***************************** PERSISTENT VALUES *********************************
175 // ***************************** DO NOT CHANGE *********************************
177 {
178 public:
180 DGNPLATFORM_EXPORT WString GetUser() const;
182 DGNPLATFORM_EXPORT WString GetDescription() const;
184 DGNPLATFORM_EXPORT double GetTime() const;
186 DGNPLATFORM_EXPORT RevisionNumber GetStartRevisionNumber() const;
188 DGNPLATFORM_EXPORT RevisionNumber GetEndRevisionNumber() const;
191 };
192 
194 //=======================================================================================
199 
200 // ***************************** PERSISTENT VALUES *********************************
201 // ***************************** DO NOT CHANGE *********************************
202 class ElementChangeFlags
203 {
204  // Fields
205 protected:
206  /* ChangeRecord data version is governed by the Admin version */
207  enum {FLAGS_Mask=0xF0, FLAG_Have8ByteID=0x80};
208 
209  // Fields
210  UInt8 m_flagsAndChangeType; // 4-bit flags | 4-bit change type value
211  UInt8 m_unused_transient_byte; // unused -- NOT STORED -- always zero
212  UInt16 m_unused_transient_short; // unused -- NOT STORED -- always zero
213  UInt32 m_unused_transient_int; // unused -- NOT STORED -- always zero
214 
215  // Methods
216 protected:
218 
219 public:
220 explicit
221  ElementChangeFlags (ElementChangeType ct) {Init(ct);}
222  ElementChangeFlags () {Init(ElementChangeType::Missing);}
223 
224  bool operator== (ElementChangeFlags const& rhs) const {return m_flagsAndChangeType == rhs.m_flagsAndChangeType;}
225 
226  DGNPLATFORM_EXPORT ElementChangeType GetChangeType () const;
227  DGNPLATFORM_EXPORT void SetChangeType (ElementChangeType);
228 };
229 
230 //=======================================================================================
233 //=======================================================================================
234 // ***************************** PERSISTENT VALUES *********************************
235 // ***************************** DO NOT CHANGE *********************************
236 struct ElementChangeRecord : ElementChangeFlags
237 {
238 private:
239  ElementId m_element;
240 public:
241  ElementChangeRecord () {}
242  ElementChangeRecord (ElementId e, ElementChangeFlags c) : m_element(e), ElementChangeFlags(c) {;}
243  ElementChangeRecord (ElementChangeType ct, ElementId eid) : m_element(eid), ElementChangeFlags(ct) {;}
244 explicit
245  ElementChangeRecord (bpair<ElementId, ElementChangeFlags> const& pr) : m_element(pr.first), ElementChangeFlags(pr.second) {;}
246 
247  ElementId GetElementId() const {return m_element;}
248 
250  StatusInt Load (DataInternalizer&);
251  void Store (DataExternalizer&) const;
253 }; // ElementChangeFlags
254 
255 /*=================================================================================**/
260 {
262 virtual void SetModel (ModelId) = 0;
263 
264 virtual StatusInt ProcessElementChange
265 (
266 RevisionInfo const& revision, // => history revision that contains this change
267 ModelId mid, // => the model that contains this element
268 ElementChangeRecord const& change, // => the relative change that produced this state
269 MSElementDescrP element // => the historical state of the element (you can call mdlElmdscr_addRef on it, but you should not otherwise modify it)
270 ) = 0;
271 
272 }; // IElementChangeProcessor
273 
274 //=======================================================================================
278 //=======================================================================================
279 // ***************************** PERSISTENT VALUES *********************************
280 // ***************************** DO NOT CHANGE *********************************
282 {
285 
289 
291 
292 DGNPLATFORM_EXPORT XAttributeHandlerId GetHandlerId () const;
293 
294 DGNPLATFORM_EXPORT UInt32 GetId () const;
295 
296 DGNPLATFORM_EXPORT UInt64 AsUInt64 () const;
297 
298 bool operator == (XAUniqueId const& cc) const {return m_handler==cc.m_handler && m_id==cc.m_id;}
299 bool operator < (XAUniqueId const& cc) const {return AsUInt64() < cc.AsUInt64();}
300 
301 DGNPLATFORM_EXPORT StatusInt CheckIsValid () const;
302 
303 DGNPLATFORM_EXPORT StatusInt Load (DataInternalizer& source);
304 DGNPLATFORM_EXPORT void Store (DataExternalizer& sink) const;
305 };
306 
307 
309 
310 }; // DgnHistory
312 
A "handle" that can be used to access a single XAttribute of a persistent element.
Definition: XAttributeIter.h:74
XAUniqueId()
Definition: DgnHistory.h:286
#define END_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:69
wchar_t WChar
Definition: Bentley.h:223
bool operator<=(const basic_string< _CharT, _Traits, _Allocator > &__lhs, const basic_string< _CharT, _Traits, _Allocator > &__rhs)
Definition: basic_string.h:1376
UInt32 m_id
Definition: DgnHistory.h:284
uint16_t UInt16
Definition: Bentley.r.h:118
A scheduled change to an XAttribute stored on an EditElementHandle.
Definition: XAttributeChange.h:24
A history revision number.
Definition: DgnHistory.h:26
uint8_t UInt8
Definition: Bentley.r.h:116
#define DGNPLATFORM_EXPORT
Definition: DgnPlatform/ExportMacros.h:58
a record in design history audit trail.
Definition: DgnHistory.h:176
UInt32 m_handler
Definition: DgnHistory.h:283
wchar_t const * WCharCP
Definition: Bentley.h:224
Associates a user name and a description with a set of changes recorded in design history...
Definition: DgnHistory.h:104
uint32_t UInt32
Definition: Bentley.r.h:128
bstdmap & operator=(const bstdmap &__rhs)
Definition: stdcxx/bstdmap.h:170
Documents a set of changes in design history.
Definition: DgnHistory.h:126
A two-part ID used by XAttribute Handlers.
Definition: DgnCore.h:74
DGNPLATFORM_EXPORT UInt64 AsUInt64() const
bool operator<(const basic_string< _CharT, _Traits, _Allocator > &__lhs, const basic_string< _CharT, _Traits, _Allocator > &__rhs)
Definition: basic_string.h:1326
AuditTrailRecordType
Type of record in design history audit trail.
Definition: DgnHistory.h:159
bool operator>(const basic_string< _CharT, _Traits, _Allocator > &__lhs, const basic_string< _CharT, _Traits, _Allocator > &__rhs)
Definition: basic_string.h:1366
Definition: MSElementDescr.h:28
A template that has many of the capabilities of std::pair.
Definition: bpair.h:73
Int32 ModelId
Definition: DgnPlatformBaseType.r.h:84
uint64_t UInt64
Definition: Bentley.r.h:131
#define BEGIN_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:68
bool operator!=(const BentleyAllocator< _Ty > &, const BentleyAllocator< _Other > &)
Definition: BentleyAllocator.h:152
virtual ~IElementChangeProcessor()
Definition: DgnHistory.h:261
int StatusInt
Definition: Bentley.h:222
UInt64 ElementId
Definition: DgnPlatformBaseType.r.h:83
bool operator>=(const basic_string< _CharT, _Traits, _Allocator > &__lhs, const basic_string< _CharT, _Traits, _Allocator > &__rhs)
Definition: basic_string.h:1386
Uniquely identifies an XAttribute within an element.
Definition: DgnHistory.h:281
Interface for an element that processes element changes in design history.
Definition: DgnHistory.h:259
bvector< RevisionInfo > T_RevisionInfoVector
Definition: DgnHistory.h:151
ElementChangeType
The kinds of changes recorded in design history.
Definition: DgnPlatform.h:659
A string class that has many of the same capabilities as std::string, plus additional functions such ...
Definition: WString.h:51
bool operator==(const BentleyAllocator< _Ty > &, const BentleyAllocator< _Other > &)
Definition: BentleyAllocator.h:146

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.