b311480e |
1 | // Created on: 2004-11-23 |
2 | // Created by: Pavel TELKOV |
973c2be1 |
3 | // Copyright (c) 2004-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
7fd59977 |
16 | // The original implementation Copyright: (C) RINA S.p.A |
17 | |
18 | #ifndef TObj_TReference_HeaderFile |
19 | #define TObj_TReference_HeaderFile |
20 | |
21 | #include <TObj_Common.hxx> |
22 | #include <TDF_Attribute.hxx> |
23 | #include <TDF_Label.hxx> |
24 | |
c04c30b3 |
25 | class TObj_Object; |
7fd59977 |
26 | class Standard_GUID; |
7fd59977 |
27 | |
28 | /** |
29 | * Attribute for storing references to the objects which implement |
30 | * TObj_Object interface in the OCAF tree. |
31 | * Its persistency mechanism provides transparent method for storing |
32 | * cross-model references. |
33 | * Each reference, when created, registers itself in the referred object, |
34 | * to support back references |
35 | */ |
36 | |
37 | class TObj_TReference : public TDF_Attribute |
38 | { |
39 | public: |
40 | //! Standard methods of OCAF attribute |
41 | |
42 | //! Empty constructor |
43 | Standard_EXPORT TObj_TReference(); |
44 | |
45 | //! This method is used in implementation of ID() |
46 | static Standard_EXPORT const Standard_GUID& GetID(); |
47 | |
48 | //! Returns the ID of TObj_TReference attribute. |
49 | Standard_EXPORT const Standard_GUID& ID() const; |
50 | |
51 | public: |
52 | //! Method for create TObj_TReference object |
53 | |
54 | //! Creates reference on TDF_Label <theLabel> to the object <theObject> and |
55 | //! creates backreference from the object <theObject> to <theMaster> one. |
56 | static Standard_EXPORT Handle(TObj_TReference) Set |
57 | (const TDF_Label& theLabel, |
58 | const Handle(TObj_Object)& theObject, |
59 | const Handle(TObj_Object)& theMaster); |
60 | |
61 | public: |
62 | //! Methods for setting and obtaining referenced object |
63 | |
64 | //! Sets the reference to the theObject |
65 | Standard_EXPORT void Set(const Handle(TObj_Object)& theObject, |
66 | const TDF_Label& theMasterLabel); |
67 | |
68 | //! Sets the reference to the theObject at indicated Label. |
69 | //! It is method for persistent only. Don`t use anywhere else. |
70 | Standard_EXPORT void Set(const TDF_Label& theLabel, |
71 | const TDF_Label& theMasterLabel); |
72 | |
73 | //! Returns the referenced theObject |
74 | Standard_EXPORT Handle(TObj_Object) Get() const; |
75 | |
76 | //! Returns the Label of master object. |
77 | Standard_EXPORT TDF_Label GetMasterLabel() const {return myMasterLabel;} |
78 | |
79 | //! Returns the referred label. |
80 | Standard_EXPORT TDF_Label GetLabel() const {return myLabel;} |
81 | |
82 | public: |
83 | //! Redefined OCAF abstract methods |
84 | |
85 | //! Returns an new empty TObj_TReference attribute. It is used by the |
86 | //! copy algorithm. |
87 | Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const; |
88 | |
89 | //! Restores the backuped contents from <theWith> into this one. It is used |
90 | //! when aborting a transaction. |
91 | Standard_EXPORT void Restore(const Handle(TDF_Attribute)& theWith); |
92 | |
93 | //! This method is used when copying an attribute from a source structure |
94 | //! into a target structure. |
95 | Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theInto, |
96 | const Handle(TDF_RelocationTable)& theRT) const; |
97 | |
98 | //! Remove back references of it reference if it is in other document. |
99 | virtual Standard_EXPORT void BeforeForget(); |
100 | |
101 | //! It is necessary for tranzaction mechanism (Undo/Redo). |
102 | virtual Standard_EXPORT Standard_Boolean BeforeUndo |
103 | (const Handle(TDF_AttributeDelta)& theDelta, |
104 | const Standard_Boolean isForced = Standard_False); |
105 | |
106 | //! It is necessary for tranzaction mechanism (Undo/Redo). |
107 | virtual Standard_EXPORT Standard_Boolean AfterUndo |
108 | (const Handle(TDF_AttributeDelta)& theDelta, |
109 | const Standard_Boolean isForced = Standard_False); |
110 | |
111 | //! Check if back reference exists for reference. |
112 | virtual Standard_EXPORT void AfterResume(); |
113 | |
114 | //! Called after retrieval reference from file. |
115 | virtual Standard_EXPORT Standard_Boolean AfterRetrieval |
116 | (const Standard_Boolean forceIt = Standard_False); |
117 | |
118 | private: |
119 | //! Fields |
120 | TDF_Label myLabel; //!< Label that indicate referenced object |
121 | TDF_Label myMasterLabel; //!< Label of object that have this reference. |
122 | |
123 | public: |
124 | //! CASCADE RTTI |
ec357c5c |
125 | DEFINE_STANDARD_RTTI(TObj_TReference, TDF_Attribute) |
7fd59977 |
126 | }; |
127 | |
128 | //! Define handle class for TObj_TReference |
129 | DEFINE_STANDARD_HANDLE(TObj_TReference,TDF_Attribute) |
130 | |
131 | #endif |
132 | |
133 | #ifdef _MSC_VER |
134 | #pragma once |
135 | #endif |