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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _TDataStd_Variable_HeaderFile
18 #define _TDataStd_Variable_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
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>
31 class TCollection_ExtendedString;
33 class TDataStd_Expression;
34 class TCollection_AsciiString;
36 class TDF_RelocationTable;
40 class TDataStd_Variable;
41 DEFINE_STANDARD_HANDLE(TDataStd_Variable, TDF_Attribute)
43 //! Variable attribute.
44 //! ==================
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
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
63 Standard_EXPORT static const Standard_GUID& GetID();
65 //! Find, or create, a Variable attribute.
68 Standard_EXPORT static Handle(TDataStd_Variable) Set (const TDF_Label& label);
70 Standard_EXPORT TDataStd_Variable();
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);
76 //! returns string stored in the associated Name
78 Standard_EXPORT const TCollection_ExtendedString& Name() const;
80 //! retrieve or create the associated real attribute and
81 //! set the value <value>. if creation, dimension is
83 Standard_EXPORT void Set (const Standard_Real value, const TDataStd_RealEnum dimension = TDataStd_SCALAR) const;
85 //! returns True if a Real attribute is associated.
86 Standard_EXPORT Standard_Boolean IsValued() const;
88 //! returns value stored in associated Real attribute.
89 Standard_EXPORT Standard_Real Get() const;
91 //! returns associated Real attribute.
92 Standard_EXPORT Handle(TDataStd_Real) Real() const;
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;
99 //! create(if doesn't exist) and returns the assigned
100 //! expression attribute. fill it after.
101 Standard_EXPORT Handle(TDataStd_Expression) Assign() const;
103 //! if <me> is assigned delete the associated expression
105 Standard_EXPORT void Desassign() const;
107 //! if <me> is assigned, returns associated Expression
109 Standard_EXPORT Handle(TDataStd_Expression) Expression() const;
111 //! shortcut for <Real()->IsCaptured()>
112 Standard_EXPORT Standard_Boolean IsCaptured() const;
114 //! A constant value is not modified by regeneration.
115 Standard_EXPORT Standard_Boolean IsConstant() const;
117 Standard_EXPORT void Unit (const TCollection_AsciiString& unit);
119 //! to read/write fields
120 //! ===================
121 Standard_EXPORT const TCollection_AsciiString& Unit() const;
123 //! if <status> is True, this variable will not be
124 //! modified by the solver.
125 Standard_EXPORT void Constant (const Standard_Boolean status);
127 Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
129 Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
131 Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
133 Standard_EXPORT void Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
135 //! to export reference to the associated Name attribute.
136 Standard_EXPORT virtual void References (const Handle(TDF_DataSet)& DS) const Standard_OVERRIDE;
138 Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
143 DEFINE_STANDARD_RTTIEXT(TDataStd_Variable,TDF_Attribute)
153 Standard_Boolean isConstant;
154 TCollection_AsciiString myUnit;
165 #endif // _TDataStd_Variable_HeaderFile