Salome HOME
2176ff1d37711c88ac450552a95dbfda78eb464a
[modules/kernel.git] / src / SALOMEDSClient / SALOMEDSClient_definitions.hxx
1 #ifndef  SALOMEDSCLIENT_DEF_HXX
2 #define  SALOMEDSCLIENT_DEF_HXX
3
4 #include <boost/shared_ptr.hpp> 
5
6 template<class T> class clt_shared_ptr: public boost::shared_ptr<T>
7 {
8 public:
9   clt_shared_ptr() {}
10   
11   template<class Y>
12     explicit clt_shared_ptr(Y * p)
13       {
14         reset(p);
15       }
16   
17   template<class Y>
18     clt_shared_ptr(clt_shared_ptr<Y> const & r):
19       boost::shared_ptr<T>(r,boost::detail::dynamic_cast_tag())
20         {}
21   
22   template<class Y>
23     clt_shared_ptr & operator=(clt_shared_ptr<Y> const & r)
24       {
25         clt_shared_ptr<T>(r).swap(*this);
26         return *this;
27       }
28   
29   template<class Y> clt_shared_ptr& operator()(Y * p) // Y must be complete
30     {
31       if(T* pt = dynamic_cast<T*>(p))
32         boost::shared_ptr<T>::reset(pt);
33       else
34         boost::throw_exception(std::bad_cast());
35       return *this;
36     }
37     
38 };
39
40 #define _PTR(Class) clt_shared_ptr<SALOMEDSClient_##Class>
41 #define _CAST(Class, shared_ptr_Obj) dynamic_cast<SALOMEDS_##Class*>(shared_ptr_Obj.get())
42
43 struct STextColor
44 {
45     double R;
46     double G;
47     double B;
48 };
49
50 #endif