42cf5bc1 |
1 | // Created on: 1997-12-10 |
2 | // Created by: Denis PASCAL |
3 | // Copyright (c) 1997-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _TDataStd_Variable_HeaderFile |
18 | #define _TDataStd_Variable_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <Standard_Boolean.hxx> |
24 | #include <TCollection_AsciiString.hxx> |
25 | #include <TDF_Attribute.hxx> |
26 | #include <Standard_Real.hxx> |
27 | #include <TDataStd_RealEnum.hxx> |
28 | #include <Standard_OStream.hxx> |
29 | class Standard_GUID; |
30 | class TDF_Label; |
31 | class TCollection_ExtendedString; |
32 | class TDataStd_Real; |
33 | class TDataStd_Expression; |
34 | class TCollection_AsciiString; |
35 | class TDF_Attribute; |
36 | class TDF_RelocationTable; |
37 | class TDF_DataSet; |
38 | |
39 | |
40 | class TDataStd_Variable; |
41 | DEFINE_STANDARD_HANDLE(TDataStd_Variable, TDF_Attribute) |
42 | |
43 | //! Variable attribute. |
44 | //! ================== |
45 | //! |
46 | //! * A variable is associated to a TDataStd_Real (which |
47 | //! contains its current value) and a TDataStd_Name |
48 | //! attribute (which contains its name). It contains a |
49 | //! constant flag, and a Unit |
50 | //! |
51 | //! * An expression may be assigned to a variable. In |
52 | //! thatcase the expression is handled by the associated |
53 | //! Expression Attribute and the Variable returns True to |
54 | //! the method <IsAssigned>. |
55 | class TDataStd_Variable : public TDF_Attribute |
56 | { |
57 | |
58 | public: |
59 | |
60 | |
61 | //! class methods |
62 | //! ============= |
63 | Standard_EXPORT static const Standard_GUID& GetID(); |
64 | |
65 | //! Find, or create, a Variable attribute. |
66 | //! Real methods |
67 | //! ============ |
68 | Standard_EXPORT static Handle(TDataStd_Variable) Set (const TDF_Label& label); |
69 | |
70 | Standard_EXPORT TDataStd_Variable(); |
71 | |
72 | //! set or change the name of the variable, in myUnknown |
73 | //! and my associated Name attribute. |
74 | Standard_EXPORT void Name (const TCollection_ExtendedString& string); |
75 | |
76 | //! returns string stored in the associated Name |
77 | //! attribute. |
78 | Standard_EXPORT const TCollection_ExtendedString& Name() const; |
58e5d30e |
79 | |
42cf5bc1 |
80 | //! retrieve or create the associated real attribute and |
58e5d30e |
81 | //! set the value <value>. |
82 | Standard_EXPORT void Set (const Standard_Real value) const; |
42cf5bc1 |
83 | |
58e5d30e |
84 | //! Obsolete method that will be removed in next versions. |
85 | //! The dimension argument is not supported in the persistence mechanism. |
86 | Standard_DEPRECATED("TDataStd_Variable::Set(value, dimension) is deprecated. Please use TDataStd_Variable::Set(value) instead.") |
87 | Standard_EXPORT void Set (const Standard_Real value, const TDataStd_RealEnum dimension) const; |
88 | |
42cf5bc1 |
89 | //! returns True if a Real attribute is associated. |
90 | Standard_EXPORT Standard_Boolean IsValued() const; |
91 | |
92 | //! returns value stored in associated Real attribute. |
93 | Standard_EXPORT Standard_Real Get() const; |
94 | |
95 | //! returns associated Real attribute. |
96 | Standard_EXPORT Handle(TDataStd_Real) Real() const; |
97 | |
98 | //! returns True if an Expression attribute is associated. |
99 | //! create(if doesn't exist), set and returns the assigned |
100 | //! expression attribute. |
101 | Standard_EXPORT Standard_Boolean IsAssigned() const; |
102 | |
103 | //! create(if doesn't exist) and returns the assigned |
104 | //! expression attribute. fill it after. |
105 | Standard_EXPORT Handle(TDataStd_Expression) Assign() const; |
106 | |
107 | //! if <me> is assigned delete the associated expression |
108 | //! attribute. |
109 | Standard_EXPORT void Desassign() const; |
110 | |
111 | //! if <me> is assigned, returns associated Expression |
112 | //! attribute. |
113 | Standard_EXPORT Handle(TDataStd_Expression) Expression() const; |
114 | |
115 | //! shortcut for <Real()->IsCaptured()> |
116 | Standard_EXPORT Standard_Boolean IsCaptured() const; |
117 | |
118 | //! A constant value is not modified by regeneration. |
119 | Standard_EXPORT Standard_Boolean IsConstant() const; |
120 | |
121 | Standard_EXPORT void Unit (const TCollection_AsciiString& unit); |
122 | |
123 | //! to read/write fields |
124 | //! =================== |
125 | Standard_EXPORT const TCollection_AsciiString& Unit() const; |
126 | |
127 | //! if <status> is True, this variable will not be |
128 | //! modified by the solver. |
129 | Standard_EXPORT void Constant (const Standard_Boolean status); |
130 | |
79104795 |
131 | Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE; |
42cf5bc1 |
132 | |
79104795 |
133 | Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE; |
42cf5bc1 |
134 | |
79104795 |
135 | Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE; |
42cf5bc1 |
136 | |
79104795 |
137 | Standard_EXPORT void Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE; |
42cf5bc1 |
138 | |
139 | //! to export reference to the associated Name attribute. |
140 | Standard_EXPORT virtual void References (const Handle(TDF_DataSet)& DS) const Standard_OVERRIDE; |
141 | |
142 | Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE; |
bc73b006 |
143 | |
144 | //! Dumps the content of me into the stream |
145 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; |
42cf5bc1 |
146 | |
147 | |
148 | |
149 | |
92efcf78 |
150 | DEFINE_STANDARD_RTTIEXT(TDataStd_Variable,TDF_Attribute) |
42cf5bc1 |
151 | |
152 | protected: |
153 | |
154 | |
155 | |
156 | |
157 | private: |
158 | |
159 | |
160 | Standard_Boolean isConstant; |
161 | TCollection_AsciiString myUnit; |
162 | |
163 | |
164 | }; |
165 | |
166 | |
167 | |
168 | |
169 | |
170 | |
171 | |
172 | #endif // _TDataStd_Variable_HeaderFile |