#pragma once #include #include #include "XDWExclusiveHolder.tlh" #include "XDWExclusiveHolder.tli" #include "VectorOfPtr.tlh" #include "ListOfPtr.tlh" #include "Iterator.tlh" //----------------------------------------------------------------------------- // ExclusiveListOfPtr //----------------------------------------------------------------------------- template class ExclusiveListOfPtr : public XDWExclusiveHolder > { typedef XDWExclusiveHolder > inherited; public: using container = ListOfPtr ; using reference = typename ListOfPtr ::reference; using const_reference = typename ListOfPtr ::const_reference; using const_iterator = typename ListOfPtr ::const_iterator; public: ExclusiveListOfPtr () { Attach (new ListOfPtr ()); } public: bool IsEmpty () const { LockHolder Lock (this); if (m_pObject == NULL) return true; return m_pObject->empty (); } template void LockForEach (Action action) { LockHolder holder (this); for (auto Iter = Iterator::From (holder.As ()); Iter; Iter ++) { action (Iter ()); } } template int LockForEachIf (Action action) { LockHolder holder (this); for (auto Iter = Iterator::From (holder.As ()); Iter; Iter ++) { if (! action (Iter ())) return Iter.Index (); } return -1; } }; //----------------------------------------------------------------------------- // ExclusiveVectorOfPtr //----------------------------------------------------------------------------- template class ExclusiveVectorOfPtr : public XDWExclusiveHolder > { typedef XDWExclusiveHolder > inherited; public: using container = ListOfPtr ; using reference = typename VectorOfPtr ::reference; using const_reference = typename VectorOfPtr ::const_reference; using const_iterator = typename VectorOfPtr ::const_iterator; public: ExclusiveVectorOfPtr () { Attach (new VectorOfPtr ()); } public: bool IsEmpty () const { LockHolder Lock (this); if (m_pObject == NULL) return true; return m_pObject->empty (); } template void LockForEach (Action action) { LockHolder holder (this); for (auto Iter = Iterator::From (holder.As ()); Iter; Iter ++) { action (Iter ()); } } template int LockForEachIf (Action action) { LockHolder holder (this); for (auto Iter = Iterator::From (holder.As ()); Iter; Iter ++) { if (! action (Iter ())) return Iter.Index (); } return -1; } };