Salome HOME
ced572bc698c5b799df1047ad6099aa20d3daeb5
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeFlags.cxx
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  File   : SALOMEDSImpl_AttributeFlags.cxx
24 //  Author : Sergey LITONIN
25 //  Module : SALOME
26 //
27 #include "SALOMEDSImpl_AttributeFlags.hxx"
28
29 /*
30   Class       : SALOMEDSImpl_AttributeFlags
31   Description : This class is intended for storing different object attributes that
32                 have only two states (0 and 1).
33 */
34
35 //=======================================================================
36 //function : SALOMEDSImpl_AttributeFlags::GetID
37 //purpose  : Get GUID of this attribute
38 //=======================================================================
39 const std::string& SALOMEDSImpl_AttributeFlags::GetID ()
40 {
41   static std::string SALOMEDSImpl_AttributeFlagsID( "866EEC9F-A517-4cb4-88E6-E208DB8FC96F" );
42   return SALOMEDSImpl_AttributeFlagsID;                
43 }
44
45 //=======================================================================
46 //function : SALOMEDSImpl_AttributeFlags::Set
47 //purpose  : Set value of the attribute
48 //=======================================================================
49 SALOMEDSImpl_AttributeFlags* SALOMEDSImpl_AttributeFlags::Set(const DF_Label& L,
50                                                               const int value )
51 {
52   SALOMEDSImpl_AttributeFlags* A = NULL;
53   if ( !(A=(SALOMEDSImpl_AttributeFlags*)L.FindAttribute(SALOMEDSImpl_AttributeFlags::GetID())) )
54   {
55     A = new  SALOMEDSImpl_AttributeFlags();
56     L.AddAttribute( A );
57   }
58
59   A->Set( value );
60   return A;
61 }
62
63 //=======================================================================
64 //function : SALOMEDSImpl_AttributeFlags::SALOMEDSImpl_AttributeFlags
65 //purpose  : Constructor
66 //=======================================================================
67 SALOMEDSImpl_AttributeFlags::SALOMEDSImpl_AttributeFlags()
68 :SALOMEDSImpl_GenericAttribute("AttributeFlags")
69 {
70   myValue = 0;
71 }
72
73 SALOMEDSImpl_AttributeFlags::~SALOMEDSImpl_AttributeFlags()
74 {
75 }
76
77 //=======================================================================
78 //function : SALOMEDSImpl_AttributeFlags::ID
79 //purpose  : Get GUID of this attribute
80 //=======================================================================
81 const std::string& SALOMEDSImpl_AttributeFlags::ID () const
82 {
83   return GetID();
84 }
85
86 //=======================================================================
87 //function : SALOMEDSImpl_AttributeFlags::NewEmpty
88 //purpose  : Create new empty attribute
89 //=======================================================================
90
91 DF_Attribute* SALOMEDSImpl_AttributeFlags::NewEmpty () const
92 {
93   return new SALOMEDSImpl_AttributeFlags();
94 }
95
96 //=======================================================================
97 //function : SALOMEDSImpl_AttributeFlags::Restore
98 //purpose  : Assign given value to the attribute
99 //=======================================================================
100 void SALOMEDSImpl_AttributeFlags::Restore( DF_Attribute* with )
101 {
102   myValue = dynamic_cast<SALOMEDSImpl_AttributeFlags*>( with )->Get();
103   return;
104 }
105
106 //=======================================================================
107 //function : SALOMEDSImpl_AttributeFlags::Paste
108 //purpose  : Assign internal value to the given attribute
109 //=======================================================================
110 void SALOMEDSImpl_AttributeFlags::Paste( DF_Attribute* into)
111 {
112   dynamic_cast<SALOMEDSImpl_AttributeFlags*>( into )->Set( myValue );
113 }
114
115 //=======================================================================
116 //function : SALOMEDSImpl_AttributeFlags::Set
117 //purpose  : Set value
118 //=======================================================================
119 void SALOMEDSImpl_AttributeFlags::Set( const int v )
120 {
121   Backup();
122   myValue=v;
123 }
124
125 //=======================================================================
126 //function : SALOMEDSImpl_AttributeFlags::Get
127 //purpose  : GetValue
128 //=======================================================================
129 int SALOMEDSImpl_AttributeFlags::Get() const
130 {
131   return myValue;
132 }
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152