Skip to content

Commit

Permalink
Gui: add convenient smart pointer CoinPtr to manager coin node
Browse files Browse the repository at this point in the history
  • Loading branch information
realthunder committed Jul 14, 2019
1 parent 6286db2 commit 54932f4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Gui/ViewProvider.h
Expand Up @@ -30,6 +30,7 @@
#include <bitset>
#include <QIcon>
#include <boost/signals2.hpp>
#include <boost/intrusive_ptr.hpp>

#include <App/TransactionalObject.h>
#include <Base/Vector3D.h>
Expand Down Expand Up @@ -77,6 +78,26 @@ enum ViewStatus {
};


/** Convenience smart pointer to wrap coin node.
*
* It is basically boost::intrusive plus implicit pointer conversion to save the
* trouble of typing get() all the time.
*/
template<class T>
class CoinPtr: public boost::intrusive_ptr<T> {
public:
// Too bad, VC2013 does not support constructor inheritance
//using boost::intrusive_ptr<T>::intrusive_ptr;
typedef boost::intrusive_ptr<T> inherited;
CoinPtr() {}
CoinPtr(T *p, bool add_ref=true):inherited(p,add_ref){}
template<class Y> CoinPtr(CoinPtr<Y> const &r):inherited(r){}

operator T *() const {
return this->get();
}
};


/** General interface for all visual stuff in FreeCAD
* This class is used to generate and handle all around
Expand Down

0 comments on commit 54932f4

Please sign in to comment.