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.

213 lines
3.6 KiB

  1. /*++
  2. Microsoft Windows NT RPC Name Service
  3. Copyright (C) Microsoft Corporation, 1995 - 1999
  4. Module Name:
  5. abstract.hxx
  6. Abstract:
  7. This module contains a definition of abstract classes used as the basis of
  8. data items in several linked data structures and iterators over them.
  9. Author:
  10. Satish Thatte (SatishT) 08/16/95 Created all the code below except where
  11. otherwise indicated.
  12. --*/
  13. #ifndef _ABSTRACT_HXX_
  14. #define _ABSTRACT_HXX_
  15. enum SkipStatus;
  16. /*++
  17. Interface Definition:
  18. IDataItem
  19. Abstract:
  20. This is the class used as the base class for data items
  21. stored in data structures. Its main purpose is to declare
  22. a virtual destructor.
  23. --*/
  24. class IDataItem {
  25. public:
  26. inline
  27. virtual ~IDataItem() {}
  28. };
  29. /*++
  30. Interface Definition:
  31. IOrderedItem
  32. Abstract:
  33. This is the abstract class used as the base class for data items
  34. stored in ordered data structures. It defines a comparison operator
  35. and derives other relational operators from it.
  36. Note that compare is pure virtual and is required to behave similar
  37. to strcmp: -1 for "less", 0 for "equal", and +1 for "greater"
  38. --*/
  39. class IOrderedItem : public IDataItem {
  40. public:
  41. virtual int compare(const IOrderedItem&) = 0; // pure virtual function
  42. // The following relational operators offer better syntax at no runtime cost
  43. // due to inline specification.
  44. inline
  45. int operator== (const IOrderedItem& k)
  46. { return compare(k) == 0; }
  47. inline
  48. int operator!= (const IOrderedItem& k)
  49. { return compare(k) != 0; }
  50. inline
  51. int operator< (const IOrderedItem& k)
  52. { return compare(k) < 0; }
  53. inline
  54. int operator> (const IOrderedItem& k)
  55. { return compare(k) > 0; }
  56. inline
  57. int operator>= (const IOrderedItem& k)
  58. { return compare(k) >= 0; }
  59. inline
  60. int operator<= (const IOrderedItem& k)
  61. { return compare(k) <= 0; }
  62. inline
  63. virtual ~IOrderedItem() {}
  64. };
  65. /*++
  66. Interface Definition:
  67. TIIterator
  68. Abstract:
  69. This is the abstract interface for iterators in general.
  70. A very minimal interface indeed.
  71. --*/
  72. template <class Data>
  73. class TIIterator {
  74. public:
  75. virtual Data * next() = 0; // primary iterative operation
  76. virtual int finished() = 0; // test for end of iterator
  77. inline virtual ~TIIterator() {}
  78. };
  79. /*++
  80. Interface Definition:
  81. TILinkList
  82. Abstract:
  83. This is the abstract interface for safe linked lists.
  84. --*/
  85. template <class Data>
  86. class TILinkList {
  87. public:
  88. virtual void enque(Data*) = 0;
  89. virtual void push(Data*) = 0;
  90. virtual void insert(Data*) = 0;
  91. virtual void wipeOut() = 0;
  92. virtual void rotate(long lDegree) = 0;
  93. // The method below is somewhat problematic, being binary.
  94. // Including this here will require nontrivial modifications
  95. // virtual void catenate(TILinkList<Data>&) = 0;
  96. virtual Data* pop() = 0;
  97. virtual int remove(Data*) = 0;
  98. virtual Data* find(Data*, int comp(Data*,Data*)) = 0;
  99. virtual Data* nth(long lOrdinal) = 0;
  100. virtual ULONG size() = 0;
  101. inline virtual ~TILinkList() {}
  102. };
  103. /*++
  104. Interface Definition:
  105. TISkipList
  106. Abstract:
  107. This is the abstract interface for safe linked lists.
  108. --*/
  109. template <class Data>
  110. class TISkipList {
  111. public:
  112. virtual ULONG size() = 0;
  113. virtual SkipStatus insert(Data *) = 0;
  114. virtual Data * pop() = 0;
  115. virtual Data * remove(IOrderedItem *) = 0;
  116. virtual Data * find(IOrderedItem *) = 0;
  117. virtual void wipeOut() = 0;
  118. inline virtual ~TISkipList() {}
  119. };
  120. #endif // _ABSTRACT_HXX_