home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / iptr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  4.4 KB  |  213 lines

  1. /**********************************************************************
  2. *                                                                     *
  3. *  IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3.5           *
  4. *                                                                     *
  5. *  PID: 5622-880                                                      *
  6. *  - Licensed Material - Program-Property of IBM                      *
  7. *  (C) Copyright IBM Corp. 1991, 1995 - All Right Reserved.           *
  8. *                                                                     *
  9. *  US Government Users Restricted Rights - Use, duplication or        *
  10. *  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.  *
  11. *                                                                     *
  12. *  VisualAge, and IBM are trademarks or registered trademarks of      *
  13. *  International Business Machines Corporation.                       *
  14. *  Windows is a registered trademark of Microsoft Corporation.        *
  15. *                                                                     *
  16. **********************************************************************/
  17.  
  18. #ifndef _IPTR_H
  19. #define _IPTR_H
  20.  
  21. #include <iglobals.h>
  22.  
  23.  
  24. #pragma info (nocls, nocnd, nocns, nocnv, noext, nognr, novft)
  25. #pragma pack (4)
  26.  
  27. #pragma SOMAsDefault (off)
  28.  
  29. enum IExplicitInit { IINIT };
  30.  
  31. template <class Element>
  32. class IElemPointer {
  33. public:
  34.  
  35.            IElemPointer     ();
  36.  
  37.            IElemPointer     (Element*, IExplicitInit = IINIT);
  38.  
  39.   Element& operator*        () const;
  40.  
  41.   Element* operator->       () const;
  42.  
  43.            operator Element*
  44.                             () const;
  45.  
  46.   friend 
  47.   Element& elementForOps    (IElemPointer <Element>&);
  48.  
  49.   friend
  50.   Element const&
  51.            elementForOps    (IElemPointer <Element> const&) ;
  52.  
  53. protected:
  54.  
  55. private:
  56.  
  57.   Element* ivPtr;
  58.  
  59.  
  60. };
  61.  
  62.  
  63. template <class Element>
  64. class IMngPointer {
  65. public:
  66.  
  67.            IMngPointer      ();
  68.  
  69.            IMngPointer      (Element*, IExplicitInit);
  70.  
  71.            IMngPointer      (IMngPointer <Element> const&);
  72.  
  73.           ~IMngPointer      ();
  74.  
  75.   IMngPointer <Element>&
  76.            operator=        (IMngPointer <Element> const&);
  77.  
  78.   Element& operator*        () const;
  79.  
  80.   Element* operator->       () const;
  81.  
  82.            operator Element* () const;
  83.  
  84.  
  85. private:
  86.  
  87.   struct PtrRc
  88.   { Element *ivPtr;
  89.  
  90.     unsigned int ivRc;
  91.  
  92.              PtrRc (Element *ptr)
  93.              : ivPtr (ptr), ivRc (1)
  94.              {
  95.              }
  96.  
  97.             ~PtrRc ()
  98.              { delete ivPtr; }
  99.  
  100.   } *ivPtrRc;
  101.  
  102.  
  103. };
  104.  
  105.  
  106. template <class Element>
  107. class IMngElemPointer : protected IMngPointer <Element> {
  108. public:
  109.  
  110.            IMngElemPointer  () ;
  111.  
  112.            IMngElemPointer  (Element*, IExplicitInit);
  113.  
  114. #if defined (ICLCC_COMPAT_PTR)
  115.            IMngElemPointer  (Element const&);
  116.  
  117.            IMngElemPointer  (Element*);
  118. #endif
  119.  
  120.   Element& operator*        () const;
  121.  
  122.   Element* operator->       () const;
  123.  
  124.            operator Element*
  125.                             () const;
  126.  
  127.   friend
  128.   Element& elementForOps    (IMngElemPointer <Element>&);
  129.  
  130.   friend
  131.   Element const&
  132.            elementForOps    (IMngElemPointer <Element> const&);
  133.  
  134.  
  135. protected:
  136.  
  137. private:
  138.  
  139.  
  140. };
  141.  
  142.  
  143.  
  144. template <class Element>
  145. class IAutoPointer {
  146. public:
  147.  
  148.            IAutoPointer     ();
  149.  
  150.            IAutoPointer     (Element*, IExplicitInit);
  151.  
  152.            IAutoPointer     (IAutoPointer <Element> const&);
  153.  
  154.           ~IAutoPointer     ();
  155.  
  156.   void     operator=        (IAutoPointer <Element> const&);
  157.  
  158.            operator Element*
  159.                             () const;
  160.  
  161.   Element& operator*        () const;
  162.  
  163.   Element* operator->       () const;
  164.  
  165. protected:
  166.  
  167. private:
  168.  
  169.   Element* ivPtr;
  170.  
  171.  
  172. };
  173.  
  174.  
  175. template <class Element>
  176. class IAutoElemPointer : protected IAutoPointer <Element> {
  177. public:
  178.  
  179.            IAutoElemPointer ();
  180.  
  181.            IAutoElemPointer (Element*, IExplicitInit);
  182.  
  183.   Element& operator*        () const;
  184.  
  185.   Element* operator->       () const;
  186.  
  187.            operator Element*
  188.                             () const;
  189.  
  190.   friend
  191.   Element& elementForOps    (IAutoElemPointer <Element>&);
  192.  
  193.   friend
  194.   Element const&
  195.            elementForOps    (IAutoElemPointer <Element> const&);
  196.  
  197. protected:
  198.  
  199. private:
  200.  
  201.  
  202. };
  203.  
  204.  
  205.  
  206. #include <iptr.inl>
  207.  
  208.  
  209. #pragma info (restore)
  210. #pragma pack ()
  211.  
  212. #endif
  213.