4ae0279cd652ccac04c5667c9f241260e5e7f391
[occt.git] / src / TDataStd / TDataStd_Variable.hxx
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;
79   
80   //! retrieve or create  the associated real attribute  and
81   //! set the  value  <value>.   if creation, dimension   is
82   //! written.
83   Standard_EXPORT void Set (const Standard_Real value, const TDataStd_RealEnum dimension = TDataStd_SCALAR) const;
84   
85   //! returns True if a Real attribute is associated.
86   Standard_EXPORT Standard_Boolean IsValued() const;
87   
88   //! returns value stored in associated Real attribute.
89   Standard_EXPORT Standard_Real Get() const;
90   
91   //! returns associated Real attribute.
92   Standard_EXPORT Handle(TDataStd_Real) Real() const;
93   
94   //! returns True if an Expression attribute is associated.
95   //! create(if doesn't exist), set and returns the assigned
96   //! expression attribute.
97   Standard_EXPORT Standard_Boolean IsAssigned() const;
98   
99   //! create(if  doesn't exist)  and  returns  the  assigned
100   //! expression  attribute. fill it after.
101   Standard_EXPORT Handle(TDataStd_Expression) Assign() const;
102   
103   //! if <me> is  assigned delete the associated  expression
104   //! attribute.
105   Standard_EXPORT void Desassign() const;
106   
107   //! if <me>  is  assigned, returns  associated  Expression
108   //! attribute.
109   Standard_EXPORT Handle(TDataStd_Expression) Expression() const;
110   
111   //! shortcut for <Real()->IsCaptured()>
112   Standard_EXPORT Standard_Boolean IsCaptured() const;
113   
114   //! A constant value is not modified by regeneration.
115   Standard_EXPORT Standard_Boolean IsConstant() const;
116   
117   Standard_EXPORT void Unit (const TCollection_AsciiString& unit);
118   
119   //! to read/write fields
120   //! ===================
121   Standard_EXPORT const TCollection_AsciiString& Unit() const;
122   
123   //! if  <status> is   True, this  variable  will not   be
124   //! modified by the solver.
125   Standard_EXPORT void Constant (const Standard_Boolean status);
126   
127   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
128   
129   Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
130   
131   Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
132   
133   Standard_EXPORT void Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
134   
135   //! to export reference to the associated Name attribute.
136   Standard_EXPORT virtual void References (const Handle(TDF_DataSet)& DS) const Standard_OVERRIDE;
137   
138   Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
139
140
141
142
143   DEFINE_STANDARD_RTTIEXT(TDataStd_Variable,TDF_Attribute)
144
145 protected:
146
147
148
149
150 private:
151
152
153   Standard_Boolean isConstant;
154   TCollection_AsciiString myUnit;
155
156
157 };
158
159
160
161
162
163
164
165 #endif // _TDataStd_Variable_HeaderFile