// // SproxyColl.h // // Copyright (c) Microsoft Corporation. All rights reserved. // #pragma once #include "stdafx.h" template > class CAtlPtrList : public CAtlList { private: typedef CAtlList Base; BOOL m_bAttached; public: CAtlPtrList() :m_bAttached(TRUE) { } void Detach() { m_bAttached = FALSE; } void RemoveAll() { if (m_bAttached) { POSITION pos = GetHeadPosition(); while (pos != NULL) { delete (GetAt(pos)); GetAt(pos) = NULL; GetNext(pos); } } Base::RemoveAll(); } ~CAtlPtrList() { RemoveAll(); } }; // class CAtlPtrList template , class VTraits = CElementTraits > class CAtlPtrMap : public CAtlMap { private: typedef CAtlMap Base; BOOL m_bAttached; public: CAtlPtrMap() :m_bAttached(TRUE) { } void Detach() { m_bAttached = FALSE; } void RemoveAll() { Base::DisableAutoRehash(); if (m_bAttached) { POSITION pos = GetStartPosition(); while (pos != NULL) { delete (GetValueAt(pos)); GetValueAt(pos) = NULL; GetNext(pos); } } Base::RemoveAll(); Base::EnableAutoRehash(); } ~CAtlPtrMap() { RemoveAll(); } }; // class CAtlPtrMap