Salome HOME
Update copyrights 2014.
[modules/kernel.git] / src / DF / DF_definitions.hxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef  DF_DEF_HXX
21 #define  DF_DEF_HXX
22
23 #ifdef WIN32
24 # if defined DF_EXPORTS
25 #  define DF_EXPORT __declspec( dllexport )
26 # else
27 #  define DF_EXPORT __declspec( dllimport )
28 # endif
29 #else
30 # define DF_EXPORT
31 #endif
32
33 #include <iostream> 
34 #include <stdio.h>
35 #include <boost/shared_ptr.hpp> 
36
37 template<class T> class df_shared_ptr: public boost::shared_ptr<T>
38 {
39 public:
40   df_shared_ptr() {}
41   
42   template<class Y>
43     explicit df_shared_ptr(Y * p)
44       {
45         boost::shared_ptr<T>::reset(p);
46       }
47   
48   template<class Y>
49     df_shared_ptr(df_shared_ptr<Y> const & r):
50       boost::shared_ptr<T>(r,boost::detail::dynamic_cast_tag())
51         {}
52   
53   template<class Y>
54     df_shared_ptr & operator=(df_shared_ptr<Y> const & r)
55       {
56         df_shared_ptr<T>(r).swap(*this);
57         return *this;
58       }
59   
60   template<class Y> df_shared_ptr& operator()(Y * p) // Y must be complete
61     {
62       if(T* pt = dynamic_cast<T*>(p))
63         boost::shared_ptr<T>::reset(pt);
64       else
65         boost::throw_exception(std::bad_cast());
66       return *this;
67     }
68     
69 };
70
71 # if defined(WIN32) && !defined(HAVE_NO_DLL)
72
73 #  ifndef Standard_EXPORT
74 #   define Standard_EXPORT __declspec( dllexport )
75 // For global variables :
76 #   define Standard_EXPORTEXTERN __declspec( dllexport ) extern
77 #   define Standard_EXPORTEXTERNC extern "C" __declspec( dllexport )
78 #  endif  /* Standard_EXPORT */
79
80 #  ifndef Standard_IMPORT
81 #   define Standard_IMPORT __declspec( dllimport ) extern
82 #   define Standard_IMPORTC extern "C" __declspec( dllimport )
83 #  endif  /* Standard_IMPORT */
84
85 # else  /* WIN32 */
86
87 #  ifndef Standard_EXPORT
88 #   define Standard_EXPORT
89 // For global variables :
90 #   define Standard_EXPORTEXTERN extern
91 #   define Standard_EXPORTEXTERNC extern "C"
92 #  endif  /* Standard_EXPORT */
93
94 #  ifndef Standard_IMPORT
95 #   define Standard_IMPORT extern
96 #   define Standard_IMPORTC extern "C"
97 #  endif  /* Standard_IMPORT */
98
99 # endif  /* WIN32 */
100
101 # ifndef __Standard_API
102 //#  ifdef WIN32
103 #   if !defined(WIN32) 
104 #    define __Standard_API Standard_EXPORT
105 #    define __Standard_APIEXTERN Standard_EXPORTEXTERN
106 #   else
107 #    define __Standard_API Standard_IMPORT
108 #    define __Standard_APIEXTERN Standard_IMPORT
109 #   endif  // __Standard_DLL
110 //#  else
111 //#   define __Standard_API
112 //#  endif  // WIN32
113 # endif  // __Standard_API
114
115 #include <iostream>
116 class Standard_EXPORT DFexception
117 {
118 public :
119   DFexception(const char *message) {
120     std::cerr << message << std::endl;
121   }
122 }; 
123
124
125 #endif