home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / iimwt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  10.5 KB  |  430 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 _IITREE_H
  19. #define _IITREE_H
  20.  
  21. #include <iiatree.h>
  22.  
  23.  
  24. #pragma info (nocls, nocnd, nocns, nocnv, noext, nognr, novft)
  25. #pragma pack (4)
  26.  
  27. #pragma SOMAsDefault (off)
  28.  
  29. struct IAMultiwayTreeNodeImpl {
  30.  
  31.   IAMultiwayTreeNodeImpl*
  32.             ivParent;
  33.  
  34.   IAMultiwayTreeNodeImpl**
  35.             ivChildren;
  36.  
  37. };
  38.  
  39. template <INumber numOfChildren, class Element>
  40. struct IMultiwayTreeNodeImpl : public IAMultiwayTreeNodeImpl {
  41.  
  42.   typedef   IAMultiwayTreeNodeImpl Inherited;
  43.  
  44.   Element   ivElement;
  45.  
  46.   IAMultiwayTreeNodeImpl*
  47.             ivChildren [numOfChildren];
  48.  
  49.             IMultiwayTreeNodeImpl
  50.                              (Element const&);
  51.  
  52.            ~IMultiwayTreeNodeImpl
  53.                              ();
  54.  
  55. };
  56.  
  57. #pragma SOMAsDefault (pop)
  58.  
  59. #pragma SOMAsDefault (off)
  60.  
  61. class IMultiwayTreeCursorImpl : public ITreeCursorImpl {
  62.  
  63.   typedef  ITreeCursorImpl Inherited;
  64.  
  65.   typedef  IMultiwayTreeCursorImpl Self;
  66.  
  67. public:
  68.  
  69.            IMultiwayTreeCursorImpl
  70.                             (IATreeImpl const&);
  71.  
  72.            IMultiwayTreeCursorImpl
  73.                             (IMultiwayTreeCursorImpl const&);
  74.  
  75.           ~IMultiwayTreeCursorImpl
  76.                             ();
  77.  
  78.   ITreeCursorImpl*
  79.            Clone            () const;
  80.  
  81.   void     Copy             (ITreeCursorImpl const&);
  82.  
  83.   IBoolean IsValid          () const;
  84.  
  85.   void     Invalidate       ();
  86.  
  87.   void     operator=        (IMultiwayTreeCursorImpl const&);
  88.  
  89.   IBoolean operator==       (ITreeCursorImpl const&) const;
  90.  
  91. protected:
  92.  
  93. private:
  94.  
  95.   IAMultiwayTreeNodeImpl*
  96.            ivNode;
  97.  
  98.   friend
  99.   class    IMultiwayTreeImpl;
  100.  
  101.  
  102. };
  103.  
  104. class IAMultiwayTreeOps;
  105.  
  106. class IMultiwayTreeImpl : public IATreeImpl {
  107.  
  108.   typedef  IATreeImpl Inherited;
  109.  
  110.   typedef  IMultiwayTreeImpl Self;
  111.  
  112.   typedef  IAMultiwayTreeNodeImpl Node;
  113.  
  114. public :
  115.  
  116.   typedef  IAMultiwayTreeOps Ops;
  117.  
  118.   typedef  IMultiwayTreeCursorImpl Cursor;
  119.  
  120.   typedef  IMultiwayTreeCursorImpl MngCursor;
  121.  
  122.            IMultiwayTreeImpl
  123.                             (Ops&);
  124.  
  125.            IMultiwayTreeImpl
  126.                             (Ops&, IMultiwayTreeImpl const&);
  127.  
  128.           ~IMultiwayTreeImpl
  129.                             ();
  130.  
  131.   void     AddAsChild       (ITreeCursorImpl const&,
  132.                              IPosition, void const*);
  133.  
  134.   void     AddAsRoot        (void const*);
  135.  
  136.   IBoolean AllElementsDo    (IApplFunc, ITreeIterationOrder, void*);
  137.  
  138.   IBoolean AllSubtreeElementsDo
  139.                             (ITreeCursorImpl const&,
  140.                              IApplFunc, ITreeIterationOrder, void*);
  141.  
  142.   virtual
  143.   void     AttachAsChild    (ITreeCursorImpl const&,
  144.                              IPosition, IMultiwayTreeImpl&);
  145.  
  146.   virtual
  147.   void     AttachAsRoot     (IMultiwayTreeImpl&);
  148.  
  149.   virtual
  150.   void     AttachSubtreeAsChild
  151.                             (ITreeCursorImpl const&, IPosition,
  152.                              IMultiwayTreeImpl&,
  153.                              ITreeCursorImpl const&);
  154.  
  155.   virtual
  156.   void     AttachSubtreeAsRoot
  157.                             (IMultiwayTreeImpl&,
  158.                              ITreeCursorImpl const&);
  159.  
  160.   IBoolean CheckChild       (ITreeCursorImpl const&, IPosition) const;
  161.  
  162.   IBoolean CheckCursor      (ITreeCursorImpl const&) const;
  163.  
  164.   IBoolean CheckCursor      (ITreeCursorImpl const&,
  165.                              ITreeCursorImpl const&) const;
  166.  
  167.   INumber  ChildPositionAt  (ITreeCursorImpl const&) const;
  168.  
  169.   char const*
  170.            ClassName        () const;
  171.  
  172.   IATreeImpl*
  173.            Clone            () const;
  174.  
  175.   void     Copy             (IMultiwayTreeImpl const&);
  176.  
  177.   virtual
  178.   void     CopySubtree      (IMultiwayTreeImpl const&,
  179.                              ITreeCursorImpl const&);
  180.  
  181.   Cursor*  CreateCursor     () const;
  182.  
  183.   void*    ElementAt        (ITreeCursorImpl const&) const;
  184.  
  185.   virtual
  186.   IBoolean HasChild         (IPosition, ITreeCursorImpl const&) const;
  187.  
  188.   IBoolean IsConsistent     () const;
  189.  
  190.   IBoolean IsEmpty          () const;
  191.  
  192.   IBoolean IsLeaf           (ITreeCursorImpl const&) const;
  193.  
  194.   IBoolean IsRoot           (ITreeCursorImpl const&) const;
  195.  
  196.   INumber  NumberOfChildren () const;
  197.  
  198.   INumber  NumberOfElements () const;
  199.  
  200.   INumber  NumberOfLeaves   () const;
  201.  
  202.   INumber  NumberOfSubtreeElements
  203.                             (ITreeCursorImpl const&) const;
  204.  
  205.   INumber  NumberOfSubtreeLeaves
  206.                             (ITreeCursorImpl const&) const;
  207.  
  208.   INumber  RemoveAll        ();
  209.  
  210.   INumber  RemoveSubtree    (ITreeCursorImpl&);
  211.  
  212.   void     ReplaceAt        (ITreeCursorImpl const&, void const*);
  213.  
  214.   IBoolean SetToChild       (IPosition, ITreeCursorImpl&) const;
  215.  
  216.   IBoolean SetToFirst       (ITreeCursorImpl&,
  217.                              ITreeIterationOrder) const;
  218.  
  219.   IBoolean SetToFirstExistingChild
  220.                             (ITreeCursorImpl&) const;
  221.  
  222.   IBoolean SetToLast        (ITreeCursorImpl&,
  223.                              ITreeIterationOrder) const;
  224.  
  225.   IBoolean SetToLastExistingChild
  226.                             (ITreeCursorImpl&) const;
  227.  
  228.   IBoolean SetToNext        (ITreeCursorImpl&,
  229.                              ITreeIterationOrder) const;
  230.  
  231.   IBoolean SetToNextExistingChild
  232.                             (ITreeCursorImpl&) const;
  233.  
  234.   IBoolean SetToParent      (ITreeCursorImpl&) const;
  235.  
  236.   IBoolean SetToPrevious    (ITreeCursorImpl&,
  237.                              ITreeIterationOrder) const;
  238.  
  239.   IBoolean SetToPreviousExistingChild
  240.                             (ITreeCursorImpl&) const;
  241.  
  242.   IBoolean SetToRoot        (ITreeCursorImpl&) const;
  243.  
  244.   void     operator=        (IMultiwayTreeImpl const&);
  245.  
  246.   TStream& operator<<=      (TStream&);
  247.  
  248.   TStream& operator>>=      (TStream&) const;
  249.  
  250. protected:
  251.  
  252.   void     Assign           (void*, void const*) const;
  253.  
  254.   void*    CreateNode       (void const*) const;
  255.  
  256.   void     DeleteNode       (void*) const;
  257.  
  258.   void*    StreamIn         (TStream&) const;
  259.  
  260.   void     StreamOut        (void const*, TStream&) const;
  261.  
  262. private:
  263.  
  264.   enum { kOriginalVersion };
  265.  
  266.   static
  267.   char const*
  268.            cvClassName;
  269.  
  270.   Node*    ivRoot;
  271.  
  272.   INumber  ivNumberOfChildren;
  273.  
  274.   IBoolean AllElementsDoSubtree
  275.                             (IApplFunc,
  276.                              ITreeIterationOrder, void*, Node*);
  277.  
  278.   IBoolean CheckCursorSubtree
  279.                             (ITreeCursorImpl const&, Node*) const;
  280.  
  281.   Node*    CopySubtree      (Node const*) const;
  282.  
  283.   INumber  DeleteSubtree    (Node*) const;
  284.  
  285.   void*    ElementOf        (Node const*) const;
  286.  
  287.   void     InitNode         (Node*, Node*) const;
  288.  
  289.   IBoolean IsConsistentSubtree
  290.                             (Node*) const;
  291.  
  292.   static
  293.   Node*&   NodeOf           (ITreeCursorImpl const&);
  294.  
  295.   INumber  NumberOfSubtreeElements
  296.                             (Node const*) const;
  297.  
  298.   INumber  NumberOfSubtreeLeaves
  299.                             (Node const*) const;
  300.  
  301.   static
  302.   Ops&     OpsOf            (IMultiwayTreeImpl const&);
  303.  
  304.   Node*    StreamInSubtree  (TStream&) const;
  305.  
  306.   void     StreamOutSubtree (Node const*, TStream&) const;
  307.  
  308.  
  309. };
  310.  
  311. class IAMultiwayTreeOps {
  312. public:
  313.  
  314.   virtual ~IAMultiwayTreeOps
  315.                             ();
  316.  
  317.   virtual
  318.   void     Assign           (void*, void const*) const = 0;
  319.  
  320.   virtual
  321.   IATreeImpl*
  322.            Clone            () const = 0;
  323.  
  324.   virtual
  325.   void*    CreateNode       (void const*) const = 0;
  326.  
  327.   virtual
  328.   void     DeleteNode       (void*) const = 0;
  329.  
  330.   virtual
  331.   void*    StreamIn         (TStream&) const = 0;
  332.  
  333.   virtual
  334.   void     StreamOut        (void const*, TStream&) const = 0;
  335.  
  336.   virtual
  337.   TStream& operator<<=      (TStream&) = 0;
  338.  
  339.   virtual
  340.   TStream& operator>>=      (TStream&) const = 0;
  341.  
  342.   virtual  operator INumber () const = 0;
  343.  
  344. protected:
  345.  
  346.            IAMultiwayTreeOps
  347.                             (IBoolean);
  348.  
  349. private:
  350.  
  351.   IBoolean ivContainsDTSObjects;
  352.  
  353.   friend
  354.   class    IMultiwayTreeImpl;
  355.  
  356.  
  357. };
  358.  
  359. template <INumber numOfChildren, class Element,
  360.           class ElementOps, class Implementation>
  361. class IMultiwayTreeOps : public IAMultiwayTreeOps {
  362.  
  363.   typedef  IAMultiwayTreeOps Inherited;
  364.  
  365.   typedef  IMultiwayTreeOps <numOfChildren, Element,
  366.                              ElementOps, Implementation> Self;
  367.  
  368.   typedef  IMultiwayTreeNodeImpl <numOfChildren, Element> Node;
  369.  
  370. public:
  371.  
  372.            IMultiwayTreeOps ();
  373.  
  374.            IMultiwayTreeOps (void*);
  375.  
  376.            IMultiwayTreeOps (IMultiwayTreeOps
  377.                               <numOfChildren, Element,
  378.                                ElementOps, Implementation> const&);
  379.  
  380.           ~IMultiwayTreeOps ();
  381.  
  382.   void     Assign           (void*, void const*) const;
  383.  
  384.   IATreeImpl*
  385.            Clone            () const;
  386.  
  387.   void*    CreateNode       (void const*) const;
  388.  
  389.   void     DeleteNode       (void*) const;
  390.  
  391.   void*    StreamIn         (TStream&) const;
  392.  
  393.   void     StreamOut        (void const*, TStream&) const;
  394.  
  395.   TStream& operator<<=      (TStream&);
  396.  
  397.   TStream& operator>>=      (TStream&) const;
  398.  
  399.            operator INumber () const;
  400.  
  401.            operator Implementation*
  402.                             ();
  403.  
  404.  
  405. protected:
  406.  
  407. private:
  408.  
  409.   ElementOps
  410.            ivElementOps;
  411.  
  412.   Implementation
  413.            ivImpl;
  414.  
  415.  
  416. };
  417.  
  418. #pragma SOMAsDefault (pop)
  419.  
  420. #include <iimwt.inl>
  421.  
  422. #if ! defined (__TEMPINC__)
  423. #include <iimwt.c>
  424. #endif
  425.  
  426. #pragma info (restore)
  427. #pragma pack ()
  428.  
  429. #endif
  430.