1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- // ExclusiveHolder.tli
- //
- #pragma once
- #include "ExclusiveHolder.tlh"
- template <typename T>
- ExclusiveHolder <T>::ExclusiveHolder ()
- {
- m_pObject = NULL;
- }
- template <typename T>
- ExclusiveHolder <T>::~ExclusiveHolder ()
- {
- LockHolder Lock (this);
- delete m_pObject;
- }
- template <typename T>
- ExclusiveHolder <T>::ExclusiveHolder (T * object)
- {
- m_pObject = object;
- }
- template <typename T>
- void ExclusiveHolder <T>::Attach (T * object)
- {
- LockHolder Lock (this);
- delete m_pObject;
- m_pObject = object;
- }
- template <typename T>
- T * ExclusiveHolder <T>::Detach ()
- {
- LockHolder Lock (this);
- T * old = m_pObject;
- m_pObject = NULL;
- Release ();
- return old;
- }
- template <typename T>
- void ExclusiveHolder <T>::Release ()
- {
- LockHolder Lock (this);
- delete m_pObject;
- m_pObject = NULL;
- }
- template <typename T>
- ExclusiveHolder <T> & ExclusiveHolder <T>::operator = (T * object)
- {
- Attach (object);
- return *this;
- }
- template <typename T>
- bool ExclusiveHolder <T>::IsEmpty () const
- {
- LockHolder Lock (this);
- return (m_pObject == NULL);
- }
|