Salome HOME
Merge from V5_1_3_BR 07/12/2009
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_SComponent.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, 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.
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 //  File   : SALOMEDSImpl_SComponent.cxx
23 //  Author : Sergey RUIN
24 //  Module : SALOME
25 //
26 #include "SALOMEDSImpl_SComponent.hxx"
27 #include "SALOMEDSImpl_AttributeComment.hxx"
28 #include "SALOMEDSImpl_AttributeIOR.hxx" 
29
30 using namespace std;
31
32 //============================================================================
33 /*! Function : Empty constructor
34  *  Purpose  : 
35  */
36 //============================================================================
37 SALOMEDSImpl_SComponent::SALOMEDSImpl_SComponent()
38 {
39 }
40
41 //============================================================================
42 /*! Function : Copy constructor
43  *  Purpose  : 
44  */
45 //============================================================================
46 SALOMEDSImpl_SComponent::SALOMEDSImpl_SComponent(const SALOMEDSImpl_SComponent& theSCO)
47 {
48   _lab   = theSCO._lab;
49   _value = theSCO._value;
50   _type  = theSCO._type;
51   _name  = theSCO._name;
52 }
53
54 //============================================================================
55 /*! Function : constructor
56  *  Purpose  : 
57  */
58 //============================================================================
59 SALOMEDSImpl_SComponent::SALOMEDSImpl_SComponent(const DF_Label& theLabel)
60   :SALOMEDSImpl_SObject(theLabel)
61 {
62 }
63   
64 //============================================================================
65 /*! Function : destructor
66  *  Purpose  : 
67  */
68 //============================================================================
69 SALOMEDSImpl_SComponent::~SALOMEDSImpl_SComponent()
70 {
71 }
72   
73   
74 //============================================================================
75 /*! Function : ComponentDataType
76  *  Purpose  : 
77  */
78 //============================================================================
79 string SALOMEDSImpl_SComponent::ComponentDataType()
80 {
81   string res = "";
82   SALOMEDSImpl_AttributeComment* type;
83   if ( (type = (SALOMEDSImpl_AttributeComment*)_lab.FindAttribute(SALOMEDSImpl_AttributeComment::GetID())) ) {
84     res = type->Value();
85   }
86
87   return res;
88 }
89   
90
91 //============================================================================
92 /*! Function : ComponentIOR
93  *  Purpose  : 
94  */
95 //============================================================================
96 bool SALOMEDSImpl_SComponent::ComponentIOR(string& IOR)
97 {
98   SALOMEDSImpl_AttributeIOR* ior;
99   if (!(ior = (SALOMEDSImpl_AttributeIOR*)_lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID())) )
100       return false;
101   IOR = ior->Value();
102   return true;
103 }
104
105
106 //============================================================================
107 /*! Function : IsA
108  *  Purpose  : 
109  */
110 //============================================================================
111 bool SALOMEDSImpl_SComponent::IsA(const DF_Label& theLabel)
112 {
113   // scomponent must contain comment and belong to the 2th depth label
114   if ( theLabel.IsAttribute(SALOMEDSImpl_AttributeComment::GetID()) && theLabel.Depth() == 2) {
115     return true;
116   }
117   return false;
118 }
119
120 //============================================================================
121 /*! Function :  GetPersistentCopy
122  *  Purpose  : 
123  */
124 //============================================================================
125 SALOMEDSImpl_SComponent* SALOMEDSImpl_SComponent::GetPersistentCopy() const
126 {
127   SALOMEDSImpl_SComponent* sco = new SALOMEDSImpl_SComponent;
128   sco->_lab = _lab;
129   sco->_name = _name;
130   sco->_type = _type;
131   sco->_value = _value; 
132   return sco;
133 }