Salome HOME
Fix to bug PAL10465.
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeFlags.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDSImpl_AttributeFlags.cxx
21 //  Author : Sergey LITONIN
22 //  Module : SALOME
23
24 #include "SALOMEDSImpl_AttributeFlags.hxx"
25 #include <Standard_GUID.hxx>
26
27 using namespace std;
28
29
30 /*
31   Class       : SALOMEDSImpl_AttributeFlags
32   Description : This class is intended for storing different object attributes that
33                 have only two states (0 and 1).
34 */
35
36 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeFlags, SALOMEDSImpl_GenericAttribute )
37 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeFlags, SALOMEDSImpl_GenericAttribute )
38
39 //=======================================================================
40 //function : SALOMEDSImpl_AttributeFlags::GetID
41 //purpose  : Get GUID of this attribute
42 //=======================================================================
43 const Standard_GUID& SALOMEDSImpl_AttributeFlags::GetID ()
44 {
45   static Standard_GUID SALOMEDSImpl_AttributeFlagsID( "866EEC9F-A517-4cb4-88E6-E208DB8FC96F" );
46   return SALOMEDSImpl_AttributeFlagsID;                
47 }
48
49 //=======================================================================
50 //function : SALOMEDSImpl_AttributeFlags::Set
51 //purpose  : Set value of the attribute
52 //=======================================================================
53 Handle(SALOMEDSImpl_AttributeFlags) SALOMEDSImpl_AttributeFlags::Set(const TDF_Label& L,
54                                                                      const Standard_Integer value )
55 {
56   Handle(SALOMEDSImpl_AttributeFlags) A;
57   if ( !L.FindAttribute(SALOMEDSImpl_AttributeFlags::GetID(),A ) )
58   {
59     A = new  SALOMEDSImpl_AttributeFlags();
60     L.AddAttribute( A );
61   }
62
63   A->Set( value );
64   return A;
65 }
66
67 //=======================================================================
68 //function : SALOMEDSImpl_AttributeFlags::SALOMEDSImpl_AttributeFlags
69 //purpose  : Constructor
70 //=======================================================================
71 SALOMEDSImpl_AttributeFlags::SALOMEDSImpl_AttributeFlags()
72 :SALOMEDSImpl_GenericAttribute("AttributeFlags")
73 {
74   myValue = 0;
75 }
76
77 SALOMEDSImpl_AttributeFlags::~SALOMEDSImpl_AttributeFlags()
78 {
79 }
80
81 //=======================================================================
82 //function : SALOMEDSImpl_AttributeFlags::ID
83 //purpose  : Get GUID of this attribute
84 //=======================================================================
85 const Standard_GUID& SALOMEDSImpl_AttributeFlags::ID () const
86 {
87   return GetID();
88 }
89
90 //=======================================================================
91 //function : SALOMEDSImpl_AttributeFlags::NewEmpty
92 //purpose  : Create new empty attribute
93 //=======================================================================
94
95 Handle(TDF_Attribute) SALOMEDSImpl_AttributeFlags::NewEmpty () const
96 {
97   return new SALOMEDSImpl_AttributeFlags();
98 }
99
100 //=======================================================================
101 //function : SALOMEDSImpl_AttributeFlags::Restore
102 //purpose  : Assign given value to the attribute
103 //=======================================================================
104 void SALOMEDSImpl_AttributeFlags::Restore( const Handle(TDF_Attribute)& with )
105 {
106   myValue = Handle(SALOMEDSImpl_AttributeFlags)::DownCast( with )->Get();
107   return;
108 }
109
110 //=======================================================================
111 //function : SALOMEDSImpl_AttributeFlags::Paste
112 //purpose  : Assign internal value to the given attribute
113 //=======================================================================
114 void SALOMEDSImpl_AttributeFlags::Paste(const Handle(TDF_Attribute)& into,
115                                         const Handle(TDF_RelocationTable)& RT ) const
116 {
117   Handle(SALOMEDSImpl_AttributeFlags)::DownCast( into )->Set( myValue );
118 }
119
120 //=======================================================================
121 //function : SALOMEDSImpl_AttributeFlags::Set
122 //purpose  : Set value
123 //=======================================================================
124 void SALOMEDSImpl_AttributeFlags::Set( const Standard_Integer v )
125 {
126   Backup();
127   myValue=v;
128 }
129
130 //=======================================================================
131 //function : SALOMEDSImpl_AttributeFlags::Get
132 //purpose  : GetValue
133 //=======================================================================
134 Standard_Integer SALOMEDSImpl_AttributeFlags::Get() const
135 {
136   return myValue;
137 }
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157