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