1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 // File : SALOMEDS_UseCaseBuilder.cxx
21 // Author : Sergey RUIN
26 #include "SALOMEDS_UseCaseBuilder.hxx"
28 #include "SALOMEDSImpl_SObject.hxx"
29 #include "SALOMEDS_SObject.hxx"
30 #include "SALOMEDSImpl_UseCaseIterator.hxx"
31 #include "SALOMEDS_UseCaseIterator.hxx"
32 #include <TCollection_AsciiString.hxx>
37 SALOMEDS_UseCaseBuilder::SALOMEDS_UseCaseBuilder(const Handle(SALOMEDSImpl_UseCaseBuilder)& theBuilder)
40 _local_impl = theBuilder;
41 _corba_impl = SALOMEDS::UseCaseBuilder::_nil();
44 SALOMEDS_UseCaseBuilder::SALOMEDS_UseCaseBuilder(SALOMEDS::UseCaseBuilder_ptr theBuilder)
48 _corba_impl = SALOMEDS::UseCaseBuilder::_duplicate(theBuilder);
51 SALOMEDS_UseCaseBuilder::~SALOMEDS_UseCaseBuilder()
53 if(!_isLocal) _corba_impl->Destroy();
56 bool SALOMEDS_UseCaseBuilder::Append(const _PTR(SObject)& theObject)
59 SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
60 if(_isLocal) ret = _local_impl->Append(obj->GetLocalImpl());
61 else ret = _corba_impl->Append(obj->GetCORBAImpl());
65 bool SALOMEDS_UseCaseBuilder::Remove(const _PTR(SObject)& theObject)
68 SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
69 if(_isLocal) ret = _local_impl->Remove(obj->GetLocalImpl());
70 else ret = _corba_impl->Remove(obj->GetCORBAImpl());
74 bool SALOMEDS_UseCaseBuilder::AppendTo(const _PTR(SObject)& theFather, _PTR(SObject) theObject)
77 SALOMEDS_SObject* father = dynamic_cast<SALOMEDS_SObject*>(theFather.get());
78 SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
79 if(_isLocal) ret = _local_impl->AppendTo(father->GetLocalImpl(), obj->GetLocalImpl());
80 else ret = _corba_impl->AppendTo(father->GetCORBAImpl(), obj->GetCORBAImpl());
84 bool SALOMEDS_UseCaseBuilder::InsertBefore(const _PTR(SObject)& theFirst, _PTR(SObject) theNext)
87 SALOMEDS_SObject* first = dynamic_cast<SALOMEDS_SObject*>(theFirst.get());
88 SALOMEDS_SObject* next = dynamic_cast<SALOMEDS_SObject*>(theNext.get());
89 if(_isLocal) ret = _local_impl->InsertBefore(first->GetLocalImpl(), next->GetLocalImpl());
90 else ret = _corba_impl->InsertBefore(first->GetCORBAImpl(), next->GetCORBAImpl());
94 bool SALOMEDS_UseCaseBuilder::SetCurrentObject(const _PTR(SObject)& theObject)
97 SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
98 if(_isLocal) ret = _local_impl->SetCurrentObject(obj->GetLocalImpl());
99 else ret = _corba_impl->SetCurrentObject(obj->GetCORBAImpl());
103 bool SALOMEDS_UseCaseBuilder::SetRootCurrent()
106 if(_isLocal) ret = _local_impl->SetRootCurrent();
107 else ret = _corba_impl->SetRootCurrent();
111 bool SALOMEDS_UseCaseBuilder::HasChildren(const _PTR(SObject)& theObject)
114 SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
115 if(_isLocal) ret = _local_impl->HasChildren(obj->GetLocalImpl());
116 else ret = _corba_impl->HasChildren(obj->GetCORBAImpl());
120 bool SALOMEDS_UseCaseBuilder::IsUseCase(const _PTR(SObject)& theObject)
123 SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
124 if(_isLocal) ret = _local_impl->IsUseCase(obj->GetLocalImpl());
125 else ret = _corba_impl->IsUseCase(obj->GetCORBAImpl());
129 bool SALOMEDS_UseCaseBuilder::SetName(const std::string& theName)
132 if(_isLocal) ret = _local_impl->SetName((char*)theName.c_str());
133 else ret = _corba_impl->SetName((char*)theName.c_str());
137 _PTR(SObject) SALOMEDS_UseCaseBuilder::GetCurrentObject()
139 SALOMEDS_SObject* obj = NULL;
140 if(_isLocal) obj = new SALOMEDS_SObject(_local_impl->GetCurrentObject());
141 else obj = new SALOMEDS_SObject(_corba_impl->GetCurrentObject());
142 return _PTR(SObject)(obj);
145 std::string SALOMEDS_UseCaseBuilder::GetName()
148 if(_isLocal) aName = _local_impl->GetName().ToCString();
149 else aName = _corba_impl->GetName();
153 _PTR(SObject) SALOMEDS_UseCaseBuilder::AddUseCase(const std::string& theName)
155 SALOMEDS_SObject* obj = NULL;
156 if(_isLocal) obj = new SALOMEDS_SObject(_local_impl->AddUseCase((char*)theName.c_str()));
157 else obj = new SALOMEDS_SObject(_corba_impl->AddUseCase((char*)theName.c_str()));
158 return _PTR(SObject)(obj);
161 _PTR(UseCaseIterator) SALOMEDS_UseCaseBuilder::GetUseCaseIterator(const _PTR(SObject)& theObject)
163 SALOMEDS_UseCaseIterator* it = NULL;
164 SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
165 if(_isLocal) it = new SALOMEDS_UseCaseIterator(_local_impl->GetUseCaseIterator(obj->GetLocalImpl()));
166 else it = new SALOMEDS_UseCaseIterator(_corba_impl->GetUseCaseIterator(obj->GetCORBAImpl()));
167 return _PTR(UseCaseIterator)(it);