1 // SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOMEDS_FlagsAttribute.cxx
25 // Author : Sergey LITONIN
28 #include "SALOMEDS_FlagsAttribute.hxx"
29 #include <TDataStd_Integer.hxx>
30 #include <Standard_GUID.hxx>
31 #include <TDF_Label.hxx>
37 Class : SALOMEDS_FlagsAttribute
38 Description : This class is intended for storing different object attributes that
39 have only two states (0 and 1).
42 IMPLEMENT_STANDARD_HANDLE( SALOMEDS_FlagsAttribute, TDataStd_Integer )
43 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDS_FlagsAttribute, TDataStd_Integer )
45 //=======================================================================
46 //function : SALOMEDS_FlagsAttribute::GetID
47 //purpose : Get GUID of this attribute
48 //=======================================================================
49 const Standard_GUID& SALOMEDS_FlagsAttribute::GetID ()
51 static Standard_GUID SALOMEDS_FlagsAttributeID( "866EEC9F-A517-4cb4-88E6-E208DB8FC96F" );
52 return SALOMEDS_FlagsAttributeID;
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 )
62 Handle(SALOMEDS_FlagsAttribute) A;
63 if ( !L.FindAttribute(SALOMEDS_FlagsAttribute::GetID(),A ) )
65 A = new SALOMEDS_FlagsAttribute();
69 ( Handle(TDataStd_Integer)::DownCast( A ) )->Set( value );
73 //=======================================================================
74 //function : SALOMEDS_FlagsAttribute::SALOMEDS_FlagsAttribute
75 //purpose : Constructor
76 //=======================================================================
77 SALOMEDS_FlagsAttribute::SALOMEDS_FlagsAttribute()
79 TDataStd_Integer::Set( 0 );
82 SALOMEDS_FlagsAttribute::~SALOMEDS_FlagsAttribute()
86 //=======================================================================
87 //function : SALOMEDS_FlagsAttribute::ID
88 //purpose : Get GUID of this attribute
89 //=======================================================================
90 const Standard_GUID& SALOMEDS_FlagsAttribute::ID () const
95 //=======================================================================
96 //function : SALOMEDS_FlagsAttribute::NewEmpty
97 //purpose : Create new empty attribute
98 //=======================================================================
100 Handle(TDF_Attribute) SALOMEDS_FlagsAttribute::NewEmpty () const
102 return new SALOMEDS_FlagsAttribute();
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 )
111 Standard_Integer s = Handle(TDataStd_Integer)::DownCast( with )->Get();
112 TDataStd_Integer::Set( s );
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
123 Handle(TDataStd_Integer)::DownCast( into )->Set( Get() );
126 //=======================================================================
127 //function : SALOMEDS_FlagsAttribute::Set
128 //purpose : Set value
129 //=======================================================================
130 void SALOMEDS_FlagsAttribute::Set( const Standard_Integer v )
132 TDataStd_Integer::Set( v );
135 //=======================================================================
136 //function : SALOMEDS_FlagsAttribute::Get
138 //=======================================================================
139 Standard_Integer SALOMEDS_FlagsAttribute::Get() const
141 return TDataStd_Integer::Get();