LevelCache.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 #include <list>
10 #include "LevelTypes.h"
11 #include "DependencyManager.h"
12 #include "DgnFile.h"
13 #include "IViewDraw.h"
14 
15 
16 DGNPLATFORM_TYPEDEFS (LsDefinition)
17 
19 
20 struct DgnAttachment;
21 struct LevelDefinitionReadNameMgr;
22 struct LevelTableHandler;
23 struct LevelTableChangeMergingExtension;
24 struct LevelEntryHandler;
25 struct LevelTableEntryChangeMergingExtension;
26 struct LooseLevel;
27 struct TxnElementAddOptions;
28 
29 /*---------------------------------------------------------------------------------**/
92 
94 typedef bset<byte>::iterator T_LevelIdToDefinitionMapIterator;
95 
96 
97 //=======================================================================================
99 // @bsiclass Bentley Systems
100 // NOTE: These originated from MSGID_errorXX in leveltableids.h in 08.11.09
101 //=======================================================================================
103 {
104  None = BSISUCCESS,
105  Error = BSIERROR,
106  TableIsReadOnly = 2,
107  LevelIsReadOnly = 4,
108  LevelNameIsNull = 7,
109  LevelNameIsInvalid = 8,
111  LevelIsUsed = 11,
112  LevelCodeIsDuplicate = 23,
113  LevelIdIsDuplicate = 46,
115  CannotFindLevel = 56,
118  LevelNullId = 92,
119  NoLevels = 1000,
121 };
122 
126 #define LEVEL_NAME_DISPLAY_FORMAT_STRING L"N"
127 #define LEVEL_CODE_DISPLAY_FORMAT_STRING L"C"
128 #define LEVEL_DESCRIPTION_DISPLAY_FORMAT_STRING L"D"
129 
133 #define LEVEL_NAME_DISPLAY_FORMAT L'N'
134 #define LEVEL_CODE_DISPLAY_FORMAT L'C'
135 #define LEVEL_DESCRIPTION_DISPLAY_FORMAT L'D'
136 #define LEVEL_ID_DISPLAY_FORMAT L'I'
137 
138 
139 //=======================================================================================
142 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
143 // @bsiclass Bentley Systems
144 //=======================================================================================
146 {
147 protected:
149 
150 public:
153 
155  DGNPLATFORM_EXPORT DgnFileP GetDefinitionFile () const;
156 
158  DGNPLATFORM_EXPORT DgnModelP GetDefinitionModel () const;
159 }; // LevelDefinitionStyleBase
160 
161 //=======================================================================================
168 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
169 // @bsiclass Bentley Systems
170 //=======================================================================================
172 {
174 private:
175  UInt32 m_color;
176 
177 public:
181  DGNPLATFORM_EXPORT LevelDefinitionColor& operator= (LevelDefinitionColor const& r);
182 
184  DGNPLATFORM_EXPORT UInt32 GetColor () const;
185 
187  DGNPLATFORM_EXPORT bool operator== (LevelDefinitionColor const&) const;
188 
190  DGNPLATFORM_EXPORT bool operator!= (LevelDefinitionColor const& rhs) const;
191 }; // LevelDefinitionColor
192 
193 //=======================================================================================
196 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
197 // @bsiclass Bentley Systems
198 //=======================================================================================
200 {
202 private:
203  int m_style;
204  LineStyleParamsCP m_styleParams;
205 
206 public:
210  DGNPLATFORM_EXPORT LevelDefinitionLineStyle& operator= (LevelDefinitionLineStyle const& r);
211 
213  DGNPLATFORM_EXPORT int GetStyle () const;
214 
216  DGNPLATFORM_EXPORT bool operator== (LevelDefinitionLineStyle const&) const;
218  DGNPLATFORM_EXPORT bool operator!= (LevelDefinitionLineStyle const& rhs) const;
219 
221  DGNPLATFORM_EXPORT bool HasStyleParams () const;
222 
224  DGNPLATFORM_EXPORT LineStyleParamsCP GetStyleParamsP () const;
225 
228  DGNPLATFORM_EXPORT bool GetStyleParams (LineStyleParamsR sp) const;
229 
230 
231 }; // LevelDefinitionLineStyle
232 
233 //=======================================================================================
236 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
237 // @bsiclass Bentley Systems
238 //=======================================================================================
240 {
242 protected:
244 
245 public:
250 
252 
254  DGNPLATFORM_EXPORT ElementId GetId () const;
255 };
256 
257 //=======================================================================================
259 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
260 // @bsiclass Bentley Systems
262 {
264 
265 
268  DGNPLATFORM_EXPORT LevelDefinitionMaterial& operator= (LevelDefinitionMaterial const& r);
269 
271  DGNPLATFORM_EXPORT bool operator== (LevelDefinitionMaterial const&) const;
272 
273  DGNPLATFORM_EXPORT bool operator!= (LevelDefinitionMaterial const& rhs) const;
274 
275 };
276 
277 //=======================================================================================
279 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
280 // @bsiclass Bentley Systems
281 //=======================================================================================
283 {
285 
286 
289  DGNPLATFORM_EXPORT LevelDefinitionPlotStyle& operator= (LevelDefinitionPlotStyle const& r);
290 
292  DGNPLATFORM_EXPORT bool operator== (LevelDefinitionPlotStyle const&) const;
293 
294  DGNPLATFORM_EXPORT bool operator!= (LevelDefinitionPlotStyle const& rhs) const;
295 
296 };
297 
298 /*=================================================================================**/
373 struct LevelHandle : std::iterator<std::forward_iterator_tag, LevelHandle const>
374 {
375 private:
376 protected:
380 public:
381 
382 
385 
392 
394 
397 
399 DGNPLATFORM_EXPORT LevelId GetLevelId () const;
400 
402 DGNPLATFORM_EXPORT WCharCP GetDescription () const;
403 
405 DGNPLATFORM_EXPORT WCharCP GetName () const;
406 
408 DGNPLATFORM_EXPORT BentleyStatus GetDisplayName (WStringR displayNameStr) const;
409 
412 DGNPLATFORM_EXPORT BentleyStatus FormatDisplayName (WStringR displayNameStr, WCharCP formatString) const;
413 
415 DGNPLATFORM_EXPORT LevelCode GetLevelCode () const;
416 
418 DGNPLATFORM_EXPORT LevelCache* GetLevelCacheP () const;
419 
423 DGNPLATFORM_EXPORT bool IsValid () const;
424 
426 DGNPLATFORM_EXPORT bool IsAlias () const;
427 
428 
432 DGNPLATFORM_EXPORT LevelCacheErrorCode GetStatus () const;
433 
435 
439 
441 DGNPLATFORM_EXPORT bool operator== (LevelHandle const&) const;
443 DGNPLATFORM_EXPORT bool operator!= (LevelHandle const&) const;
444 
454 DGNPLATFORM_EXPORT bool EqualLevelData (BitMaskP differences, LevelHandle const& sourceLevel, BitMaskCP attributesToCompare) const;
456 
460 DGNPLATFORM_EXPORT LevelHandle& operator++ ();
462 
464 DGNPLATFORM_EXPORT LevelHandle const* operator-> () const;
465 
468 
470 DGNPLATFORM_EXPORT LevelDefinitionColor GetOverrideColor () const;
472 DGNPLATFORM_EXPORT LevelDefinitionLineStyle GetOverrideLineStyle () const;
474 DGNPLATFORM_EXPORT UInt GetOverrideWeight () const;
476 DGNPLATFORM_EXPORT LevelDefinitionMaterial GetOverrideMaterial () const;
479 DGNPLATFORM_EXPORT LevelDefinitionColor GetByLevelColor () const;
481 DGNPLATFORM_EXPORT LevelDefinitionLineStyle GetByLevelLineStyle () const;
483 DGNPLATFORM_EXPORT UInt GetByLevelWeight () const;
485 DGNPLATFORM_EXPORT LevelDefinitionMaterial GetByLevelMaterial () const;
487 DGNPLATFORM_EXPORT bool GetOverrideColorOn () const;
489 DGNPLATFORM_EXPORT bool GetOverrideLineStyleOn () const;
491 DGNPLATFORM_EXPORT bool GetOverrideWeightOn () const;
493 DGNPLATFORM_EXPORT bool GetOverrideMaterialOn () const;
495 DGNPLATFORM_EXPORT bool GetDisplay () const;
497 DGNPLATFORM_EXPORT bool GetPlot () const;
499 DGNPLATFORM_EXPORT bool GetByCell () const;
501 DGNPLATFORM_EXPORT bool GetSnap () const;
503 DGNPLATFORM_EXPORT bool GetReadOnly () const;
505 DGNPLATFORM_EXPORT bool GetHidden () const;
510 DGNPLATFORM_EXPORT LevelElementAccess GetElementAccess () const;
512 DGNPLATFORM_EXPORT bool GetFrozen () const;
514 DGNPLATFORM_EXPORT bool GetLocate () const;
516 DGNPLATFORM_EXPORT bool GetCodeAutoGenerated () const;
518 DGNPLATFORM_EXPORT Int32 GetDisplayPriority () const;
520 DGNPLATFORM_EXPORT double GetTransparency () const;
522 DGNPLATFORM_EXPORT LevelDefinitionPlotStyle GetPlotStyle () const;
523 
525 
526 }; // LevelHandle
527 
528 //=======================================================================================
537 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
538 // @bsiclass Bentley Systems
539 //=======================================================================================
541 {
543 private:
544 public:
545 
546 
549 
552 
554 DGNPLATFORM_EXPORT EditLevelHandle (EditLevelHandle const&);
555 
557 DGNPLATFORM_EXPORT explicit EditLevelHandle (LevelHandle const&);
558 
559 
561 DGNPLATFORM_EXPORT bool IsDirty () const;
562 
564 
567 
574 
581 DGNPLATFORM_EXPORT LevelCacheErrorCode SetLevelCode (LevelCode levelCode, bool autoGenerated);
582 
585 DGNPLATFORM_EXPORT bool SetDescription (WCharCP);
586 
588 
591 
593 DGNPLATFORM_EXPORT EditLevelHandle& operator= (EditLevelHandle const&);
594 
602 DGNPLATFORM_EXPORT bool CopyLevelData (LevelHandle const& sourceLevel, BitMaskCP m=NULL);
603 
605 
608 
610 DGNPLATFORM_EXPORT bool SetOverrideColor (LevelDefinitionColor const&);
617 DGNPLATFORM_EXPORT bool SetOverrideLineStyle (LsEntryCR l, LineStyleParamsCP p, DgnFileR f);
619 DGNPLATFORM_EXPORT bool SetOverrideWeight (UInt);
621 DGNPLATFORM_EXPORT bool SetOverrideMaterial (LevelDefinitionMaterial const&);
623 DGNPLATFORM_EXPORT bool SetByLevelColor (LevelDefinitionColor const&);
630 DGNPLATFORM_EXPORT bool SetByLevelLineStyle (LsEntryCR l, LineStyleParamsCP p, DgnFileR f);
632 DGNPLATFORM_EXPORT bool SetByLevelWeight (UInt);
634 DGNPLATFORM_EXPORT bool SetByLevelMaterial (LevelDefinitionMaterial const&);
636 DGNPLATFORM_EXPORT bool SetOverrideColorOn (bool);
638 DGNPLATFORM_EXPORT bool SetOverrideLineStyleOn (bool);
640 DGNPLATFORM_EXPORT bool SetOverrideWeightOn (bool);
642 DGNPLATFORM_EXPORT bool SetOverrideMaterialOn (bool);
644 DGNPLATFORM_EXPORT bool SetDisplay (bool);
646 DGNPLATFORM_EXPORT bool SetPlot (bool);
648 DGNPLATFORM_EXPORT bool SetByCell (bool);
650 DGNPLATFORM_EXPORT bool SetSnap (bool);
652 DGNPLATFORM_EXPORT bool SetHidden (bool);
658 DGNPLATFORM_EXPORT bool SetElementAccess (LevelElementAccess access);
660 DGNPLATFORM_EXPORT bool SetFrozen (bool);
662 DGNPLATFORM_EXPORT bool SetLocate (bool);
663 
665 DGNPLATFORM_EXPORT bool SetDisplayPriority (Int32);
667 DGNPLATFORM_EXPORT bool SetTransparency (double);
668 
670 DGNPLATFORM_EXPORT bool SetPlotStyle (LevelDefinitionPlotStyle const&);
671 
673 DGNPLATFORM_EXPORT void EditElementRelatedProperties (PropertyContextR context);
674 
676 
677 }; // EditLevelHandle
678 
679 
680 
681 //=======================================================================================
699 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
700 // @bsiclass Bentley Systems
701 //=======================================================================================
703 {
704 
705 public:
706 
707 
714  DGNPLATFORM_EXPORT LevelHandle GetLevel (LevelId levelId, bool includeLibraries=false) const;
715 
720  DGNPLATFORM_EXPORT LevelHandle GetLevelByCode (LevelCode levelCode, bool includeLibraries=false) const;
721 
726  DGNPLATFORM_EXPORT LevelHandle GetLevelByName (WCharCP levelName, bool includeLibraries=false) const;
727 
732  DGNPLATFORM_EXPORT LevelHandle GetLevelByDisplayName (WCharCP levelDisplayName, bool includeLibraries=false) const;
733 
736 
743 
746  DGNPLATFORM_EXPORT size_t GetLevelCount (bool includeLibraries=false) const;
747 
749  DGNPLATFORM_EXPORT LevelId ComputeHighestUsedLevelId () const;
751  DGNPLATFORM_EXPORT LevelCode ComputeHighestUsedLevelCode () const;
753  DGNPLATFORM_EXPORT LevelId GetLowestAvailableLevelId () const;
755  DGNPLATFORM_EXPORT LevelCode GetLowestAvailableLevelCode () const;
756 
760  DGNPLATFORM_EXPORT LevelCacheErrorCode GetLastModifiedTimeForLevelDefinitions (UInt32& timeStampOut) const;
761 
763  DGNPLATFORM_EXPORT bool IsReadOnly () const;
764 
771  DGNPLATFORM_EXPORT bool EqualLevelData (LevelCache const& rhs, bool compareElementIds = false, BitMaskCP compareAttributesMask = NULL) const;
772 
775  DGNPLATFORM_EXPORT bool IsHiddenStatePersisted () const;
778  DGNPLATFORM_EXPORT void SetPersistHiddenState (bool persistStateIn);
779 
780 };
781 
782 
783 //=======================================================================================
785 //=======================================================================================
787  {
788  Always = 0,
789  IfNewChangesOnly = 1,
790  Never = 2,
791  };
792 
793 //=======================================================================================
798 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
799 // @bsiclass Bentley Systems
800 //=======================================================================================
802 {
803 public:
807 
809  DGNPLATFORM_EXPORT bool IsDirty () const;
810 
815  DGNPLATFORM_EXPORT void EditProperties (PropertyContextR context, EditPropertiesChangeWrite writeChanges);
816 
817 
818 };
819 
820 
823 typedef bvector<FileLevelCachePtr> T_LevelCachePtrVector;
824 
825 //=======================================================================================
847 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
848 // @bsiclass Bentley Systems
849 //=======================================================================================
851 {
852 private:
853  virtual void MakeClassAbstract() = 0;
854 public:
855 public:
857 
859  DGNPLATFORM_EXPORT DgnFileR GetDgnFileR () const;
860 
871  // Invokes _OnCreateLevel, _OnUseLevelId, and _UseNextLevelCode
872  DGNPLATFORM_EXPORT EditLevelHandle CreateLevel (WCharCP levelName, LevelCode levelCode, LevelId idIn);
873 
875  DGNPLATFORM_EXPORT EditLevelHandle CreateDefaultLevel ();
876 
890  // Invokes _OnCopyLevel after copying the level
891  DGNPLATFORM_EXPORT EditLevelHandle CopyLevel (LevelHandle const& source, bool replaceDuplicateLevelCode=false);
892 
903  // Invokes _OnRemoveLevel before removing the level. The level is not removed if _OnRemoveLevel returns non-zero.
905 
907  DGNPLATFORM_EXPORT bool SetLevelReadOnly (LevelHandle&, bool);
908 
911  DGNPLATFORM_EXPORT LevelId GetHighestUsedLevelId (bool includeLibraries=false) const;
912 
914  DGNPLATFORM_EXPORT LevelCode GetHighestUsedLevelCode() const;
915 
918  DGNPLATFORM_EXPORT bool IsLevelUsedInModel (DgnModelRefP, LevelId) const;
921  DGNPLATFORM_EXPORT bool IsLevelUsedInFile (LevelId) const;
922 
924  DGNPLATFORM_EXPORT T_LevelCachePtrVector* GetLibraries () const;
925 
926 };
927 
928 //=======================================================================================
952 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
953 // @bsiclass Bentley Systems
954 //=======================================================================================
956 {
957 private:
958  virtual void MakeClassAbstract() = 0;
959 public:
960 public:
961 
963  DGNPLATFORM_EXPORT DgnAttachmentR GetDgnAttachmentR () const;
964 
965 };
966 
967 
968 
969 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
970 // @bsiclass Bentley Systems
972 {
974 DGNPLATFORM_EXPORT static bool ContainsInvalidCharacters (WCharCP);
977 DGNPLATFORM_EXPORT static void ReplaceInvalidCharacters (WCharP, WChar);
980 DGNPLATFORM_EXPORT static void ReplaceInvalidCharacters (WStringR, WChar);
981 
982 }; // LevelUtils
983 
984 
986 
1193 
LevelCacheErrorCode m_status
Definition: LevelCache.h:377
The level is in a library, and cannot be edited.
The name is already used by a level in this cache.
Represents a PlotStyleID used by a level.
Definition: LevelCache.h:282
#define END_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:69
struct DgnPlatform::LineStyleParams const * LineStyleParamsCP
Definition: DgnPlatform.h:360
wchar_t * WCharP
Definition: Bentley.h:225
unsigned int UInt
Definition: Bentley.r.h:140
A level element with levelId - LEVEL_NULL_ID is in the level table element descriptor and that level ...
UInt32 LevelCode
Definition: DgnPlatform.h:623
wchar_t WChar
Definition: Bentley.h:223
Locate interiors of regions, surfaces, and solids even in wireframe and even with fill display off...
Class for enumerating the common properties of elements such as color and level and changing those pr...
Definition: PropertyContext.h:597
const_iterator iterator
only const iteration is possible
Definition: LevelCache.h:735
Open for write access.
UInt32 LevelId
Definition: DgnPlatformBaseType.r.h:85
The LevelCode is already used by a level in this cache.
iterator begin()
Definition: stdcxx/bstdmap.h:178
Attempt to query a FileLevelCache for a DgnAttachment that is not resolved (not found or not read)...
Write changes to the file only if there were previously no unsaved changes.
DgnFileP m_definitionFile
Definition: LevelCache.h:148
Base class for style that is used by a level.
Definition: LevelCache.h:145
Definition: LevelCache.h:971
iterator end()
Definition: stdcxx/bstdmap.h:186
The LevelId is already used by a level in this cache.
Represents a line style used by a level.
Definition: LevelCache.h:199
Read-only access to a level definition.
Definition: LevelCache.h:373
T_LevelIdToDefinitionMapIterator m_levelIterator
Definition: LevelCache.h:378
#define DGNPLATFORM_EXPORT
Definition: DgnPlatform/ExportMacros.h:58
struct DgnPlatform::LsEntry const & LsEntryCR
Definition: DgnPlatform.h:368
A DgnFile is an in-memory representation of a physical file, regardless of its format.
Definition: DgnFile.h:308
wchar_t const * WCharCP
Definition: Bentley.h:224
Represents a material used by a level.
Definition: LevelCache.h:261
uint32_t UInt32
Definition: Bentley.r.h:128
#define NULL
Definition: Bentley.h:157
bstdmap & operator=(const bstdmap &__rhs)
Definition: stdcxx/bstdmap.h:170
bset< byte >::iterator T_LevelIdToDefinitionMapIterator
Definition: LevelCache.h:94
bvector< FileLevelCachePtr > T_LevelCachePtrVector
Definition: LevelCache.h:823
LevelCacheP m_levelCache
Definition: LevelCache.h:379
LevelHandle const_iterator
Definition: LevelCache.h:734
A DgnModel represents a DgnModel in memory.
Definition: DgnModel.h:236
Provides access to levels used by elements in a referenced model.
Definition: LevelCache.h:955
EditPropertiesChangeWrite
Controls Change writing for LevelCache EditProperties method.
Definition: LevelCache.h:786
Parameters defining a line style.
Definition: IViewDraw.h:24
The name contains invalid characters. See LevelUtils::ContainsInvalidCharacters.
BentleyStatus
Definition: Bentley.h:208
A DgnModelRef provides access to a model in a Bentley::DgnPlatform::DgnFile.
Definition: DgnModelRef.h:172
int32_t Int32
Definition: Bentley.r.h:119
ElementId m_id
Definition: LevelCache.h:243
#define DGNPLATFORM_TYPEDEFS(_name_)
Definition: DgnPlatform.h:73
A shared pointer template for reference-counted objects.
Definition: RefCounted.h:119
Represents a color used by a level.
Definition: LevelCache.h:171
RefCountedPtr< FileLevelCache > FileLevelCachePtr
Smart pointer wrapper for FileLevelCache.
Definition: LevelCache.h:822
Definition: Bentley.h:211
The level cache is marked as read-only.
unsigned char byte
Definition: Bentley.r.h:144
A Bitmask holds a variable-sized array of bits.
Definition: BitMask.h:53
A level cache holds level definitions.
Definition: LevelCache.h:702
#define DEFINE_T_SUPER(B)
Definition: Bentley.h:167
There are no levels in the LevelCache.
#define BEGIN_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:68
A FileLevelCache contains the level definitions for a file.
Definition: LevelCache.h:850
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...
bool operator!=(const BentleyAllocator< _Ty > &, const BentleyAllocator< _Other > &)
Definition: BentleyAllocator.h:152
Abstract base class for persistent LevelCaches that support Write.
Definition: LevelCache.h:801
LevelCacheErrorCode
Error codes returned by LevelCache function.
Definition: LevelCache.h:102
A DgnAttachment represents a reference from one model to another, with transforming, clipping, and filtering applied.
Definition: DgnAttachment.h:192
Concrete class that can be used to implement the reference-counting pattern.
Definition: RefCounted.h:109
UInt64 ElementId
Definition: DgnPlatformBaseType.r.h:83
Read-write access to a level definition.
Definition: LevelCache.h:540
struct Bentley::BitMask const * BitMaskCP
Definition: DgnPlatform.h:134
Represents a style used by a level.
Definition: LevelCache.h:239
LevelElementAccess
Level Element Access Defines.
Definition: LevelTypes.h:79
An attempt was made to Write the LevelCache associated with a DgnAttachment that shares the FileLevel...
A string class that has many of the same capabilities as std::string, plus additional functions such ...
Definition: WString.h:51
Definition: Bentley.h:213
bool operator==(const BentleyAllocator< _Ty > &, const BentleyAllocator< _Other > &)
Definition: BentleyAllocator.h:146

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