// XDWExclusiveHolder.tli // #pragma once #include "XDWExclusiveHolder.tlh" template XDWExclusiveHolder ::XDWExclusiveHolder () { m_pObject = NULL; } template XDWExclusiveHolder ::~XDWExclusiveHolder () { LockHolder Lock (this); delete m_pObject; } template XDWExclusiveHolder ::XDWExclusiveHolder (T * object) { m_pObject = object; } template void XDWExclusiveHolder ::Attach (T * object) { LockHolder Lock (this); delete m_pObject; m_pObject = object; } template T * XDWExclusiveHolder ::Detach () { LockHolder Lock (this); T * over = m_pObject; m_pObject = NULL; Release (); return over; } template void XDWExclusiveHolder ::Release () { LockHolder Lock (this); delete m_pObject; m_pObject = NULL; } template XDWExclusiveHolder & XDWExclusiveHolder ::operator = (T * object) { Attach (object); return *this; } template bool XDWExclusiveHolder ::IsEmpty () const { LockHolder Lock (this); return (m_pObject == NULL); } template XDWExclusiveHolder ::LockHolder::LockHolder (const XDWExclusiveHolder *holder) { auto lock = new std::lock_guard < std::recursive_mutex > (holder->m_Mutex); m_Lock.Attach (lock); m_Holder = holder; } template XDWExclusiveHolder ::LockHolder::LockHolder (const LockHolder & h) { m_Lock = h.m_Lock; m_Holder = h.m_Holder; } template XDWExclusiveHolder ::LockHolder::~LockHolder () { // m_Lock->Unlock (); } /* template void XDWExclusiveHolder ::LockHolder::Unlock () { m_Lock->Unlock (); } */ template T * XDWExclusiveHolder ::LockHolder::As () { return m_Holder->m_pObject; } template const T * XDWExclusiveHolder ::LockHolder::As () const { return m_Holder->m_pObject; } template template C * XDWExclusiveHolder ::LockHolder::AS () { return m_Holder->m_pObject; } template template const C * XDWExclusiveHolder ::LockHolder::AS () const { return m_Holder->m_pObject; }