Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.4 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. #ifndef OBJECT_TREE_H
  5. #define OBJECT_TREE_H
  6. class CTreeElement
  7. {
  8. public:
  9. CTreeElement(LPCWSTR lpszHashedName, CRefCountedObject *pObject);
  10. ~CTreeElement();
  11. LPCWSTR GetHashedName() const;
  12. CRefCountedObject *GetObject() const;
  13. CTreeElement *GetLeft() const;
  14. CTreeElement *GetRight() const;
  15. void SetLeft(CTreeElement *pNext);
  16. void SetRight(CTreeElement *pNext);
  17. private:
  18. LPWSTR m_lpszHashedName;
  19. CRefCountedObject *m_pObject;
  20. CTreeElement *m_pLeft;
  21. CTreeElement *m_pRight;
  22. };
  23. class CObjectTree
  24. {
  25. public:
  26. CObjectTree();
  27. ~CObjectTree();
  28. BOOLEAN AddElement(LPCWSTR lpszHashedName, CRefCountedObject *pObject);
  29. BOOLEAN DeleteElement(LPCWSTR lpszHashedName);
  30. BOOLEAN DeleteLeastRecentlyAccessedElement();
  31. CRefCountedObject *GetElement(LPCWSTR lpszHashedName);
  32. void DeleteTree();
  33. DWORD GetNumberOfElements() const
  34. {
  35. return m_dwNumElements;
  36. }
  37. private:
  38. CTreeElement *m_pHead;
  39. // The number of elements in the tree currently
  40. DWORD m_dwNumElements;
  41. // A critical section object for synchronizing modifications
  42. CRITICAL_SECTION m_ModificationSection;
  43. // Private fucntions for recursive calls
  44. void DeleteSubTree(CTreeElement *pRoot);
  45. CRefCountedObject * GetLeastRecentlyAccessedElementRecursive(CTreeElement *pElement);
  46. };
  47. #endif /* OBJECT_TREE_H */