DependencyManagerLinkage.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 
11 #include <Bentley/RefCounted.h>
12 #include "ITxnManager.h"
13 #include "DependencyManagerAppid.h"
14 #include <map>
15 
16 // a linkage can be up to about 40K in size (including the header)
17 #define DEPENDENCY_MAX_DATA 40960
18 #define DEPENDENCY_MAX_ELEMIDS_(X) ((DEPENDENCY_MAX_DATA-X)/sizeof(ElementId))
19 #define DEPENDENCY_MAX_FARELEMIDS_(X) ((DEPENDENCY_MAX_DATA-X)/sizeof(DependencyRootFarElementID))
20 #define DEPENDENCY_MAX_ELEMIDVS_(X) ((DEPENDENCY_MAX_DATA-X)/sizeof(DependencyRootElementID_V))
21 #define DEPENDENCY_MAX_FARELEMIDVS_(X) ((DEPENDENCY_MAX_DATA-X)/sizeof(DependencyRootFarElementID_V))
22 #define SIZEOF_ASSOCPOINT 40
23 #define DEPENDENCY_MAX_ASSOCPOINTS_(X) ((DEPENDENCY_MAX_DATA-X)/SIZEOF_ASSOCPOINT)
24 #define DEPENDENCY_MAX_ASSOCPOINTIS_(X) ((DEPENDENCY_MAX_DATA-X)/(SIZEOF_ASSOCPOINT+8))
25 
26 #define DEPENDENCY_MAX_ELEMIDS DEPENDENCY_MAX_ELEMIDS_(0)
27 #define DEPENDENCY_MAX_FARELEMIDS DEPENDENCY_MAX_FARELEMIDS_(0)
28 #define DEPENDENCY_MAX_ELEMIDVS DEPENDENCY_MAX_ELEMIDVS_(0)
29 #define DEPENDENCY_MAX_FARELEMIDVS DEPENDENCY_MAX_FARELEMIDVS_(0)
30 #define DEPENDENCY_MAX_ELEMIDS_IN_MODEL DEPENDENCY_MAX_ELEMIDS_IN_MODEL_(0)
31 #define DEPENDENCY_MAX_ASSOCPOINTS DEPENDENCY_MAX_ASSOCPOINTS_(0)
32 #define DEPENDENCY_MAX_ASSOCPOINTIS DEPENDENCY_MAX_ASSOCPOINTIS_(0)
33 
34 // Most dependency linkages will have far, far fewer references than that.
35 // We define an in-memory version of the struct that has a pre-allocated buffer
36 // of a smaller size. This is just for the convenience of programs that want to
37 // declare a DependencyLinkage on the stack, without worrying about stack overflow.
38 
39 #define DEPENDENCY_SOME_DATA 1024
40 #define DEPENDENCY_SOME_ELEMIDS (DEPENDENCY_SOME_DATA/sizeof(ElementId))
41 #define DEPENDENCY_SOME_FARELEMIDS (DEPENDENCY_SOME_DATA/sizeof(DependencyRootFarElementID))
42 #define DEPENDENCY_SOME_ELEMIDVS (DEPENDENCY_SOME_DATA/sizeof(DependencyRootElementID_V))
43 #define DEPENDENCY_SOME_FARELEMIDVS (DEPENDENCY_SOME_DATA/sizeof(DependencyRootFarElementID_V))
44 #define DEPENDENCY_SOME_ASSOCPOINTS (DEPENDENCY_SOME_DATA/SIZEOF_ASSOCPOINT)
45 #define DEPENDENCY_SOME_ASSOCPOINTIS (DEPENDENCY_SOME_DATA/(SIZEOF_ASSOCPOINT+8))
46 
47 // Identifies type of root data in DependencyLinkage:
48 #define DEPENDENCY_DATA_TYPE_ELEM_ID 0
49 #define DEPENDENCY_DATA_TYPE_ELEM_ID_V 1
50 #define DEPENDENCY_DATA_TYPE_ASSOC_POINT 2
51 #define DEPENDENCY_DATA_TYPE_ASSOC_POINT_I 3
52 #define DEPENDENCY_DATA_TYPE_FAR_ELEM_ID 4
53 #define DEPENDENCY_DATA_TYPE_FAR_ELEM_ID_V 5
54 #define DEPENDENCY_DATA_TYPE_PATH_V 6
55 
56 // Values for copyOptions flag
57 #define DEPENDENCY_ON_COPY_DropDependency 0
58 #define DEPENDENCY_ON_COPY_RemapRootsWithinSelection 1
59 #define DEPENDENCY_ON_COPY_DeepCopyRootsAcrossFiles 2
60 
61 
65 #define DEPENDENCY_ON_COPY_DeepCopyRootsAlways 3
66 
67 
71 #define DEPENDENCY_STATUS_UNCHANGED 0
72 #define DEPENDENCY_STATUS_CHANGED 1
73 #define DEPENDENCY_STATUS_DELETED 2
74 #define DEPENDENCY_STATUS_RESOLVED 3
75 #define DEPENDENCY_STATUS_UNRESOLVED 4
76 // NB: DEPENDENCY_STATUS_UNRESOLVED must be > DEPENDENCY_STATUS_RESOLVED!
77 
78 #define DEPENDENCY_MAX_TARGETS_PER_ROOT 4
79 
81 
82 /*----------------------------------------------------------------------+
83 | |
84 | Typedefs |
85 | |
86 +----------------------------------------------------------------------*/
87 
95 {
106 
107 
117 {
121  double value;
123 
132 {
143 
157 typedef struct
158 {
162  int i;
164  int i2;
166 
174 typedef struct DependencyRootPath_V
175 {
179  double value;
180  ElementId path[1];
188 
202 typedef struct DependencyLinkage
203 {
204  /*-------------------------------------------------------------------
205  Header
206  -------------------------------------------------------------------*/
217 
219  union
220  {
222  struct
223  {
225  UInt16 invalid:1;
228  UInt16 deleteRoots:1;
231  UInt16 dontRequireAppForDelete:1;
233  UInt16 __unused__:4;
235  UInt16 allowRemapToOriginal:1;
257  UInt16 copyOptions:2;
259  UInt16 rootDataType:4;
263  UInt16 requireApp:1;
267  UInt16 disabled:1;
268  } f;
269  } u;
270 
271  /*-------------------------------------------------------------------
272  Data (type depends on rootDataType)
273  -------------------------------------------------------------------*/
289  union // ***NB! start of union must be 8-byte aligned!
290  {
298  } root;
299 
301 
307 typedef struct dependencyRoot
308 {
328 
329 
330 
331 //=======================================================================================
368 {
369 
371 
372 /*----------------------------------------------------------------------**/
525 {
526  virtual StatusInt OnRootsChanged
527  (
528  ElementHandleCR dependentElement,
529  DependencyLinkage const& dependencyData,
530  UInt8 *pRootStatus,
531  UInt8 selfStatus
532  ) = 0;
533 
534  virtual WString GetDescription () const = 0;
535 };
536 
537 
565 DGNPLATFORM_EXPORT static StatusInt RegisterRootsChangedCallback
566 (
567 UShort appID,
569 );
570 
587 DGNPLATFORM_EXPORT static StatusInt GetRootsChangedCallback
588 (
590 UShort appID
591 );
592 
603 DGNPLATFORM_EXPORT static void RemoveRootsChangedCallback
604 (
605 UShort appID
606 );
607 
633 DGNPLATFORM_EXPORT static void SetIgnoreMissingCallbacks (bool b);
634 
642 DGNPLATFORM_EXPORT static bool GetIgnoreMissingCallbacks (void);
643 
659 DGNPLATFORM_EXPORT static StatusInt RegisterRootsChangedForUndoRedoCallback
660 (
661 UShort appID,
663 );
664 
672 DGNPLATFORM_EXPORT static StatusInt GetRootsChangedForUndoRedoCallback
673 (
675 UShort appID
676 );
677 
687 DGNPLATFORM_EXPORT static void RemoveRootsChangedForUndoRedoCallback
688 (
689 UShort appID // appID of dependency
690 );
691 
692 
694 
696 
710 DGNPLATFORM_EXPORT static StatusInt InitLinkage
711 (
712 DependencyLinkage& dependencyData,
713 UShort appID,
714 int dataType,
715 int copyOptions
716 );
717 
718 DGNPLATFORM_EXPORT static void DefineElementIDDependency
719 (
720 DependencyLinkage& dependencyData,
721 UShort appID,
722 UShort appValue,
723 int copyOptions,
724 ElementId elementID
725 );
726 
727 DGNPLATFORM_EXPORT static StatusInt DefinePathVDependency
728 (
729 DependencyLinkage& dep,
730 size_t bufSize,
731 UShort appID,
732 UShort appValue,
733 DisplayPathCP displayPath,
734 DgnModelRefP parentModel
735 );
736 
737 /*----------------------------------------------------------------------**/
818 DGNPLATFORM_EXPORT static StatusInt AppendLinkage
819 (
821 DependencyLinkage const& dependencyData,
822 size_t xtrabytes
823 );
824 
840 DGNPLATFORM_EXPORT static int DeleteLinkage
841 (
843 UShort appID,
844 UShort appValue
845 );
846 
861 DGNPLATFORM_EXPORT static StatusInt UpdateLinkage
862 (
864 DependencyLinkage const & dependencyData,
865 size_t xtrabytes
866 );
867 
882 DGNPLATFORM_EXPORT static StatusInt GetLinkage
883 (
884 DependencyLinkage const** ppDependencyLinkageInplace,
885 ElementHandleCR element,
886 UShort appID,
887 UShort appValue
888 );
889 
909 DGNPLATFORM_EXPORT static size_t GetSizeofLinkage
910 (
911 DependencyLinkage const& dependencyData,
912 size_t xtrabytes
913 );
914 
916 
918 
919 
954 DGNPLATFORM_EXPORT static UInt16 GetRoots
955 (
956 DependencyRoot *pRoots,
957 DgnModelP homeModel,
958 DependencyLinkage const& dependencyData,
959 UInt16 iRoot
960 );
961 
972 DGNPLATFORM_EXPORT static void GetRootElementIds
973 (
974 bvector<ElementId>& ids,
975 ElementHandleCR eh,
976 UShort applicationID,
977 UShort applicationValue
978 );
979 
980 
996 DGNPLATFORM_EXPORT static size_t GetSizeofRootDataType
997 (
998 int rootDataType
999 );
1000 
1001 
1003 
1004 
1005 
1006 
1009 
1010 }; // DependencyManagerLinkage
1011 
1012 
1014 
Defines an ElementID_V reference where the root can be in a different model from the dependent...
Definition: DependencyManagerLinkage.h:131
UInt16 appID
A value that is assigned by Bentley to uniquely identify a dependency type.
Definition: DependencyManagerLinkage.h:210
#define DEPENDENCY_SOME_FARELEMIDVS
Definition: DependencyManagerLinkage.h:43
#define END_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:69
int i2
a 2nd integer value that further defines the relationship
Definition: DependencyManagerLinkage.h:164
#define DEPENDENCY_SOME_ELEMIDS
The maximum number of ElementIDs that a DependencyLinkage holds (128)
Definition: DependencyManagerLinkage.h:40
Defines a dependency tied to a particular point on one or more root elements.
Definition: DependencyManagerLinkage.h:157
uint16_t UInt16
Definition: Bentley.r.h:118
DependencyRootElementID_V s
the elementID of the root and an associated value
Definition: DependencyManagerLinkage.h:134
A writeable "handle" to an MSElement.
Definition: ElementHandle.h:470
ElementId elemid
root element ID (relative to its model or file)
Definition: DependencyManagerLinkage.h:310
double value
numerical value to associate with the dependency
Definition: DependencyManagerLinkage.h:121
uint8_t UInt8
Definition: Bentley.r.h:116
ElementId refattid
identifies the model that contains the root.
Definition: DependencyManagerLinkage.h:104
Definition: DependencyManagerLinkage.h:367
Defines a dependency where the root can be in a different model from the dependent.
Definition: DependencyManagerLinkage.h:94
#define DGNPLATFORM_EXPORT
Definition: DgnPlatform/ExportMacros.h:58
UInt16 flags
Definition: DependencyManagerLinkage.h:221
UInt16 nRoots
The number of items in the root array.
Definition: DependencyManagerLinkage.h:277
Transform refTransform
reference transform (if refattid != 0 && ref != NULL)
Definition: DependencyManagerLinkage.h:326
Definition: DgnPlatform.h:1622
struct Bentley::DgnPlatform::DependencyRootFarElementID DependencyRootFarElementID
Defines a dependency where the root can be in a different model from the dependent.
#define DEPENDENCY_SOME_ELEMIDVS
The number of DependencyRootElementID_Vs that a DependencyLinkage holds (64)
Definition: DependencyManagerLinkage.h:42
uint32_t UInt32
Definition: Bentley.r.h:128
ElementId elemid
root element ID
Definition: DependencyManagerLinkage.h:119
In-memory image of user attribute data in which dependency information is stored. ...
Definition: DependencyManagerLinkage.h:202
double value
Definition: DependencyManagerLinkage.h:179
#define DEPENDENCY_SOME_DATA
The amount of data, in bytes, that a DependencyLinkage holds.
Definition: DependencyManagerLinkage.h:39
ElementId refattid
identifies the model that contains the root.
Definition: DependencyManagerLinkage.h:318
struct DgnPlatform::DisplayPath const * DisplayPathCP
Definition: DgnPlatform.h:236
A DgnModel represents a DgnModel in memory.
Definition: DgnModel.h:236
Describes a reference from a dependent to a root in a DependencyLinkage.
Definition: DependencyManagerLinkage.h:307
#define DEPENDENCY_SOME_ASSOCPOINTS
The number of AssocPoints that a DependencyLinkage holds (25)
Definition: DependencyManagerLinkage.h:44
struct Bentley::DgnPlatform::dependencyRoot DependencyRoot
Describes a reference from a dependent to a root in a DependencyLinkage.
A DgnModelRef provides access to a model in a Bentley::DgnPlatform::DgnFile.
Definition: DgnModelRef.h:172
struct Bentley::DgnPlatform::DependencyRootPath_V DependencyRootPath_V
Defines a dependency where the root can be in a different model from the dependent, including nested reference files where multiple Reference attachment IDs are needed to specify the modelRef that is resolved at runtime.
unsigned short UShort
Definition: Bentley.r.h:133
AssocPoint assoc
the associative point
Definition: DependencyManagerLinkage.h:160
#define DEPENDENCY_SOME_FARELEMIDS
The number of DependencyRootFarElementIDs that a DependencyLinkage holds (64)
Definition: DependencyManagerLinkage.h:41
Interface that provides direct and efficient access to element data.
Definition: ElementRefBase.h:120
DependencyRootPath_V path_v
Definition: DependencyManagerLinkage.h:297
UInt32 numElemsInPath
identifies the root within its model.
Definition: DependencyManagerLinkage.h:177
#define BEGIN_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:68
struct Bentley::DgnPlatform::DependencyRootFarElementID_V DependencyRootFarElementID_V
Defines an ElementID_V reference where the root can be in a different model from the dependent...
struct Bentley::DgnPlatform::DependencyLinkage DependencyLinkage
In-memory image of user attribute data in which dependency information is stored. ...
ElementId refattid
identifies the model that contains the root.
Definition: DependencyManagerLinkage.h:141
int StatusInt
Definition: Bentley.h:222
3x4 matrix for defining coordinate frames and affine transformations.
Definition: transform.h:22
int i
an integer value that further defines the relationship
Definition: DependencyManagerLinkage.h:162
UInt64 ElementId
Definition: DgnPlatformBaseType.r.h:83
Defines a dependency where the root can be in a different model from the dependent, including nested reference files where multiple Reference attachment IDs are needed to specify the modelRef that is resolved at runtime.
Definition: DependencyManagerLinkage.h:174
UserFunction called by DependencyManager::ProcessAffected when a dependent element is affected by cha...
Definition: DependencyManagerLinkage.h:524
unsigned char UChar
Definition: Bentley.r.h:142
struct Bentley::DgnPlatform::DependencyRootElementID_V DependencyRootElementID_V
Defines a dependency and associates a floating-point value with it.
UInt32 reserved
Definition: DependencyManagerLinkage.h:178
struct DgnPlatform::ElementHandle const & ElementHandleCR
Definition: DgnPlatform.h:260
Interface to be adopted by a class the implements the reference-counting pattern. ...
Definition: RefCounted.h:34
Defines a dependency and associates a floating-point value with it.
Definition: DependencyManagerLinkage.h:116
A string class that has many of the same capabilities as std::string, plus additional functions such ...
Definition: WString.h:51
ElementId elemid
identifies the root within its model.
Definition: DependencyManagerLinkage.h:97
UInt16 appValue
An application-specific value that further defines the linkage The DependencyLinkage.appValue field is for the use of the application.
Definition: DependencyManagerLinkage.h:216
ElementRefP ref
identifies the root element itself.
Definition: DependencyManagerLinkage.h:324

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