Back to index

salome-kernel  6.5.0
SALOMEDS_UseCaseBuilder_i.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : SALOMEDS_UseCaseBuilder_i.cxx
00024 //  Author : Sergey RUIN
00025 //  Module : SALOME
00026 
00027 #include "SALOMEDS_UseCaseBuilder_i.hxx"
00028 #include "SALOMEDS_UseCaseIterator_i.hxx"
00029 #include "SALOMEDS_SObject_i.hxx"  
00030 #include "SALOMEDS.hxx"
00031 
00032 #include "utilities.h"
00033 
00034 //============================================================================
00038 //============================================================================
00039 SALOMEDS_UseCaseBuilder_i::SALOMEDS_UseCaseBuilder_i(SALOMEDSImpl_UseCaseBuilder* theImpl,
00040                                                      CORBA::ORB_ptr orb)
00041 {
00042   _orb = CORBA::ORB::_duplicate(orb);
00043   _impl = theImpl;
00044 }
00045 
00046 //============================================================================
00050 //============================================================================
00051 SALOMEDS_UseCaseBuilder_i::~SALOMEDS_UseCaseBuilder_i()
00052 {
00053 }
00054 
00055 
00056 //============================================================================
00060 //============================================================================
00061 CORBA::Boolean SALOMEDS_UseCaseBuilder_i::Append(SALOMEDS::SObject_ptr theObject)
00062 {
00063   SALOMEDS::Locker lock;
00064   if(!_impl || theObject->_is_nil()) return 0;
00065   return _impl->Append(_impl->GetSObject(theObject->GetID()));
00066 }
00067 
00068  //============================================================================
00072 //============================================================================
00073 CORBA::Boolean SALOMEDS_UseCaseBuilder_i::Remove(SALOMEDS::SObject_ptr theObject)
00074 {
00075   SALOMEDS::Locker lock;
00076   if(!_impl || theObject->_is_nil()) return 0;
00077   return _impl->Remove(_impl->GetSObject(theObject->GetID()));
00078 }
00079 
00080 
00081 //============================================================================
00085 //============================================================================
00086 CORBA::Boolean SALOMEDS_UseCaseBuilder_i::AppendTo(SALOMEDS::SObject_ptr theFather, 
00087                                                    SALOMEDS::SObject_ptr theObject)
00088 {
00089   SALOMEDS::Locker lock;
00090   if(!_impl || theFather->_is_nil() || theObject->_is_nil()) return 0;
00091   return _impl->AppendTo(_impl->GetSObject(theFather->GetID()), _impl->GetSObject(theObject->GetID()));
00092 }
00093 
00094 //============================================================================
00098 //============================================================================
00099 CORBA::Boolean SALOMEDS_UseCaseBuilder_i::InsertBefore(SALOMEDS::SObject_ptr theFirst, 
00100                                                        SALOMEDS::SObject_ptr theNext)
00101 {
00102   SALOMEDS::Locker lock;
00103   if(!_impl || theFirst->_is_nil() || theNext->_is_nil()) return 0;
00104   return _impl->InsertBefore(_impl->GetSObject(theFirst->GetID()), _impl->GetSObject(theNext->GetID()));
00105 }
00106 
00107 
00108 //============================================================================
00112 //============================================================================
00113 CORBA::Boolean SALOMEDS_UseCaseBuilder_i::SetCurrentObject(SALOMEDS::SObject_ptr theObject)
00114 {
00115   SALOMEDS::Locker lock;
00116   if(!_impl || theObject->_is_nil()) return 0;
00117   return _impl->SetCurrentObject(_impl->GetSObject(theObject->GetID()));
00118 }
00119 
00120 //============================================================================
00124 //============================================================================
00125 CORBA::Boolean SALOMEDS_UseCaseBuilder_i::SetRootCurrent()
00126 {
00127   SALOMEDS::Locker lock;
00128   if(!_impl) return 0;
00129   return _impl->SetRootCurrent();
00130 }
00131 
00132 //============================================================================
00136 //============================================================================
00137 CORBA::Boolean SALOMEDS_UseCaseBuilder_i::HasChildren(SALOMEDS::SObject_ptr theObject)
00138 {
00139   SALOMEDS::Locker lock;
00140   if(!_impl) return 0;
00141   return _impl->HasChildren(_impl->GetSObject(theObject->GetID()));
00142 }
00143 
00144 //============================================================================
00148 //============================================================================
00149 SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::GetFather(SALOMEDS::SObject_ptr theObject)
00150 {
00151   SALOMEDS::Locker lock; 
00152 
00153   if(!_impl) return NULL;
00154   SALOMEDSImpl_SObject aSO = _impl->GetFather(_impl->GetSObject(theObject->GetID()));
00155   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
00156   return so._retn();
00157 }
00158 
00159 //============================================================================
00163 //============================================================================
00164 CORBA::Boolean SALOMEDS_UseCaseBuilder_i::SetName(const char* theName) 
00165 {
00166   SALOMEDS::Locker lock;
00167   if(!_impl) return 0;
00168   return _impl->SetName((char*)theName);
00169 }
00170 
00171 
00172 //============================================================================
00176 //============================================================================
00177 SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::GetCurrentObject()
00178 {
00179   SALOMEDS::Locker lock; 
00180   
00181   if(!_impl) return NULL;
00182   SALOMEDSImpl_SObject aSO = _impl->GetCurrentObject();
00183   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
00184   return so._retn();
00185 }
00186 
00187 //============================================================================
00191 //============================================================================
00192 char* SALOMEDS_UseCaseBuilder_i::GetName() 
00193 {
00194   SALOMEDS::Locker lock;
00195   return CORBA::string_dup(_impl->GetName().c_str());
00196 }
00197 
00198 //============================================================================ 
00202 //============================================================================ 
00203 CORBA::Boolean SALOMEDS_UseCaseBuilder_i::IsUseCase(SALOMEDS::SObject_ptr theObject)
00204 {
00205   SALOMEDS::Locker lock;
00206   
00207   if(!_impl || theObject->_is_nil()) return false;
00208   return _impl->IsUseCase(_impl->GetSObject(theObject->GetID()));
00209 }
00210 
00211 //============================================================================ 
00215 //============================================================================ 
00216 CORBA::Boolean SALOMEDS_UseCaseBuilder_i::IsUseCaseNode(SALOMEDS::SObject_ptr theObject)
00217 {
00218   SALOMEDS::Locker lock;
00219   
00220   if(!_impl || theObject->_is_nil()) return false;
00221   return _impl->IsUseCaseNode(_impl->GetSObject(theObject->GetID()));
00222 }
00223 
00224 //============================================================================ 
00228 //============================================================================ 
00229 SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::AddUseCase(const char* theName)
00230 {
00231   SALOMEDS::Locker lock;
00232   
00233   if(!_impl) return SALOMEDS::SObject::_nil();
00234   SALOMEDSImpl_SObject aSO = _impl->AddUseCase((char*)theName);
00235   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
00236   return so._retn();
00237 }
00238 
00239 //============================================================================
00243 //============================================================================
00244 SALOMEDS::UseCaseIterator_ptr SALOMEDS_UseCaseBuilder_i::GetUseCaseIterator(SALOMEDS::SObject_ptr theObject) 
00245 {
00246   SALOMEDS::Locker lock;
00247   
00248   if(!_impl) return SALOMEDS::UseCaseIterator::_nil();
00249   SALOMEDSImpl_UseCaseIterator anItr;
00250   if(!CORBA::is_nil(theObject)) anItr = _impl->GetUseCaseIterator(_impl->GetSObject(theObject->GetID()));
00251   else anItr = _impl->GetUseCaseIterator(SALOMEDSImpl_SObject());
00252   SALOMEDS_UseCaseIterator_i* aServant = new SALOMEDS_UseCaseIterator_i(anItr, _orb);
00253   SALOMEDS::UseCaseIterator_var anIterator = SALOMEDS::UseCaseIterator::_narrow(aServant->_this());
00254   return anIterator._retn(); 
00255 }