Content


NTL
Core
CReleasable

CReleasable



Implementation of releasable object. If a class can be released/destroyed it can be derived from this class. As a result it will have Release() method which can be used to destroy class instance. This is preferred way of destroying classes accessed via their interfaces. When working with interfaces using destructor directly is forbidden.

You can find more information in comments below. Overrided methods can be found in corresponding base interface.

class CReleasable :public virtual IReleasable
{
protected:
    std::vector<IReleasableListener *> m_aReleaseListeners;
            
    virtual void BeforeRelease(); // Called before releasing object 
public:
    // IReleasable listeners 
    bool RegisterReleaseListener(IReleasableListener *listener) override;
    bool UnregisterReleaseListener(IReleasableListener *listener) override;
    
    // IReleasable methods 
    int AddRef() override;
    bool Release(const bool force = false) override;

    CReleasable();
    virtual ~CReleasable() = default;
};
Namespace: nitisa
Include: Nitisa/Core/Releasable.h