Salome HOME
13c4d8521f6c420de8a959b432aa595a990a831e
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_GenericAttribute.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_GenericAttribute.hxx
24 //  Author : SERGEY_RUIN
25 //  Module : SALOME
26 //
27 #include "SALOMEDSImpl_Attributes.hxx"
28 #include "SALOMEDSImpl_Study.hxx"
29 #include "SALOMEDSImpl_StudyBuilder.hxx"
30
31 std::string SALOMEDSImpl_GenericAttribute::Impl_GetType(DF_Attribute* theAttr)
32 {
33   SALOMEDSImpl_GenericAttribute* ga = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(theAttr);  
34   if (ga)
35     return ga->Type();
36
37   return "";
38 }
39
40 std::string SALOMEDSImpl_GenericAttribute::Impl_GetClassType(DF_Attribute* theAttr)
41 {
42   SALOMEDSImpl_GenericAttribute* ga = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(theAttr);
43   if (ga)
44     return ga->GetClassType();
45   
46   return "";
47
48
49 void SALOMEDSImpl_GenericAttribute::Impl_CheckLocked(DF_Attribute* theAttr)
50 {
51   SALOMEDSImpl_GenericAttribute* ga = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(theAttr);
52   ga->CheckLocked();
53 }
54
55 std::string SALOMEDSImpl_GenericAttribute::Type() 
56
57     return _type; 
58 }
59
60
61 void SALOMEDSImpl_GenericAttribute::CheckLocked()
62 {
63   DF_Label aLabel = Label();
64   if(aLabel.IsNull()) return;
65
66   SALOMEDSImpl_Study* aStudy = SALOMEDSImpl_Study::GetStudyImpl(aLabel);
67   if(!aStudy) return;
68   if(aStudy->IsLocked()) {
69     aStudy->_errorCode = "LockProtection";
70     throw LockProtection("LockProtection");
71   }                                         
72 }
73
74 SALOMEDSImpl_SObject SALOMEDSImpl_GenericAttribute::GetSObject()
75 {
76   SALOMEDSImpl_SObject so; 
77   DF_Label aLabel = Label();
78   if(aLabel.IsNull()) return so;
79   return SALOMEDSImpl_Study::SObject(aLabel);
80 }
81
82 /*!
83  * Set modification flag of the Attribute.
84  * param reason reason of the modification (by default equal to 0)
85  */
86 void SALOMEDSImpl_GenericAttribute::SetModifyFlag(int reason)
87 {
88    DF_Label aLabel = Label();
89    if(aLabel.IsNull()) return; 
90
91   SALOMEDSImpl_Study* aStudy = SALOMEDSImpl_Study::GetStudyImpl(aLabel);
92   if(aStudy) aStudy->modifySO_Notification(GetSObject(), reason);
93   if(aStudy) aStudy->Modify();
94 }