b311480e |
1 | // Created on: 1999-06-10 |
2 | // Created by: Vladislav ROMASHKO |
3 | // Copyright (c) 1999-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | #include <TFunction_Function.ixx> |
24 | #include <TFunction_GraphNode.hxx> |
25 | #include <TFunction_Scope.hxx> |
26 | |
27 | #include <TDF_Label.hxx> |
28 | #include <Standard_DomainError.hxx> |
29 | |
30 | |
31 | //======================================================================= |
32 | //function : GetID |
33 | //purpose : Static method to get an ID |
34 | //======================================================================= |
35 | |
36 | const Standard_GUID& TFunction_Function::GetID() |
37 | { |
38 | static Standard_GUID TFunction_FunctionID("5b35ca00-5b78-11d1-8940-080009dc3333"); |
39 | return TFunction_FunctionID; |
40 | } |
41 | |
42 | |
43 | //======================================================================= |
44 | //function : Set |
45 | //purpose : Finds or creates a function attribute |
46 | //======================================================================= |
47 | |
48 | Handle(TFunction_Function) TFunction_Function::Set(const TDF_Label& L) |
49 | { |
50 | Handle(TFunction_Function) F; |
51 | if (!L.FindAttribute(TFunction_Function::GetID(), F)) { |
52 | F = new TFunction_Function(); |
53 | L.AddAttribute(F); |
54 | } |
55 | return F; |
56 | } |
57 | |
58 | //======================================================================= |
59 | //function : Set |
60 | //purpose : Finds or creates a function attribute and initializes |
61 | // : a driver for it |
62 | //======================================================================= |
63 | |
64 | Handle(TFunction_Function) TFunction_Function::Set(const TDF_Label& L, |
65 | const Standard_GUID& DriverID) |
66 | { |
67 | Handle(TFunction_Function) F; |
68 | if (!L.FindAttribute(TFunction_Function::GetID(), F)) { |
69 | F = new TFunction_Function(); |
70 | L.AddAttribute(F); |
71 | } |
72 | F->SetDriverGUID(DriverID); |
73 | return F; |
74 | } |
75 | |
76 | //======================================================================= |
77 | //function : ID |
78 | //purpose : Returns GUID of the function |
79 | //======================================================================= |
80 | |
81 | const Standard_GUID& TFunction_Function::ID() const |
82 | { return GetID(); } |
83 | |
84 | |
85 | //======================================================================= |
86 | //function : Find |
87 | //purpose : Finds a function if it is on the label |
88 | //======================================================================= |
89 | |
90 | // Standard_Boolean TFunction_Function::Find(const TDF_Label& L, |
91 | // Handle(TFunction_Function)& F) |
92 | // { |
93 | // if (!L.FindAttribute(TFunction_Function::GetID(), F)) |
94 | // return Standard_False; |
95 | // return Standard_True; |
96 | // } |
97 | |
98 | //======================================================================= |
99 | //function : TFunction_Function |
100 | //purpose : Constructor |
101 | //======================================================================= |
102 | |
103 | TFunction_Function::TFunction_Function () : myFailure(0) |
104 | {} |
105 | |
106 | //======================================================================= |
107 | //function : SetDriverGUID |
108 | //purpose : |
109 | //======================================================================= |
110 | |
111 | void TFunction_Function::SetDriverGUID(const Standard_GUID& guid) |
112 | { |
113 | // OCC2932 correction |
114 | if(myDriverGUID == guid) return; |
115 | |
116 | Backup(); |
117 | myDriverGUID = guid; |
118 | } |
119 | |
120 | //======================================================================= |
121 | //function : SetFailure |
122 | //purpose : Sets the failed status of the function |
123 | //======================================================================= |
124 | |
125 | void TFunction_Function::SetFailure (const Standard_Integer mode) |
126 | { |
127 | // OCC2932 correction |
128 | if(myFailure == mode) return; |
129 | |
130 | Backup(); |
131 | myFailure = mode; |
132 | } |
133 | |
134 | |
135 | //======================================================================= |
136 | //function : Restore |
137 | //purpose : |
138 | //======================================================================= |
139 | |
140 | void TFunction_Function::Restore(const Handle(TDF_Attribute)& other) |
141 | { |
142 | Handle(TFunction_Function) F = Handle(TFunction_Function)::DownCast(other); |
143 | myFailure = F->myFailure; |
144 | myDriverGUID = F->myDriverGUID; |
145 | } |
146 | |
147 | //======================================================================= |
148 | //function : Paste |
149 | //purpose : Method for Copy mechanism |
150 | //======================================================================= |
151 | |
152 | void TFunction_Function::Paste(const Handle(TDF_Attribute)& into, |
153 | const Handle(TDF_RelocationTable)& RT) const |
154 | { |
155 | Handle(TFunction_Function) intof = Handle(TFunction_Function)::DownCast(into); |
156 | intof->SetFailure(myFailure); |
157 | intof->SetDriverGUID(myDriverGUID); |
158 | } |
159 | |
160 | //======================================================================= |
161 | //function : NewEmpty |
162 | //purpose : Returns new empty function attribute |
163 | //======================================================================= |
164 | |
165 | Handle(TDF_Attribute) TFunction_Function::NewEmpty() const |
166 | { |
167 | return new TFunction_Function(); |
168 | } |
169 | |
170 | //======================================================================= |
171 | //function : References |
172 | //purpose : Collects the references |
173 | //======================================================================= |
174 | |
175 | void TFunction_Function::References(const Handle(TDF_DataSet)& aDataSet) const |
176 | { |
177 | } |
178 | |
179 | //======================================================================= |
180 | //function : Dump |
181 | //purpose : Dump of the function |
182 | //======================================================================= |
183 | |
184 | Standard_OStream& TFunction_Function::Dump (Standard_OStream& anOS) const |
185 | { |
186 | TDF_Attribute::Dump(anOS); |
187 | return anOS; |
188 | } |