Salome HOME
DCQ : Merge with Ecole_ete_a6.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_SComponent_i.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_SComponent_i.cxx
25 //  Author : Yves FRICAUD
26 //  Module : SALOME
27 //  $Header$
28
29 using namespace std;
30 #include "SALOMEDS_SComponent_i.hxx"
31 #include "utilities.h"
32
33
34 //============================================================================
35 /*! Function : constructor
36  *  Purpose  : 
37  */
38 //============================================================================
39 SALOMEDS_SComponent_i::SALOMEDS_SComponent_i(const TDF_Label lab, CORBA::ORB_ptr orb)
40   :SALOMEDS_SObject_i(lab,orb)
41 {
42 }
43   
44 //============================================================================
45 /*! Function : destructor
46  *  Purpose  : 
47  */
48 //============================================================================
49 SALOMEDS_SComponent_i::~SALOMEDS_SComponent_i()
50 {
51 }
52   
53   
54 //============================================================================
55 /*! Function : ComponentDataType
56  *  Purpose  : 
57  */
58 //============================================================================
59 char* SALOMEDS_SComponent_i::ComponentDataType()
60 {
61   //DEB
62   //    MESSAGE("In SALOMEDS_SComponent_i::ComponentDataType");
63   //    TCollection_AsciiString anEntry;
64   //    TDF_Tool::Entry (_lab,anEntry);
65   //    MESSAGE("in SALOMEDS_SComponent_i, Entry :"<<anEntry);
66   // END DEB
67
68   Standard_CString res = "";
69   Handle(TDataStd_Comment) type;
70   if ( _lab.FindAttribute(TDataStd_Comment::GetID(),type) ) {
71     TCollection_AsciiString ch(type->Get());
72     res = ch.ToCString();
73   }
74
75   return CORBA::string_dup(res);
76 }
77   
78
79 //============================================================================
80 /*! Function : ComponentIOR
81  *  Purpose  : 
82  */
83 //============================================================================
84 CORBA::Boolean SALOMEDS_SComponent_i::ComponentIOR(CORBA::String_out IOR)
85 {
86   Handle(SALOMEDS_IORAttribute) ior;
87   if (!_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),ior) )
88       return false;
89   TCollection_AsciiString ch(ior->Get());
90   IOR = strdup(ch.ToCString());
91   return true;
92 }
93   
94
95 //============================================================================
96 /*! Function : IsA
97  *  Purpose  : 
98  */
99 //============================================================================
100 Standard_Boolean SALOMEDS_SComponent_i::IsA(const TDF_Label Lab)
101 {
102   Handle(TDF_Attribute) Att;
103   // scomponent must contain comment and belong to the 2th depth label
104   if ( Lab.FindAttribute(TDataStd_Comment::GetID(), Att) && Lab.Depth() == 2) {
105     return Standard_True;
106   }
107   return Standard_False;
108 }
109   
110