home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / iimwt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  5.6 KB  |  162 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. #include <new.h>
  19.  
  20. #pragma info (nocls, nocnd, nocns, nocnv, noext, nognr, novft)
  21. #pragma pack (4)
  22.  
  23. // ----------------
  24. // IMultiwayTreeOps
  25. // ----------------
  26.  
  27. // public members
  28.  
  29. template <INumber numOfChildren, class Element,
  30.           class ElementOps, class Implementation>
  31. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  32. IMultiwayTreeOps ()
  33. : Inherited (__isDTSClass (Element)),
  34.   ivElementOps (),
  35.   ivImpl (*this)
  36. {
  37. }
  38.  
  39. template <INumber numOfChildren, class Element,
  40.           class ElementOps, class Implementation>
  41. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  42. IMultiwayTreeOps (void* opsArg)
  43. : Inherited (__isDTSClass (Element)),
  44.   ivElementOps (opsArg),
  45.   ivImpl (*this)
  46. {
  47. }
  48.  
  49. template <INumber numOfChildren, class Element,
  50.           class ElementOps, class Implementation>
  51. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  52. IMultiwayTreeOps
  53.   (IMultiwayTreeOps
  54.     <numOfChildren, Element, ElementOps, Implementation> const& tree)
  55. : Inherited (__isDTSClass (Element)),
  56.   ivElementOps (tree.ivElementOps),
  57.   ivImpl (*this, tree.ivImpl)
  58. {
  59. }
  60.  
  61. template <INumber numOfChildren, class Element,
  62.           class ElementOps, class Implementation>
  63. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  64. ~IMultiwayTreeOps ()
  65. {
  66. }
  67.  
  68. template <INumber numOfChildren, class Element,
  69.           class ElementOps, class Implementation>
  70. void
  71. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  72. Assign (void* element1, void const* element2) const
  73. { ivElementOps.Assign (*(Element*)element1, *(Element const*)element2);
  74. }
  75.  
  76. template <INumber numOfChildren, class Element,
  77.           class ElementOps, class Implementation>
  78. IATreeImpl*
  79. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  80. Clone () const
  81. { return (Implementation*) *new Self (*this);
  82. }
  83.  
  84. template <INumber numOfChildren, class Element,
  85.           class ElementOps, class Implementation>
  86. void*
  87. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  88. CreateNode (void const* element) const
  89. { void* node = ivElementOps.Allocate (sizeof (Node)
  90. #if defined (__DEBUG_ALLOC__)
  91.                                       , __FILE__, __LINE__
  92. #endif
  93.                                      );
  94.   return new (ivImpl.CheckPointer (node))
  95.     Node (*(Element const*)element);
  96. }
  97.  
  98. template <INumber numOfChildren, class Element,
  99.           class ElementOps, class Implementation>
  100. void
  101. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  102. DeleteNode (void* node) const
  103. { ((Node*)node)->~Node ();
  104.   ivElementOps.Deallocate (node
  105. #if defined (__DEBUG_ALLOC__)
  106.                            , __FILE__, __LINE__
  107. #endif
  108.                           );
  109. }
  110.  
  111. template <INumber numOfChildren, class Element,
  112.           class ElementOps, class Implementation>
  113. void*
  114. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  115. StreamIn (TStream& fromWhere) const
  116. { Element* element = ivElementOps.GetStreamable ();
  117.   ivElementOps.StreamIn (*element, fromWhere);
  118.   return (void*) element;
  119. }
  120.  
  121. template <INumber numOfChildren, class Element,
  122.           class ElementOps, class Implementation>
  123. void
  124. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  125. StreamOut (void const* element, TStream& toWhere) const
  126. { ivElementOps.StreamOut (*(Element const*)element, toWhere);
  127. }
  128.  
  129. template <INumber numOfChildren, class Element,
  130.           class ElementOps, class Implementation>
  131. TStream&
  132. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  133. operator<<= (TStream& fromWhere)
  134. { return (ivElementOps <<= fromWhere);
  135. }
  136.  
  137. template <INumber numOfChildren, class Element,
  138.           class ElementOps, class Implementation>
  139. TStream&
  140. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  141. operator>>= (TStream& toWhere) const
  142. { return (ivElementOps >>= toWhere);
  143. }
  144.  
  145. template <INumber numOfChildren, class Element,
  146.           class ElementOps, class Implementation>
  147. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  148. operator INumber () const
  149. { return numOfChildren;
  150. }
  151.  
  152. template <INumber numOfChildren, class Element,
  153.           class ElementOps, class Implementation>
  154. IMultiwayTreeOps <numOfChildren, Element, ElementOps, Implementation>::
  155. operator Implementation* ()
  156. { ivImpl.CheckPointer (this);
  157.   return &ivImpl;
  158. }
  159.  
  160. #pragma info (restore)
  161. #pragma pack ()
  162.