home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 2.ddi / CLASSINC.ZIP / CONTAIN.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.6 KB  |  100 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  CONTAIN.H                                                             */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991, 1992                            */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( __CONTAIN_H )
  11. #define __CONTAIN_H
  12.  
  13. #if !defined( __CLSTYPES_H )
  14. #include <ClsTypes.h>
  15. #endif  // __CLSTYPES_H
  16.  
  17. #if !defined( __OBJECT_H )
  18. #include <Object.h>
  19. #endif  // __OBJECT_H
  20.  
  21. #if !defined( __SHDDEL_H )
  22. #include <ShdDel.h>
  23. #endif  // __SHDDEL_H
  24.  
  25. #pragma option -Vo-
  26. #if defined( __BCOPT__ ) && !defined( _ALLOW_po )
  27. #pragma option -po-
  28. #endif
  29.  
  30. _CLASSDEF(ostream)
  31. _CLASSDEF(ContainerIterator)
  32. _CLASSDEF(Container)
  33.  
  34. class _CLASSTYPE Container : public Object, public virtual TShouldDelete
  35. {
  36.  
  37. public:
  38.  
  39.     Container() : itemsInContainer(0) {}
  40.  
  41.     virtual void flush( DeleteType = DefDelete ) = 0;
  42.  
  43.     virtual int isEmpty() const
  44.         {
  45.         return itemsInContainer == 0;
  46.         }
  47.  
  48.     virtual countType getItemsInContainer() const
  49.         {
  50.         return itemsInContainer;
  51.         }
  52.  
  53.     virtual void forEach( iterFuncType, void _FAR * );
  54.     virtual Object _FAR & firstThat( condFuncType, void _FAR * ) const;
  55.     virtual Object _FAR & lastThat( condFuncType, void _FAR * ) const;
  56.  
  57.     virtual classType isA() const = 0;
  58.     virtual char _FAR *nameOf() const = 0;
  59.     virtual hashValueType hashValue() const;
  60.     virtual int isEqual( const Object& ) const;
  61.  
  62.     virtual void printOn( ostream& ) const;
  63.     virtual void printHeader( ostream& ) const;
  64.     virtual void printSeparator( ostream& ) const;
  65.     virtual void printTrailer( ostream& ) const;
  66.  
  67.     virtual ContainerIterator _FAR & initIterator() const = 0;
  68.  
  69.     friend class ContainerIterator;
  70.  
  71. protected:
  72.  
  73.     unsigned itemsInContainer;
  74.  
  75. };
  76.  
  77. class _CLASSTYPE ContainerIterator
  78. {
  79.  
  80. public:
  81.  
  82.     virtual ~ContainerIterator()
  83.     {
  84.     }
  85.  
  86.     virtual operator int() = 0;
  87.     virtual Object _FAR & current() = 0;
  88.     virtual Object _FAR & operator ++ ( int ) = 0;
  89.     virtual Object _FAR & operator ++ () = 0;
  90.     virtual void restart() = 0;
  91.  
  92. };
  93.  
  94. #if defined( __BCOPT__ ) && !defined( _ALLOW_po )
  95. #pragma option -po.
  96. #endif
  97. #pragma option -Vo.
  98.  
  99. #endif
  100.