Source code of Windows XP (NT5)
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.

84 lines
1.9 KiB

  1. // Tree.h: interface for the CTreeNode and CTree classes.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_TREE_H__988BB458_8C93_11D3_BE83_0000F87A3912__INCLUDED_)
  5. #define AFX_TREE_H__988BB458_8C93_11D3_BE83_0000F87A3912__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. //////////////////////////////////////////////////////////////////////
  10. template <class T>
  11. class CTreeNode : public CObject
  12. {
  13. // Construction/Destruction
  14. public:
  15. CTreeNode();
  16. ~CTreeNode();
  17. // Destroy
  18. public:
  19. virtual void Destroy();
  20. // Parent Members
  21. public:
  22. CTreeNode<T>* GetParent() { return m_pParent; }
  23. void SetParent(CTreeNode<T>* pParent) { m_pParent = pParent; }
  24. protected:
  25. CTreeNode<T>* m_pParent;
  26. // Children Members
  27. public:
  28. int GetChildCount();
  29. CTreeNode<T>* GetChild(int iIndex);
  30. int AddChild(CTreeNode<T>* pNode);
  31. void RemoveChild(CTreeNode<T>* pNode);
  32. void RemoveChild(int iIndex);
  33. protected:
  34. CTypedPtrArray<CObArray,CTreeNode<T>*> m_Children;
  35. // Associations
  36. public:
  37. int GetAssocCount();
  38. CTreeNode<T>* GetAssoc(int iIndex);
  39. int AddAssoc(CTreeNode<T>* pNode);
  40. void RemoveAssoc(CTreeNode<T>* pNode);
  41. void RemoveAssoc(int iIndex);
  42. protected:
  43. CTypedPtrArray<CObArray,CTreeNode<T>*> m_Associations;
  44. // Object Members
  45. public:
  46. T GetObject() { return m_Object; }
  47. void SetObject(T Object) { m_Object = Object; }
  48. protected:
  49. T m_Object;
  50. };
  51. //////////////////////////////////////////////////////////////////////
  52. template<class T>
  53. class CTree : public CObject
  54. {
  55. // Construction/Destruction
  56. public:
  57. CTree();
  58. virtual ~CTree();
  59. // Root Node
  60. public:
  61. CTreeNode<T>* GetRootNode() { return m_pRootNode; }
  62. void SetRootNode(CTreeNode<T>* pRootNode) { m_pRootNode = pRootNode; }
  63. protected:
  64. CTreeNode<T>* m_pRootNode;
  65. };
  66. #include "tree.inl"
  67. //////////////////////////////////////////////////////////////////////
  68. #endif // !defined(AFX_TREE_H__988BB458_8C93_11D3_BE83_0000F87A3912__INCLUDED_)