Back to index

salome-kernel  6.5.0
DF_definitions.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef  DF_DEF_HXX
00021 #define  DF_DEF_HXX
00022 
00023 #ifdef WIN32
00024 # if defined DF_EXPORTS
00025 #  define DF_EXPORT __declspec( dllexport )
00026 # else
00027 #  define DF_EXPORT __declspec( dllimport )
00028 # endif
00029 #else
00030 # define DF_EXPORT
00031 #endif
00032 
00033 #include <iostream> 
00034 #include <stdio.h>
00035 #include <boost/shared_ptr.hpp> 
00036 
00037 template<class T> class df_shared_ptr: public boost::shared_ptr<T>
00038 {
00039 public:
00040   df_shared_ptr() {}
00041   
00042   template<class Y>
00043     explicit df_shared_ptr(Y * p)
00044       {
00045         boost::shared_ptr<T>::reset(p);
00046       }
00047   
00048   template<class Y>
00049     df_shared_ptr(df_shared_ptr<Y> const & r):
00050       boost::shared_ptr<T>(r,boost::detail::dynamic_cast_tag())
00051         {}
00052   
00053   template<class Y>
00054     df_shared_ptr & operator=(df_shared_ptr<Y> const & r)
00055       {
00056         df_shared_ptr<T>(r).swap(*this);
00057         return *this;
00058       }
00059   
00060   template<class Y> df_shared_ptr& operator()(Y * p) // Y must be complete
00061     {
00062       if(T* pt = dynamic_cast<T*>(p))
00063         boost::shared_ptr<T>::reset(pt);
00064       else
00065         boost::throw_exception(std::bad_cast());
00066       return *this;
00067     }
00068     
00069 };
00070 
00071 # if defined(WIN32) && !defined(HAVE_NO_DLL)
00072 
00073 #  ifndef Standard_EXPORT
00074 #   define Standard_EXPORT __declspec( dllexport )
00075 // For global variables :
00076 #   define Standard_EXPORTEXTERN __declspec( dllexport ) extern
00077 #   define Standard_EXPORTEXTERNC extern "C" __declspec( dllexport )
00078 #  endif  /* Standard_EXPORT */
00079 
00080 #  ifndef Standard_IMPORT
00081 #   define Standard_IMPORT __declspec( dllimport ) extern
00082 #   define Standard_IMPORTC extern "C" __declspec( dllimport )
00083 #  endif  /* Standard_IMPORT */
00084 
00085 # else  /* WIN32 */
00086 
00087 #  ifndef Standard_EXPORT
00088 #   define Standard_EXPORT
00089 // For global variables :
00090 #   define Standard_EXPORTEXTERN extern
00091 #   define Standard_EXPORTEXTERNC extern "C"
00092 #  endif  /* Standard_EXPORT */
00093 
00094 #  ifndef Standard_IMPORT
00095 #   define Standard_IMPORT extern
00096 #   define Standard_IMPORTC extern "C"
00097 #  endif  /* Standard_IMPORT */
00098 
00099 # endif  /* WIN32 */
00100 
00101 # ifndef __Standard_API
00102 //#  ifdef WIN32
00103 #   if !defined(WIN32) 
00104 #    define __Standard_API Standard_EXPORT
00105 #    define __Standard_APIEXTERN Standard_EXPORTEXTERN
00106 #   else
00107 #    define __Standard_API Standard_IMPORT
00108 #    define __Standard_APIEXTERN Standard_IMPORT
00109 #   endif  // __Standard_DLL
00110 //#  else
00111 //#   define __Standard_API
00112 //#  endif  // WIN32
00113 # endif  // __Standard_API
00114 
00115 #include <iostream>
00116 class Standard_EXPORT DFexception
00117 {
00118 public :
00119   DFexception(const char *message) {
00120     std::cerr << message << std::endl;
00121   }
00122 }; 
00123 
00124 
00125 #endif