#ifndef __JLANG__JPOINTER__ #define __JLANG__JPOINTER__ #include "JLang/JAbstractPointer.hh" /** * \author mdejong */ namespace JLANG {} namespace JPP { using namespace JLANG; } namespace JLANG { /** * Template implementation of class that holds pointer to object(s). * * This class implements the JAbstractPointer interface. */ template class JPointer : public JAbstractPointer { public: using JAbstractPointer::set; using JAbstractPointer::reset; /** * Default constructor. */ JPointer() : __p(NULL) {} /** * Constructor. * * \param p pointer to object */ JPointer(JClass_t* p) : __p(p) {} /** * Constructor. * * \param pointer pointer to object */ template JPointer(JPointer pointer) : __p(pointer.get()) {} /** * Get pointer. * * \return pointer to object */ virtual JClass_t* get() const override { return this->__p; } /** * Set pointer. * * \param p pointer to object */ virtual void set(JClass_t* p) override { this->__p = p; } /** * Reset pointer. */ virtual void reset() override { this->__p = NULL; } /** * Set pointer. * * \param pointer pointer to object */ template void set(const JPointer& pointer) { this->set(pointer.get()); } /** * Reset pointer. * * \param pointer pointer to object */ template void reset(const JPointer& pointer) { this->reset(pointer.get()); } /** * Get rereference to internal pointer. * * \return reference to internal pointer */ JClass_t* const& getReference() const { return __p; } /** * Get rereference to internal pointer. * * \return reference to internal pointer */ JClass_t* & getReference() { return __p; } protected: JClass_t* __p; //!< pointer to object }; } #endif