DesignHistory.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
10 #include <Bentley/bstdmap.h>
11 
12 
14 namespace DgnHistory {
15 
16 /*=================================================================================**/
25 /*===========+===============+===============+===============+===============+======*/
26 
27 // <p>To customize the presentation of historical changes, see \ref Bentley::DgnPlatform::DgnHistory::UI namespace.
28 
30 
33 class ElementsAsOfQuery;
34 class ElementsAsOfAdapter;
35 class ElementsAsOfUncommittedAdapter;
36 class DesignHistory;
38 class ElementChangeRecordFilter;
39 struct IRevisionCatalogProcessor;
40 
41 #define ELEMENT_CHANGETYPE_PLACEHOLDER ElementChangeType::Missing
42 #define ELEMENT_CHANGETYPE_NO_CHANGE ElementChangeType::Missing
43 
44 typedef bvector<RevisionNumber> T_RevisionNumberVectorType;
45 
47 //=========================================================================
51 //=========================================================================
52 class FarElementID
53 {
54  public:
56  ModelId model;
58  ElementId id;
59 
60  DGNPLATFORM_EXPORT FarElementID ();
61  DGNPLATFORM_EXPORT FarElementID (ModelId, ElementId);
62  DGNPLATFORM_EXPORT FarElementID& operator= (const FarElementID&);
63  DGNPLATFORM_EXPORT bool operator< (const FarElementID&) const;
64  DGNPLATFORM_EXPORT bool operator== (const FarElementID&) const;
65 };
67 
68 /*=================================================================================**/
77 {
78 
79 private:
80  DgnFileP m_file;
81  bool m_hasRecent;
82  bool m_isPreparedForQuery;
84 
85 public:
87 
89 
90 
93  DgnFileP GetDgnFileP() const {return m_file;}
94 
97  T_RevisionNumberVectorType const& GetRevisions() const {return m_revs;}
98 
100  bool operator == (RevisionNumbersForFile const& c2) const {return m_file==c2.m_file && m_revs==c2.m_revs;}
101 
103 
105 
109  void AddRevisionNumberForQuery (DgnHistory::RevisionNumber const&);
110 
112 };
113 
114 /*=================================================================================**/
124 {
125 public:
126 
128 
129 
131  ElementHandle GetElemHandle () const;
132 
133  // Short-cut method to query model that contains(ed) this element. \see ElementQueryResultsForModel::GetModelId
135  ModelId GetModelId () const;
136 
139  DgnFileP GetDgnFileP () const;
140 
142 
144 
145 
147  ElementChangeType GetChangeType () const;
148 
150  bool IsPreChangeVersion () const;
151 
154  ElementQueryResultsForModel* GetResultsForModel() const;
155 
157 
158 }; // ElementQueryResult
159 
160 /*=================================================================================**/
167 {
168  virtual bool AcceptElementQueryResult (ElementQueryResult const&) = 0;
169 
170  virtual bool AnyClientSideFilter () const = 0;
171 }; // IElementQueryResultFilter
172 
173 /*---------------------------------------------------------------------------------**/
176 struct NopElementQueryResultFilter : IElementQueryResultFilter
178  {
179  virtual bool AcceptElementQueryResult (ElementQueryResult const&) {return true;}
180  virtual bool AnyClientSideFilter () const {return false;}
181  };
183 
184 /*---------------------------------------------------------------------------------**/
187 struct ElementQueryResultFilterPipeline : IElementQueryResultFilter
189  {
190  IElementQueryResultFilter& m_f1;
191  IElementQueryResultFilter& m_f2;
192 
193  ElementQueryResultFilterPipeline (IElementQueryResultFilter& f1, IElementQueryResultFilter& f2) : m_f1(f1), m_f2(f2) {;}
194 
195  // IElementQueryResultFilter:
196  virtual bool AcceptElementQueryResult (ElementQueryResult const& eq)
197  {
198  return m_f1.AcceptElementQueryResult(eq) && m_f2.AcceptElementQueryResult(eq);
199  }
200  virtual bool AnyClientSideFilter() const
201  {
202  return m_f1.AnyClientSideFilter() || m_f2.AnyClientSideFilter();
203  }
204  };
206 
207 typedef bstdmap<ElementId, ElementQueryResult> T_ElementIdToElementQueryResultMapType;
208 
209 /*=================================================================================**/
217 {
219 public:
220 
224 
225  struct const_iterator : std::iterator<std::forward_iterator_tag, value_type const>
226  {
227  private:
229  T_Map::const_iterator m_it;
230  const_iterator (T_Map::const_iterator const&);
231  public:
232  DGNPLATFORM_EXPORT const_iterator& operator++();
233  DGNPLATFORM_EXPORT value_type const& operator*() const;
234  DGNPLATFORM_EXPORT bool operator != (const_iterator const &) const;
235  DGNPLATFORM_EXPORT bool operator == (const_iterator const & r) const {return !(*this != r);}
236  };
237 
240  const_iterator begin () const;
241 
244  const_iterator end () const;
245 
249  ElementQueryResult const* GetElement (ElementId) const;
250 
252 
257  ModelId GetModelId () const;
258 
262  DgnModelP GetDgnModelP () const;
265  DgnFileP GetDgnFileP () const;
266 
269  ElementQueryResultsForFile* GetResultsForFile () const;
270 
272 
273 }; // ElementQueryResultsForModel
274 
275 typedef bstdmap<ModelId, ElementQueryResultsForModel> T_ModelIdToElementQueryResultsForModelMapType;
276 
277 /*=================================================================================**/
283 class ElementQueryResultsForFile : public RefCounted<IRefCounted>
284 {
286 
287 private:
288  virtual void MakeClassAbstract() = 0;
289 public:
290 public:
291 
294  DgnFileP GetDgnFileP () const;
295 
299 
300  struct const_iterator : std::iterator<std::forward_iterator_tag, value_type const>
301  {
302  private:
304  T_Map::const_iterator m_it;
305  const_iterator (T_Map::const_iterator const&);
306  public:
307  DGNPLATFORM_EXPORT const_iterator& operator++();
308  DGNPLATFORM_EXPORT value_type const& operator*() const;
309  DGNPLATFORM_EXPORT bool operator != (const_iterator const &) const;
310  DGNPLATFORM_EXPORT bool operator == (const_iterator const & r) const {return !(*this != r);}
311  };
312 
314 
317  const_iterator begin () const;
318 
321  const_iterator end () const;
322 
325  const_iterator FindModelById (ModelId) const;
326 
329  ElementQueryResultsForModel& GetResultsForModel (ModelId);
330 
332 
335 
339  ElementChangeType GetChangeType (ModelId, ElementId) const;
340 
344  ElementQueryResult const* GetElement (ModelId, ElementId) const;
345 
349  ElementHandle GetElemHandle (ModelId, ElementId) const;
350 
353  UInt32 ComputeElementCount() const;
354 
356 
357 }; // ElementQueryResultsForFile
358 
359 /*=================================================================================**/
367 {
368 private:
369 private:
370  virtual void MakeClassAbstract() = 0;
371 public:
372 public:
373 }; // ElementsAsOfQuery
374 
375 /*=================================================================================**/
403 {
404 private:
405  DgnFileP m_file;
406 
407  /*-----------------------------------------------------------------------------------
408  Public Member functions
409  -----------------------------------------------------------------------------------*/
410 
411 public:
414  explicit
416 
418  DesignHistory ();
419 
421  DgnFileP GetDgnFileP() const {return m_file;}
422 
423 // ##########################################################################
425 
426 // ##########################################################################
427 
431 static bool ContainsHistory (DgnFileR);
432 
440 static StatusInt InitializeHistory
441  (
442  DgnFileR file,
443  WChar const* comment
444  );
445 
452 static StatusInt RemoveHistory (DgnFileR);
453 
476  StatusInt CombineRevisions
477  (
478  RevisionNumber const& start,
479  RevisionNumber const& end,
480  CommitInfo const& parms
481  );
482 
487  StatusInt DeleteEarlyRevisions
488  (
489  RevisionNumber const& tooOld
490  );
491 
494  StatusInt UpdateRevision
495  (
496  RevisionNumber const& revNo,
497  WChar const* user,
498  WChar const* desc
499  );
500 
501 // ##########################################################################
503 // ##########################################################################
504 
505 // ##########################################################################
507 
508 // ##########################################################################
509 
513  RevisionNumber GetTip () const;
514 
519  RevisionNumber GetNextPossibleRevisionNumber (DgnHistory::RevisionNumber const& r);
520 
523  RevisionNumber GetEarliest () const;
524 
527  {
530  };
531 
535  StatusInt GetRevisionNumbers
536  (
537  RevisionNumbersForFile& revNos,
538  RevisionNumber const& startRevNo = RevisionNumber(),
539  RevisionNumber const& endRevNo = RevisionNumber()
540  ) const;
541 
545  StatusInt GetRevisions
546  (
547  T_RevisionInfoVector& revs,
548  RevisionNumbersForFile& nums,
549  ElementChangeRecordFilter const* ssfilter = NULL,
550  bool removeRejectedRevisions = false
551  ) const;
552 
557  StatusInt GetTags
558  (
559  bvector<TagDefinition>& tags
560  );
561 
567  StatusInt GetTag (DgnHistory::RevisionNumber* revNo, WChar const* tag);
568 
575  StatusInt SetTag (WChar const* tag, RevisionNumber const& revNo, bool replaceExisting);
576 
581  StatusInt RemoveTag (WChar const* tag);
582 
583 
584 // ##########################################################################
586 // ##########################################################################
587 
588 // ##########################################################################
590 
591 // ##########################################################################
592 
597  RefCountedPtr<ElementsAsOfQuery> QueryPreChangeState
598  (
599  RevisionNumbersForFile const& range
600  );
601 
606  RefCountedPtr<ElementsAsOfQuery> QueryPostChangeState
607  (
608  RevisionNumbersForFile const& range
609  );
610 
615  StatusInt QueryElementAsOf
616  (
617  EditElementHandleR historicalVersion,
618  ModelId modelId,
619  ElementId elementId,
620  RevisionNumber const& rev
621  );
622 
623 
624 // ##########################################################################
626 // ##########################################################################
627 
628 // ##########################################################################
630 
631 // ##########################################################################
632 
640  bool CheckUncommittedChanges (bool force = false) const;
641 
656  StatusInt Commit
657  (
658  RevisionInfo* result,
659  CommitInfo const& parms,
660  bool ignoreVersion = false
661  ) const;
662 
663 // ##########################################################################
665 // ##########################################################################
666 
667 
668 // ##########################################################################
670 
671 
674  WString GetRevisionNumberFormat () const;
675 
768  void SetRevisionNumberFormat (WChar const*);
769 
772  WString FormatRevisionNumber (DgnHistory::RevisionNumber const&);
773 
776  static
777  WString FormatRevisionNumber (DgnHistory::RevisionNumber const&, WChar const*);
778 
784  RevisionNumber ParseRevisionNumber (WChar const* str, WChar const* fmt = NULL) const;
785 
787 // ##########################################################################
788 
789 // ##########################################################################
790 // Miscellaneous functions, not grouped or highlighted in the doc.
791 
800 static
801  StatusInt ExtractModelElementInfo
802  (
803  ModelInfoR pInfo, // <=
804  MSElementDescrCP modelElement,
805  DgnFileP dgnFile
806  );
807 
815  StatusInt CheckFormatVersion (bool prompt) const;
816 
823  static
824  StatusInt GetLastError (WStringR details);
825 
826 }; // DesignHistory
827 
828 /*---------------------------------------------------------------------------------*/
833 typedef enum
834  {
866 
867 }; // DgnHistory
869 
T_RevisionNumberVectorType const & GetRevisions() const
Query all of the revisions identified by this object.
Definition: DesignHistory.h:97
A readonly "handle" to an element.
Definition: ElementHandle.h:113
Provides access to the design history of a specified file.
Definition: DesignHistory.h:402
#define END_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:69
bstdmap< ElementId, ElementQueryResult > T_ElementIdToElementQueryResultMapType
Definition: DesignHistory.h:207
A set of revision numbers pertaining to the design history of a specified file.
Definition: DesignHistory.h:76
Can the user change the revision number discontinuously?
Definition: DesignHistory.h:862
wchar_t WChar
Definition: Bentley.h:223
Can the user change revision descriptions in design history?
Definition: DesignHistory.h:854
Automatically upgrade design history to the newest version when modifying?
Definition: DesignHistory.h:856
Can the user change the revision format?
Definition: DesignHistory.h:860
Can the user delete early revisions from design history?
Definition: DesignHistory.h:848
iterator begin()
Definition: stdcxx/bstdmap.h:178
Definition: ModelInfo.h:27
The definition of a tag.
Definition: DesignHistory.h:526
A history revision number.
Definition: DgnHistory.h:26
iterator end()
Definition: stdcxx/bstdmap.h:186
A writeable "handle" to an MSElement.
Definition: ElementHandle.h:470
WString tag
[out] tag symbol
Definition: DesignHistory.h:528
#define DGNPLATFORM_EXPORT
Definition: DgnPlatform/ExportMacros.h:58
A DgnFile is an in-memory representation of a physical file, regardless of its format.
Definition: DgnFile.h:308
ElementQueryResult value_type
Definition: DesignHistory.h:223
ElementQueryResultsForModel value_type
Definition: DesignHistory.h:298
Template to simplify the task of writing a class that implements the reference-counting pattern...
Definition: RefCounted.h:90
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
#define NULL
Definition: Bentley.h:157
bstdmap & operator=(const bstdmap &__rhs)
Definition: stdcxx/bstdmap.h:170
Documents a set of changes in design history.
Definition: DgnHistory.h:126
struct DgnPlatform::MSElementDescr const * MSElementDescrCP
Definition: DgnPlatform.h:390
bool operator<(const basic_string< _CharT, _Traits, _Allocator > &__lhs, const basic_string< _CharT, _Traits, _Allocator > &__rhs)
Definition: basic_string.h:1326
DgnFileP GetDgnFileP() const
Query the DgnFile that contains the revisions identified by this object.
Definition: DesignHistory.h:93
HistoryCapabilities
History capabilities specific to a file and/or capabilities enabled in the current configuration...
Definition: DesignHistory.h:833
A DgnModel represents a DgnModel in memory.
Definition: DgnModel.h:236
bvector< RevisionNumber > T_RevisionNumberVectorType
Definition: DesignHistory.h:44
A shared pointer template for reference-counted objects.
Definition: RefCounted.h:119
Can the user commit changes to design history?
Definition: DesignHistory.h:842
Copies of elements in a historical state for a given file.
Definition: DesignHistory.h:283
Copies of elements in a historical state for a given model.
Definition: DesignHistory.h:216
Can the user combine revisions?
Definition: DesignHistory.h:840
Int32 ModelId
Definition: DgnPlatformBaseType.r.h:84
DgnFileP GetDgnFileP() const
Query the DgnFile to which this applies.
Definition: DesignHistory.h:421
Can the user browse design history?
Definition: DesignHistory.h:844
#define BEGIN_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:68
DVec3d operator*(Transform const &transform, DVec3d const &vector)
operator overload for multiplication of a transform and a vector li>The vector appears on the left as...
Can the user add tags?
Definition: DesignHistory.h:852
bool operator!=(const BentleyAllocator< _Ty > &, const BentleyAllocator< _Other > &)
Definition: BentleyAllocator.h:152
Can the user delete design history?
Definition: DesignHistory.h:846
Interface to filter query results at the element level.
Definition: DesignHistory.h:166
Performs a query to get the historical state of elements.
Definition: DesignHistory.h:366
int StatusInt
Definition: Bentley.h:222
UInt64 ElementId
Definition: DgnPlatformBaseType.r.h:83
Can the user turn on tracing in design history functions?
Definition: DesignHistory.h:850
bstdmap< ModelId, ElementQueryResultsForModel > T_ModelIdToElementQueryResultsForModelMapType
Definition: DesignHistory.h:275
RevisionNumber revNo
[in] tag value
Definition: DesignHistory.h:529
Can the user initialize design history?
Definition: DesignHistory.h:838
const_iterator iterator
only const iteration is possible
Definition: DesignHistory.h:313
Does the master file format support design history?
Definition: DesignHistory.h:836
bvector< RevisionInfo > T_RevisionInfoVector
Definition: DgnHistory.h:151
Definition: DesignHistoryRestore.h:56
When used as a mask, identifies all capabilities.
Definition: DesignHistory.h:864
Can the user change revision author in design history?
Definition: DesignHistory.h:858
ElementChangeType
The kinds of changes recorded in design history.
Definition: DgnPlatform.h:659
Holds the result of querying design history for the historical version of an element.
Definition: DesignHistory.h:123
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.