Back to index

salome-med  6.5.0
MED_SharedPtr.hxx
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   : 
00024 //  Author : 
00025 //  Module : 
00026 //  $Header: /home/server/cvs/MED/MED_SRC/src/MEDWrapper/Base/MED_SharedPtr.hxx,v 1.5.20.2.10.1 2012-04-13 08:48:43 vsr Exp $
00027 //
00028 #ifndef MED_SharedPtr_HeaderFile
00029 #define MED_SharedPtr_HeaderFile
00030 
00031 #include <boost/shared_ptr.hpp>
00032 
00033 namespace MED
00034 {
00035 
00037 
00042   template<class T> class SharedPtr: public boost::shared_ptr<T>
00043   {
00044   public:
00046     SharedPtr() {}
00047 
00049     template<class Y>
00050     explicit SharedPtr(Y * p): 
00051       boost::shared_ptr<T>(p) 
00052     {}
00053 
00055     template<class Y>
00056     SharedPtr(SharedPtr<Y> const & r):
00057       boost::shared_ptr<T>(r,boost::detail::dynamic_cast_tag())
00058     {}
00059 
00061     template<class Y>
00062     SharedPtr& 
00063     operator=(SharedPtr<Y> const & r)
00064     {
00065       boost::shared_ptr<T>(r,boost::detail::dynamic_cast_tag()).swap(*this);
00066       return *this;
00067     }
00068 
00070     template<class Y> 
00071     SharedPtr& 
00072     operator()(Y * p) // Y must be complete
00073     {
00074       return operator=<Y>(SharedPtr<Y>(p));
00075     }
00076 
00078     template<class Y> 
00079     SharedPtr& 
00080     operator()(SharedPtr<Y> const & r) // Y must be complete
00081     {
00082       return operator=<Y>(SharedPtr<Y>(r));
00083     }
00084 
00086     operator const T& () const 
00087     { 
00088       return *(this->get());
00089     }
00090 
00092     operator T& () 
00093     { 
00094       return *(this->get());
00095     }
00096   };
00097 
00098 }
00099 
00100 
00101 #endif