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_SComponent_i.cxx
25 // Author : Yves FRICAUD
29 #include "SALOMEDS_SComponent_i.hxx"
30 #include "SALOMEDS_Study_i.hxx"
31 #include "SALOMEDS.hxx"
33 #include "utilities.h"
37 SALOMEDS_Study_i::TSObjectHolder
38 SALOMEDS_SComponent_i::New(SALOMEDS_Study_i* theStudy,
39 const TDF_Label& theLabel)
41 SALOMEDS_Study_i::TSObjectHolder aSObjectHolder;
42 SALOMEDS_Study_i::TSObjectMap& anSObjectMap = theStudy->GetSObjectMap();
43 SALOMEDS_Study_i::TSObjectMap::const_iterator anIter = anSObjectMap.find(theLabel);
44 if(anIter != anSObjectMap.end()){
45 aSObjectHolder = anIter->second;
46 SALOMEDS_SObject_i* aSObject = aSObjectHolder.first;
47 if(dynamic_cast<SALOMEDS_SComponent_i*>(aSObject))
48 return aSObjectHolder;
50 TCollection_AsciiString anEntry;
51 TDF_Tool::Entry(theLabel,anEntry);
52 SALOMEDS_SComponent_i* aSComponent = new SALOMEDS_SComponent_i(theStudy,theLabel);
53 aSObjectHolder.first = aSComponent;
54 aSObjectHolder.second = aSComponent->_this();
55 anSObjectMap[theLabel] = aSObjectHolder;
57 return aSObjectHolder;
60 SALOMEDS_SComponent_i*
61 SALOMEDS_SComponent_i::NewPtr(SALOMEDS_Study_i* theStudy,
62 const TDF_Label& theLabel)
64 return dynamic_cast<SALOMEDS_SComponent_i*>(New(theStudy,theLabel).first);
67 SALOMEDS::SComponent_var
68 SALOMEDS_SComponent_i::NewRef(SALOMEDS_Study_i* theStudy,
69 const TDF_Label& theLabel)
71 return SALOMEDS::SComponent::_narrow(New(theStudy,theLabel).second);
74 //============================================================================
75 /*! Function : constructor
78 //============================================================================
79 SALOMEDS_SComponent_i::SALOMEDS_SComponent_i(SALOMEDS_Study_i* theStudy,
80 const TDF_Label& theLabel):
81 SALOMEDS_SObject_i(theStudy,theLabel)
85 //============================================================================
86 /*! Function : destructor
89 //============================================================================
90 SALOMEDS_SComponent_i::~SALOMEDS_SComponent_i()
95 //============================================================================
96 /*! Function : ComponentDataType
99 //============================================================================
100 char* SALOMEDS_SComponent_i::ComponentDataType()
102 SALOMEDS::Locker lock;
105 // MESSAGE("In SALOMEDS_SComponent_i::ComponentDataType");
106 // TCollection_AsciiString anEntry;
107 // TDF_Tool::Entry (_lab,anEntry);
108 // MESSAGE("in SALOMEDS_SComponent_i, Entry :"<<anEntry);
111 Standard_CString res = "";
112 Handle(TDataStd_Comment) type;
113 if ( _lab.FindAttribute(TDataStd_Comment::GetID(),type) ) {
114 TCollection_AsciiString ch(type->Get());
115 res = ch.ToCString();
118 return CORBA::string_dup(res);
122 //============================================================================
123 /*! Function : ComponentIOR
126 //============================================================================
127 CORBA::Boolean SALOMEDS_SComponent_i::ComponentIOR(CORBA::String_out IOR)
129 SALOMEDS::Locker lock;
131 Handle(SALOMEDS_IORAttribute) ior;
132 if (!_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),ior) )
134 TCollection_AsciiString ch(ior->Get());
135 IOR = CORBA::string_dup(ch.ToCString());
140 //============================================================================
144 //============================================================================
145 Standard_Boolean SALOMEDS_SComponent_i::IsA(const TDF_Label& Lab)
147 Handle(TDF_Attribute) Att;
148 // scomponent must contain comment and belong to the 2th depth label
149 if ( Lab.FindAttribute(TDataStd_Comment::GetID(), Att) && Lab.Depth() == 2) {
150 return Standard_True;
152 return Standard_False;