home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CLASS.ZIP / TREE.CC < prev    next >
Text File  |  1993-02-16  |  2KB  |  86 lines

  1. #include "tree.h"
  2. #ifdef INCLUDESOURCE
  3. #include "chain.cc"
  4. #endif
  5.  
  6.  
  7. int tree::toBeCalledForeachElement(unsigned int iMsg, void *pDummy)
  8. {    int ret;
  9. #ifdef SHOWCALLS
  10.         fprintf(stderr, "Calling tree::toBeCalledForeachElement(%x)!\n", this);
  11. #endif
  12.     switch (ret = toBeCalledPre(iMsg, pDummy))
  13.     {    case 0:
  14.             break;
  15.         case -1:
  16.             return 0;
  17.         default:
  18.             return ret;
  19.     }
  20.     if (ret = foreach(iMsg, pDummy))
  21.         return ret;
  22.     return toBeCalledPost(iMsg, pDummy);    
  23. }
  24.  
  25.  
  26. int tree::toBeCalledPre(unsigned int iMsg, void *pDummy)
  27. {
  28. #ifdef SHOWCALLS
  29.         fprintf(stderr, "Calling tree::toBeCalledPre(%x)!\n", this);
  30. #endif
  31.       switch (iMsg)
  32.        {       case idForeachTreeDeletePreChilds:
  33.                        delete this;
  34.                        return -1;
  35.                case idForeachTreeDeletePostChilds:
  36.                        return 0;
  37.                default:
  38.                        return 0;
  39.                case idForeachTreeSearchPreChilds:
  40.                        return chainElement::toBeCalledForeachElement(
  41.                            idForeachChainElementSearch, pDummy);
  42.                case idForeachTreeSearchPostChilds:
  43.                        return 0;
  44.        }
  45.     return 0;
  46. }
  47.  
  48.  
  49. int tree::toBeCalledPost(unsigned int iMsg, void *pDummy)
  50. {
  51. #ifdef SHOWCALLS
  52.         fprintf(stderr, "Calling tree::toBeCalledPost(%x)!\n", this);
  53. #endif
  54.       switch (iMsg)
  55.        {       case idForeachTreeDeletePreChilds:
  56.                        abort();
  57.                        return -1;
  58.                case idForeachTreeDeletePostChilds:
  59.                        delete this;
  60.                        return 0;
  61.                case idForeachTreeSearchPostChilds:
  62.                        return chainElement::toBeCalledForeachElement(
  63.                            idForeachChainElementSearch, pDummy);
  64.                case idForeachTreeSearchPreChilds:
  65.                        return 0;
  66.                default:
  67.                        return chainElement::toBeCalledForeachElement(iMsg, pDummy);
  68.        }
  69. }
  70.  
  71.  
  72. tree::~tree(void)
  73. {
  74. #ifdef SHOWCALLS
  75.        fprintf(stderr, "Calling ~tree(%x)!\n", this);
  76. #endif
  77. }
  78.  
  79.  
  80. tree::tree(chain *pParent):chainElement(pParent), chain()
  81. {
  82. #ifdef SHOWCALLS
  83.        fprintf(stderr, "Calling tree(%x)!\n", this);
  84. #endif
  85. }
  86.