home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tv20cpp.zip / tvision / tvobjs.h < prev    next >
C/C++ Source or Header  |  1998-01-19  |  3KB  |  132 lines

  1. /*
  2.  * tvobjs.h
  3.  *
  4.  * Turbo Vision - Version 2.0
  5.  *
  6.  * Copyright (c) 1994 by Borland International
  7.  * All Rights Reserved.
  8.  *
  9.  * Modified by Sergio Sigala <ssigala@globalnet.it>
  10.  */
  11.  
  12. #if defined( Uses_TObject ) && !defined( __TObject )
  13. #define __TObject
  14.  
  15. #include <stddef.h>
  16.  
  17. class TObject
  18. {
  19.  
  20. public:
  21.  
  22.     virtual ~TObject();
  23.  
  24.     static void destroy( TObject * );
  25.     virtual void shutDown();
  26.  
  27. private:
  28.  
  29. };
  30.  
  31. inline void TObject::destroy( TObject *o )
  32. {
  33.     if( o != 0 )
  34.         o->shutDown();
  35.     delete o;
  36. }
  37.  
  38. #endif  // Uses_TObject
  39.  
  40. #if defined( Uses_TNSCollection ) && !defined( __TNSCollection )
  41. #define __TNSCollection
  42.  
  43. class TNSCollection : public TObject
  44. {
  45.  
  46. public:
  47.  
  48.     TNSCollection( ccIndex aLimit, ccIndex aDelta );
  49.     ~TNSCollection();
  50.  
  51.     virtual void shutDown();
  52.  
  53.     void *at( ccIndex index );
  54.     virtual ccIndex indexOf( void *item );
  55.  
  56.     void atFree( ccIndex index );
  57.     void atRemove( ccIndex index );
  58.     void remove( void *item );
  59.     void removeAll();
  60.     void free( void *item );
  61.     void freeAll();
  62.  
  63.     void atInsert( ccIndex index, void *item );
  64.     void atPut( ccIndex index, void *item );
  65.     virtual ccIndex insert( void *item );
  66.  
  67. #ifndef __UNPATCHED
  68.     virtual void error( ccIndex code, ccIndex info );
  69. #else
  70.     static void error( ccIndex code, ccIndex info );
  71. #endif
  72.  
  73.     void *firstThat( ccTestFunc Test, void *arg );
  74.     void *lastThat( ccTestFunc Test, void *arg );
  75.     void forEach( ccAppFunc action, void *arg );
  76.  
  77.     void pack();
  78.     virtual void setLimit( ccIndex aLimit );
  79.  
  80.     ccIndex getCount()
  81.         { return count; }
  82.  
  83. protected:
  84.  
  85.     TNSCollection();
  86.  
  87.     void **items;
  88.     ccIndex count;
  89.     ccIndex limit;
  90.     ccIndex delta;
  91.     Boolean shouldDelete;
  92.  
  93. private:
  94.  
  95.     virtual void freeItem( void *item );
  96.  
  97. };
  98.  
  99. #endif  // Uses_TNSCollection
  100.  
  101. #if defined( Uses_TNSSortedCollection ) && !defined( __TNSSortedCollection )
  102. #define __TNSSortedCollection
  103.  
  104. class TNSSortedCollection: public virtual TNSCollection
  105. {
  106.  
  107. public:
  108.  
  109.     TNSSortedCollection( ccIndex aLimit, ccIndex aDelta) :
  110.         TNSCollection( aLimit, aDelta ), duplicates(False)
  111.             { delta = aDelta; setLimit( aLimit ); }
  112.  
  113.     virtual Boolean search( void *key, ccIndex& index );
  114.  
  115.     virtual ccIndex indexOf( void *item );
  116.     virtual ccIndex insert( void *item );
  117.  
  118.     Boolean duplicates;
  119.     virtual void *keyOf( void *item );
  120.  
  121. protected:
  122.  
  123.     TNSSortedCollection() : duplicates(False) {}
  124.  
  125. private:
  126.  
  127.     virtual int compare( void *key1, void *key2 ) = 0;
  128.  
  129. };
  130.  
  131. #endif  // Uses_TNSSortedCollection
  132.