CustomItemType.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 #pragma managed(push, off)
10 
11 #include <ECObjects/ECObjectsApi.h>
13 
14 
16 
53 /*---------------------------------------------------------------------------------**/
59 template<typename T_Impl> struct ItemTypeLibraryComponent
60  {
61 private:
62  T_Impl* m_impl;
63  ItemTypeLibraryP m_library;
64  ::UInt32 m_guid;
65  WString m_storedName;
66 
67 protected:
68 protected:
71  : m_impl(other.m_impl), m_library(other.m_library), m_guid(other.m_guid), m_storedName(other.m_storedName)
72  {
73  //
74  }
75 public:
77  ::UInt32 GetGuid() const { return m_guid; }
79  ItemTypeLibraryCR GetLibrary() const { return *m_library; }
81  ItemTypeLibraryR GetLibrary() { return *m_library; }
82  };
83 
84 /*---------------------------------------------------------------------------------**/
108 struct CustomProperty : ItemTypeLibraryComponent<ECN::ECProperty>
109  {
110 private:
111 public:
114 
115  /*---------------------------------------------------------------------------------**/
120  enum class Type
121  {
122  Boolean = 0,
123  DateTime = 1,
124  Double = 2,
125  Integer = 3,
126  Point = 4,
127  String = 5,
128 
129  Custom = 6
130  };
131 
132  DGNPLATFORM_EXPORT WCharCP GetInternalName() const;
133 
135  DGNPLATFORM_EXPORT Type GetType() const;
137  DGNPLATFORM_EXPORT CustomPropertyTypeCP GetCustomType() const;
139  DGNPLATFORM_EXPORT bool SupportsCustomType() const;
140 
142  DGNPLATFORM_EXPORT WCharCP GetName() const;
144  DGNPLATFORM_EXPORT bool IsArray() const;
145 
147  DGNPLATFORM_EXPORT bool SupportsUnits() const;
149  DGNPLATFORM_EXPORT DgnECUnit GetUnits() const;
150 
152  CustomPropertyContainerCR GetContainer() const { return const_cast<CustomPropertyP>(this)->GetContainer(); }
156  DGNPLATFORM_EXPORT UInt32 GetContainerId() const;
158  DGNPLATFORM_EXPORT UInt32 GetId() const;
159 
161  DGNPLATFORM_EXPORT Int32 GetPriority() const;
163  DGNPLATFORM_EXPORT bool IncrementPriority();
165  DGNPLATFORM_EXPORT bool DecrementPriority();
166 
168  DGNPLATFORM_EXPORT bool SetName (WCharCP name);
170  DGNPLATFORM_EXPORT bool SetIsArray (bool isArray);
171 
175  DGNPLATFORM_EXPORT bool SetType (Type type);
177  DGNPLATFORM_EXPORT bool SetType (CustomPropertyTypeCR customType);
179  DGNPLATFORM_EXPORT bool SetUnits (DgnECUnitCR unit);
180 
184  DGNPLATFORM_EXPORT bool GetDefaultValue (ECN::ECValueR v) const;
189  DGNPLATFORM_EXPORT bool SetDefaultValue (ECN::ECValueCR v);
190 
192  DGNPLATFORM_EXPORT bool CompareTo (CustomPropertyCR other) const;
193 
194  };
195 
196 /*---------------------------------------------------------------------------------**/
203  {
204 protected:
205 public:
206  DGNPLATFORM_EXPORT WCharCP GetInternalName() const;
207 public:
209  DGNPLATFORM_EXPORT WCharCP GetName() const;
211  DGNPLATFORM_EXPORT UInt32 GetId() const;
212 
215 
217  DGNPLATFORM_EXPORT size_t GetPropertyCount() const;
226 
228  CustomPropertyCP GetPropertyById (UInt32 id) const { return const_cast<CustomPropertyContainerP>(this)->GetPropertyById (id); }
230  CustomPropertyCP GetPropertyByName (WCharCP name) const { return const_cast<CustomPropertyContainerP>(this)->GetPropertyByName (name); }
232  DGNPLATFORM_EXPORT CustomPropertyP GetPropertyById (UInt32 id);
234  DGNPLATFORM_EXPORT CustomPropertyP GetPropertyByName (WCharCP name);
235 
237  DGNPLATFORM_EXPORT bool SetName (WCharCP name);
238 
240  DGNPLATFORM_EXPORT CustomPropertyP AddProperty (WCharCP name, bool forCopy = false);
242  DGNPLATFORM_EXPORT bool RemoveProperty (UInt32 id);
243  };
244 
245 /*---------------------------------------------------------------------------------**/
269  {
270 private:
271 public:
274 
276  DGNPLATFORM_EXPORT bool IsReferenced() const;
278  DGNPLATFORM_EXPORT bool CompareTo (CustomPropertyTypeCR other) const;
279  };
280 
281 
282 /*---------------------------------------------------------------------------------**/
305  {
306 private:
307 public:
309  ItemType (ItemTypeCR other);
310 
312  DGNPLATFORM_EXPORT bool CompareTo (ItemTypeCR other) const;
313 
315  DGNPLATFORM_EXPORT bool IsIdentifyingItem() const;
317  DGNPLATFORM_EXPORT bool SetIsIdentifyingItem (bool isIdentifyingItem);
319  DGNPLATFORM_EXPORT CustomPropertyCP GetLabelProperty() const;
321  DGNPLATFORM_EXPORT bool SetLabelProperty (CustomPropertyCP prop);
322  };
323 
324 /*---------------------------------------------------------------------------------**/
339  {
340 private:
341 public:
343  DGNPLATFORM_EXPORT WCharCP GetName() const;
345  DGNPLATFORM_EXPORT WCharCP GetInternalName() const;
347  DGNPLATFORM_EXPORT bool SetName (WCharCP name);
349  DGNPLATFORM_EXPORT ElementId GetId() const;
350 
352  DGNPLATFORM_EXPORT bool IsPersistent() const;
354  DGNPLATFORM_EXPORT DgnFileR GetDgnFile() const;
355 
357  DGNPLATFORM_EXPORT ItemTypeP AddItemType (WCharCP name, bool forCopy = false);
359  DGNPLATFORM_EXPORT CustomPropertyTypeP AddCustomType (WCharCP name, bool forCopy = false);
361  DGNPLATFORM_EXPORT bool RemoveItemType (UInt32 id);
363  DGNPLATFORM_EXPORT bool RemoveCustomType (UInt32 id);
364 
366  DGNPLATFORM_EXPORT bool Revert();
368  DGNPLATFORM_EXPORT bool Write();
371 
373  DGNPLATFORM_EXPORT bool CompareTo (ItemTypeLibraryCR other) const;
374 
377 
379  DGNPLATFORM_EXPORT size_t GetItemTypeCount() const;
388 
390  ItemTypeCP GetItemTypeByName (WCharCP name) const { return const_cast<ItemTypeLibraryP>(this)->GetItemTypeByName (name); }
392  ItemTypeCP GetItemTypeById (UInt32 id) const { return const_cast<ItemTypeLibraryP>(this)->GetItemTypeById (id); }
394  DGNPLATFORM_EXPORT ItemTypeP GetItemTypeByName (WCharCP name);
396  DGNPLATFORM_EXPORT ItemTypeP GetItemTypeById (UInt32 id);
397 
400 
402  DGNPLATFORM_EXPORT size_t GetCustomTypeCount() const;
404  DGNPLATFORM_EXPORT CustomTypeConstIterator CustomTypesBegin() const;
406  DGNPLATFORM_EXPORT CustomTypeConstIterator CustomTypesEnd() const;
408  DGNPLATFORM_EXPORT CustomTypeIterator CustomTypesBegin();
410  DGNPLATFORM_EXPORT CustomTypeIterator CustomTypesEnd();
411 
413  DGNPLATFORM_EXPORT CustomPropertyTypeCP GetCustomTypeByName (WCharCP name) const;
415  DGNPLATFORM_EXPORT CustomPropertyTypeCP GetCustomTypeById (UInt32 id) const { return const_cast<ItemTypeLibraryP>(this)->GetCustomTypeById (id); }
417  DGNPLATFORM_EXPORT CustomPropertyTypeP GetCustomTypeByName (WCharCP name);
419  DGNPLATFORM_EXPORT CustomPropertyTypeP GetCustomTypeById (UInt32 id);
420 
422  CustomPropertyContainerCP GetPropertyContainerByName (WCharCP name) const { return const_cast<ItemTypeLibraryP>(this)->GetPropertyContainerByName (name); }
424  CustomPropertyContainerCP GetPropertyContainerById (UInt32 id) const { return const_cast<ItemTypeLibraryP>(this)->GetPropertyContainerById (id); }
426  DGNPLATFORM_EXPORT CustomPropertyContainerP GetPropertyContainerByName (WCharCP name);
428  DGNPLATFORM_EXPORT CustomPropertyContainerP GetPropertyContainerById (UInt32 id);
429 
431  DGNPLATFORM_EXPORT CustomPropertyP GetPropertyByGuid (UInt32 guid);
433  CustomPropertyCP GetPropertyByGuid (UInt32 guid) const { return const_cast<ItemTypeLibraryP>(this)->GetPropertyByGuid (guid); }
434 
436  DGNPLATFORM_EXPORT static ItemTypeLibraryPtr FindByName (WCharCP name, DgnFileR dgnfile);
438  DGNPLATFORM_EXPORT static ItemTypeLibraryPtr FindBySchemaName (WCharCP schemaName, DgnFileR dgnfile);
440  DGNPLATFORM_EXPORT static ItemTypeLibraryPtr Create (WCharCP name, DgnFileR dgnfile, bool forCopy = false);
441 
443  DGNPLATFORM_EXPORT ItemTypeLibraryPtr CloneForFile (DgnFileR destFile, bool forReplacement = false) const;
444 
446  DGNPLATFORM_EXPORT static bool IsItemTypeSchema (WStringCR schemaName);
448  DGNPLATFORM_EXPORT static bool IsItemTypeSchema (ECN::ECSchemaCR schema);
449  };
450 
451 
452 /*---------------------------------------------------------------------------------**/
471  {
472 public:
473  struct Entry
474  {
475  private:
476 
477  ECN::ECSchemaPtr m_schema;
478  ItemTypeLibrariesCP m_collection;
479  mutable ItemTypeLibraryPtr m_library;
480  ElementId m_elementId;
481 
482  Entry (ECN::ECSchemaR schema, ItemTypeLibrariesCR collection, ElementId elemId) : m_schema (&schema), m_collection (&collection), m_elementId (elemId) { }
483  public:
485  Entry (Entry const& other) : m_schema(other.m_schema), m_collection(other.m_collection), m_library(other.m_library), m_elementId (other.m_elementId) { }
486 
488  WCharCP GetName() const { return m_schema->GetDisplayLabel().c_str(); }
490  WCharCP GetInternalName() const { return m_schema->GetName().c_str(); }
492  ECN::ECSchemaCR GetSchema() const { return *m_schema; }
494  ElementId GetId() const { return m_elementId; }
495 
497  DGNPLATFORM_EXPORT ItemTypeLibraryPtr ObtainLibrary() const;
498  };
499 private:
500 public:
503 
505  DGNPLATFORM_EXPORT DgnFileR GetDgnFile() const;
506 
512  DGNPLATFORM_EXPORT size_t size() const;
513 
515  DGNPLATFORM_EXPORT static ItemTypeLibrariesPtr Create (DgnFileR dgnfile);
516  };
517 
518 
519 /*---------------------------------------------------------------------------------**/
544  {
545 private:
546  struct ViewData
547  {
548  ViewGroupP m_viewGroup;
549  UInt32 m_viewIndex;
550  };
551 
552  DgnECHostType m_hostType;
553  bool m_readOnly;
554  bool m_scheduleItemsOnElement;
555  union
556  {
561  ViewData m_view;
562  };
563 
564 public:
566  DGNPLATFORM_EXPORT DgnFileR GetDgnFile() const;
567 
571  DGNPLATFORM_EXPORT CustomItemHost (EditElementHandleR eeh, bool scheduleItems = true);
577  DGNPLATFORM_EXPORT CustomItemHost (ViewGroupR viewGroup, UInt32 viewIndex);
578 
581 
583  DGNPLATFORM_EXPORT size_t GetCustomItems (DgnECInstanceVector& items) const;
585  DGNPLATFORM_EXPORT size_t GetCustomItemsCount() const;
587  DGNPLATFORM_EXPORT DgnECInstancePtr GetCustomItem (WCharCP libraryName, WCharCP itemTypeName) const;
589  DGNPLATFORM_EXPORT DgnECInstancePtr ApplyCustomItem (ItemTypeCR itemType) const;
591  DGNPLATFORM_EXPORT DgnECInstancePtr ApplyCustomItem (ItemTypeCR itemType, bool importLibrariesIfRequired) const;
593  DGNPLATFORM_EXPORT bool CopyCustomItems (CustomItemHostCR src, bool importLibrariesIfRequired = false) const;
594  };
595 
598 
599 #pragma managed(pop)
600 
struct DgnPlatform::ItemTypeLibraries const & ItemTypeLibrariesCR
Definition: DgnPlatform.h:584
CustomPropertyContainerCP GetPropertyContainerById(UInt32 id) const
Returns the CustomPropertyContainer with the specified ID within this library, or nullptr if no such ...
Definition: CustomItemType.h:424
DGNPLATFORM_EXPORT CustomPropertyTypeCP GetCustomTypeById(UInt32 id) const
Returns the CustomPropertyType with the specified ID within this library, or nullptr if no such Custo...
Definition: CustomItemType.h:415
ItemTypeCP GetItemTypeByName(WCharCP name) const
Returns the ItemType with the specified name, or nullptr if no such ItemType exists.
Definition: CustomItemType.h:390
bvector< CustomProperty >::iterator iterator
Definition: CustomItemType.h:214
#define END_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:69
Defines a named collection of CustomProperties which can be attached to elements, models...
Definition: CustomItemType.h:304
WCharCP GetName() const
Returns the user-visible name of the associated library.
Definition: CustomItemType.h:488
bvector< Entry >::const_iterator const_iterator
Definition: CustomItemType.h:501
Defines a collection of all of the ItemTypeLibrary objects stored within a DgnFile.
Definition: CustomItemType.h:470
RefCountedPtr< ECSchema > ECSchemaPtr
Definition: ECSchema.h:569
ECN::ECSchemaCR GetSchema() const
Returns the underlying ECSchema of the associated library.
Definition: CustomItemType.h:492
struct DgnPlatform::CustomPropertyContainer const * CustomPropertyContainerCP
Definition: DgnPlatform.h:583
ItemTypeCP GetItemTypeById(UInt32 id) const
Returns the ItemType with the specified ID, or nullptr if no such ItemType exists.
Definition: CustomItemType.h:392
signed 32-bit integer, unitless
DgnFileP m_file
Definition: CustomItemType.h:560
The in-memory representation of a schema as defined by ECSchemaXML.
Definition: ECSchema.h:1375
struct DgnPlatform::CustomPropertyType const & CustomPropertyTypeCR
Definition: DgnPlatform.h:581
ElementHandleCP m_eh
Definition: CustomItemType.h:557
Open for write access.
Definition: CustomItemType.h:473
struct Bentley::WString const & WStringCR
Definition: Bentley.h:239
iterator begin()
Definition: stdcxx/bstdmap.h:178
ItemTypeLibraryCR GetLibrary() const
Returns the ItemTypeLibrary containing this component.
Definition: CustomItemType.h:79
Defines a property within a CustomPropertyContainer.
Definition: CustomItemType.h:108
iterator end()
Definition: stdcxx/bstdmap.h:186
A writeable "handle" to an MSElement.
Definition: ElementHandle.h:470
ItemTypeLibraryR GetLibrary()
Returns the ItemTypeLibrary containing this component.
Definition: CustomItemType.h:81
#define DGNPLATFORM_EXPORT
Definition: DgnPlatform/ExportMacros.h:58
ECValue const & ECValueCR
Definition: ECObjects.h:46
A DgnFile is an in-memory representation of a physical file, regardless of its format.
Definition: DgnFile.h:308
Represents an object to which a ItemType can be attached to produce an "Item".
Definition: CustomItemType.h:543
wchar_t const * WCharCP
Definition: Bentley.h:224
Represents an instant in time, typically expressed as a date and time of day.
Definition: DateTime.h:28
ECSchema const & ECSchemaCR
Definition: ECObjects.h:53
ElementId GetId() const
Returns the ID of the element which hosts the associated library.
Definition: CustomItemType.h:494
bvector< ItemType >::iterator iterator
Definition: CustomItemType.h:376
uint32_t UInt32
Definition: Bentley.r.h:128
struct DgnPlatform::ItemType const * ItemTypeCP
Definition: DgnPlatform.h:580
CustomPropertyCP GetPropertyByName(WCharCP name) const
Returns the property with the specified name, or nullptr if no such property exists.
Definition: CustomItemType.h:230
BC__RW::__rw_debug_iter< bvector, const_pointer, pointer > const_iterator
Definition: stdcxx/bvector.h:115
Describes the units associated with a Dgn-based ECProperty.
Definition: DgnECTypes.h:198
BC__RW::__rw_debug_iter< bvector, pointer, pointer > iterator
Definition: stdcxx/bvector.h:112
Base class for a component of an ItemTypeLibrary, i.e., a CustomProperty or CustomPropertyContainer.
Definition: CustomItemType.h:59
A DgnModel represents a DgnModel in memory.
Definition: DgnModel.h:236
ItemTypeLibraryComponent(ItemTypeLibraryComponent const &other)
Copy constructor.
Definition: CustomItemType.h:70
Base class for an object which represents a named collection of CustomProperties within an ItemTypeLi...
Definition: CustomItemType.h:202
int32_t Int32
Definition: Bentley.r.h:119
ViewData m_view
Definition: CustomItemType.h:561
struct DgnPlatform::CustomPropertyContainer const & CustomPropertyContainerCR
Definition: DgnPlatform.h:583
struct DgnPlatform::ElementHandle const * ElementHandleCP
Definition: DgnPlatform.h:260
struct DgnPlatform::ItemTypeLibraries const * ItemTypeLibrariesCP
Definition: DgnPlatform.h:584
Type
Enumeration defining the set of supported property types.
Definition: CustomItemType.h:120
bvector< CustomPropertyType >::iterator CustomTypeIterator
Definition: CustomItemType.h:399
Variant-like object used to set and retrieve property values in ECInstances.
Definition: ECValue.h:73
Defines a named collection of ItemTypes and CustomPropertyTypes.
Definition: CustomItemType.h:338
struct DgnPlatform::CustomProperty const & CustomPropertyCR
Definition: DgnPlatform.h:582
CustomPropertyContainerCR GetContainer() const
Returns the CustomPropertyContainer to which the property belongs.
Definition: CustomItemType.h:152
Entry(Entry const &other)
Copy-constructor.
Definition: CustomItemType.h:485
#define BEGIN_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:68
ViewGroups contain information about the contents, positioning, and ordering of a user-specified coll...
Definition: DgnPlatform/ViewGroup.h:294
WCharCP GetInternalName() const
Returns the internal name of the associated library.
Definition: CustomItemType.h:490
Concrete class that can be used to implement the reference-counting pattern.
Definition: RefCounted.h:109
UInt64 ElementId
Definition: DgnPlatformBaseType.r.h:83
Defines a collection of properties which can serve as the "type" of a CustomProperty.
Definition: CustomItemType.h:268
EditElementHandleP m_eeh
Definition: CustomItemType.h:558
CustomPropertyContainerCP GetPropertyContainerByName(WCharCP name) const
Returns the CustomPropertyContainer with the specified name within this library, or nullptr if no suc...
Definition: CustomItemType.h:422
struct DgnPlatform::CustomItemHost const & CustomItemHostCR
Definition: DgnPlatform.h:585
::UInt32 GetGuid() const
Returns the GUID for this component within its ItemTypeLibrary.
Definition: CustomItemType.h:77
struct DgnPlatform::ItemTypeLibrary const & ItemTypeLibraryCR
Definition: DgnPlatform.h:579
SchemaDeleteStatus
Definition: DgnECProviders.h:196
bvector< ItemType >::const_iterator const_iterator
Definition: CustomItemType.h:375
bvector< CustomProperty >::const_iterator const_iterator
Definition: CustomItemType.h:213
DgnModelP m_model
Definition: CustomItemType.h:559
CustomPropertyCP GetPropertyById(UInt32 id) const
Returns the property with the specified ID, or nullptr if no such property exists.
Definition: CustomItemType.h:228
struct DgnPlatform::ElementHandle const & ElementHandleCR
Definition: DgnPlatform.h:260
const_iterator iterator
Definition: CustomItemType.h:502
bvector< CustomPropertyType >::const_iterator CustomTypeConstIterator
Definition: CustomItemType.h:398
DgnECHostType
Describes the underlying type on which an instance can be persisted.
Definition: DgnECInstance.h:78
size_type size() const
Definition: stdcxx/bstdmap.h:214
struct DgnPlatform::CustomPropertyType const * CustomPropertyTypeCP
Definition: DgnPlatform.h:581
struct DgnPlatform::CustomProperty const * CustomPropertyCP
Definition: DgnPlatform.h:582
CustomPropertyCP GetPropertyByGuid(UInt32 guid) const
Returns the CustomProperty with the specified GUID within this library, or nullptr if no such propert...
Definition: CustomItemType.h:433
bvector< DgnECInstancePtr > DgnECInstanceVector
Definition: DgnECInstance.h:72
A string class that has many of the same capabilities as std::string, plus additional functions such ...
Definition: WString.h:51
struct DgnPlatform::ItemType const & ItemTypeCR
Definition: DgnPlatform.h:580

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