home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 1.ddi / CLASSINC.ZIP / COLLECT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  3.3 KB  |  145 lines

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. // Contents ----------------------------------------------------------------
  4. //
  5. //      Collection
  6. //
  7. // Description
  8. //
  9. //      Defines the abstract class Collection.  Collections group objects
  10. //      together and specify operations.
  11. //
  12. // End ---------------------------------------------------------------------
  13.  
  14. // Interface Dependencies ---------------------------------------------------
  15.  
  16. #ifndef __COLLECT_H
  17. #define __COLLECT_H
  18.  
  19. #ifndef __IOSTREAM_H
  20. #include <iostream.h>
  21. #define __IOSTREAM_H
  22. #endif
  23.  
  24. #ifndef __CLSTYPES_H
  25. #include <clstypes.h>
  26. #endif
  27.  
  28. #ifndef __OBJECT_H
  29. #include <object.h>
  30. #endif
  31.  
  32. #ifndef __CONTAIN_H
  33. #include <contain.h>
  34. #endif
  35.  
  36. // End Interface Dependencies ------------------------------------------------
  37.  
  38. // Class //
  39.  
  40. class Collection:  public Container
  41. {
  42. public:
  43.     virtual ~Collection();
  44.  
  45.     virtual void            add( Object& ) = 0;
  46.     virtual void            detach( const Object&, int = 0 ) = 0;
  47.     virtual int             hasMember( const Object& ) const;
  48.     virtual Object&         findMember( const Object& ) const;
  49.     virtual ContainerIterator& initIterator() const = 0;
  50.  
  51.             void            destroy( const Object& o ) { detach( o, 1 ); }
  52.  
  53.     virtual classType       isA() const = 0;
  54.     virtual char           *nameOf() const = 0;
  55.     virtual hashValueType   hashValue() const = 0;
  56. };
  57.  
  58. // Description -------------------------------------------------------------
  59. //
  60. //         Defines the abstract class Collection.  A Collection is a 
  61. //      grouping of objects on which addition and deletion of objects
  62. //      may occur.  In addition, a Collection supports a membership test.
  63. //      
  64. // Public Members
  65. //
  66. //      add
  67. //
  68. //      Adds an object to the collection.
  69. //
  70. //      destroy
  71. //
  72. //      Removes an object reference from the collection and
  73. //      destroys the object.
  74. //
  75. //         detach
  76. //
  77. //         Removes all references to the object in the collection.
  78. //      Does not delete the object.  Use this function when the collection
  79. //      elements are not owned by the collection.
  80. //
  81. //      hasMember
  82. //
  83. //         Test whether an object is part of the collection.  Returns 1 if
  84. //      the object reference is found in the array.
  85. //
  86. //      findMember
  87. //
  88. //         Test whether an object is part of the collection.  Returns a
  89. //         reference to the object in the collection if the object is found.
  90. //
  91. //         initIterator
  92. //
  93. //         Iterator initializer.  Redeclared as pure virtual.
  94. //
  95. //         isA
  96. //
  97. //         Redeclared as pure virtual.
  98. //
  99. //         nameOf
  100. //
  101. //         Redeclared as pure virtual.
  102. //     
  103. //         hashValue
  104. //
  105. //         Redeclared as pure virtual.
  106. //
  107. //  Inherited Members
  108. //
  109. //         isEmpty
  110. //
  111. //         Inherited from Container.
  112. //
  113. //         forEach
  114. //
  115. //         Inherited from Container.
  116. //
  117. //      firstThat
  118. //
  119. //         Inherited from Container.
  120. //
  121. //      lastThat
  122. //
  123. //         Inherited from Container.
  124. //
  125. //         printOn
  126. //
  127. //         Inherited from Container.
  128. //
  129. //      isEqual
  130. //
  131. //         Inherited from Container.
  132. //
  133. //         isSortable
  134. //
  135. //         Inherited from Object.
  136. //
  137. //         isAssociation
  138. //
  139. //         Inherited from Object.
  140. //
  141. // End ---------------------------------------------------------------------
  142.  
  143.  
  144. #endif // ifndef __COLLECT_H //
  145.