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