Back to index

salome-kernel  6.5.0
SALOMEDSClient_definitions.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 #ifndef  SALOMEDSCLIENT_DEF_HXX
00024 #define  SALOMEDSCLIENT_DEF_HXX
00025 
00026 #ifdef WIN32
00027 # if defined SALOMEDSCLIENT_EXPORTS || defined SalomeDSClient_EXPORTS
00028 #  define SALOMEDSCLIENT_EXPORT __declspec( dllexport )
00029 # else
00030 #  define SALOMEDSCLIENT_EXPORT __declspec( dllimport )
00031 # endif
00032 #else
00033 # define SALOMEDSCLIENT_EXPORT
00034 #endif
00035 
00036 #include <boost/shared_ptr.hpp> 
00037 
00038 template<class T> class clt_shared_ptr: public boost::shared_ptr<T>
00039 {
00040 public:
00041   clt_shared_ptr() {}
00042   
00043   template<class Y>
00044     explicit clt_shared_ptr(Y * p)
00045       {
00046         boost::shared_ptr<T>::reset(p);
00047       }
00048   
00049   template<class Y>
00050     clt_shared_ptr(clt_shared_ptr<Y> const & r):
00051       boost::shared_ptr<T>(r,boost::detail::dynamic_cast_tag())
00052         {}
00053   
00054   template<class Y>
00055     clt_shared_ptr & operator=(clt_shared_ptr<Y> const & r)
00056       {
00057         clt_shared_ptr<T>(r).swap(*this);
00058         return *this;
00059       }
00060   
00061   template<class Y> clt_shared_ptr& operator()(Y * p) // Y must be complete
00062     {
00063       if(T* pt = dynamic_cast<T*>(p))
00064         boost::shared_ptr<T>::reset(pt);
00065       else
00066         boost::throw_exception(std::bad_cast());
00067       return *this;
00068     }
00069     
00070 };
00071 
00072 #define _PTR(Class) clt_shared_ptr<SALOMEDSClient_##Class>
00073 #define _CAST(Class, shared_ptr_Obj) dynamic_cast<SALOMEDS_##Class*>(shared_ptr_Obj.get())
00074 
00075 struct STextColor
00076 {
00077     double R;
00078     double G;
00079     double B;
00080 };
00081 
00082 #endif