1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAPI_Interface.hxx
4 // Created: 23 Apr 2014
5 // Author: Mikhail PONIKAROV
7 #ifndef GeomAPI_Interface_H_
8 #define GeomAPI_Interface_H_
14 /**\class GeomAPI_Interface
16 * \brief General base class for all interfaces in this package
20 void GeomAPI_deleter( void* p ) {
21 delete reinterpret_cast<T*>(p);
24 class GeomAPI_Interface
27 std::shared_ptr<char> myImpl; ///< pointer to the internal impl object
30 /// None - constructor
31 GEOMAPI_EXPORT GeomAPI_Interface();
33 /// Constructor by the impl pointer (used for internal needs)
34 template<class T> explicit GeomAPI_Interface(T* theImpl)
36 myImpl = std::shared_ptr<char>(reinterpret_cast<char*>(theImpl), GeomAPI_deleter<T>);
40 GEOMAPI_EXPORT virtual ~GeomAPI_Interface();
42 /// Returns the pointer to the impl
43 template<class T> inline T* implPtr()
45 return reinterpret_cast<T*>(myImpl.get());
47 /// Returns the pointer to the impl
48 template<class T> inline const T* implPtr() const
50 return reinterpret_cast<T*>(myImpl.get());
52 /// Returns the reference object of the impl
53 template<class T> inline const T& impl() const
55 return *(reinterpret_cast<T*>(myImpl.get()));
57 /// Updates the impl (deletes the old one)
58 template<class T> inline void setImpl(T* theImpl)
60 myImpl = std::shared_ptr<char>(reinterpret_cast<char*>(theImpl), GeomAPI_deleter<T>);
63 /// Returns true if the impl is empty
64 GEOMAPI_EXPORT bool empty() const;