home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / CLASSINC.PAK / SHDDEL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  1.9 KB  |  87 lines

  1. //----------------------------------------------------------------------------
  2. // Borland Class Library
  3. // Copyright (c) 1991, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   5.7  $
  6. //
  7. //----------------------------------------------------------------------------
  8. #if !defined(CLASSLIB_SHDDEL_H)
  9. #define CLASSLIB_SHDDEL_H
  10.  
  11. #if !defined( CLASSLIB_DEFS_H )
  12. # include <classlib/defs.h>
  13. #endif
  14.  
  15. #pragma option -Vo-
  16. #if defined(BI_CLASSLIB_NO_po)
  17. # pragma option -po-
  18. #endif
  19.  
  20. #if defined(BI_NAMESPACE)
  21. namespace ClassLib {
  22. #endif
  23.  
  24. //
  25. // class TShouldDelete
  26. // ~~~~~ ~~~~~~~~~~~~~
  27. class TShouldDelete
  28. {
  29.   public:
  30.     enum TDelete { NoDelete, DefDelete, Delete };
  31.     typedef TDelete DeleteType;  // For compatibility
  32.  
  33.     TShouldDelete(TDelete dt = Delete);
  34.  
  35.     bool OwnsElements();
  36.     void OwnsElements(bool del);
  37.     bool DelObj(TDelete dt);
  38.  
  39. #if defined(BI_OLDNAMES)
  40.     int ownsElements() { return OwnsElements(); }
  41.     void ownsElements(int del) { OwnsElements(del); }
  42.     int delObj(DeleteType dt) { return DelObj(dt); }
  43. #endif
  44.  
  45.   private:
  46.     TDelete ShouldDelete;  // Is either Delete or NoDelete
  47. };
  48.  
  49. //----------------------------------------------------------------------------
  50. // Inline implementation
  51. //
  52.  
  53. inline TShouldDelete::TShouldDelete(TDelete dt)
  54. {
  55.   OwnsElements(dt != NoDelete);
  56. }
  57.  
  58. inline bool TShouldDelete::OwnsElements()
  59. {
  60.   return ShouldDelete == Delete;
  61. }
  62.  
  63. inline void TShouldDelete::OwnsElements(bool del)
  64. {
  65.   ShouldDelete = del ? Delete : NoDelete;
  66. }
  67.  
  68. inline bool TShouldDelete::DelObj(TDelete dt)
  69. {
  70.   return dt == Delete || (dt==DefDelete && ShouldDelete==Delete);
  71. }
  72.  
  73. #if defined(BI_OLDNAMES)
  74. # define BI_ShouldDelete TShouldDelete
  75. #endif
  76.  
  77. #if defined(BI_NAMESPACE)
  78. }   // namespace ClassLib
  79. #endif
  80.  
  81. #if defined(BI_CLASSLIB_NO_po)
  82. # pragma option -po.
  83. #endif
  84. #pragma option -Vo.
  85.  
  86. #endif  // CLASSLIB_SHDDEL_H
  87.