home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sompar.zip / SOM / PART.C < prev    next >
C/C++ Source or Header  |  1994-01-10  |  7KB  |  228 lines

  1.  
  2. /*
  3.  *  This file was generated by the SOM Compiler.
  4.  *  Generated using:
  5.  *     SOM incremental update: somc/smmain.c
  6.  */
  7.  
  8. /*
  9.  *  This file was generated by the SOM Compiler and Emitter Framework.
  10.  *  Generated using: 
  11.  *      SOM Emitter emitctm: somc/smmain.c
  12.  */
  13.  
  14. #define Part_Class_Source
  15. #include <stdio.h>
  16. #include <part.ih>
  17.  
  18. static boolean SearchParts(PartData *pData, long lSet,
  19.                                    long lAction, long* ID, long* Count)
  20. {
  21.     long nIndex, nCount;
  22.  
  23.     // --------------------------------------------------------------------
  24.     //  Search through the internal data structures for same item
  25.     // --------------------------------------------------------------------
  26.  
  27.     nCount = pData->stackCount;
  28.     for (nIndex=0;nIndex<nCount;nIndex++)
  29.     {
  30.         if ((pData->stackSet[nIndex] == lSet) && (pData->stackAction[nIndex] == lAction)) 
  31.         {
  32.             (*ID) = nIndex;    
  33.             (*Count) = pData->stackActionCount[nIndex];
  34.             return (TRUE);
  35.         }
  36.     }
  37.  
  38.     // --------------------------------------------------------------------
  39.     //  item is not found so return back FALSE;
  40.     // --------------------------------------------------------------------
  41.  
  42.     (*ID) = 0l;
  43.     (*Count) = 0l;
  44.     return (FALSE);    
  45. }
  46.  
  47.  
  48. /*
  49.  * SOM_Scope boolean  SOMLINK Search(Part somSelf,  Environment *ev, 
  50.  *                                   long lSet, long lAction, long* ID, 
  51.  *                                   long* Count)
  52.  */
  53.  
  54. /*
  55.  * The prototype for Search was replaced by the following prototype:
  56.  */
  57. SOM_Scope boolean  SOMLINK Search(Part somSelf,  Environment *ev, 
  58.                                   long lSet, long lAction, long* ID, 
  59.                                   long* Count)
  60. {
  61.     PartData *somThis = PartGetData(somSelf);
  62.     PartMethodDebug("Part","Search");
  63.  
  64.  
  65.     // ----------------------------------------------------------------------
  66.     // Call internal function to search for ID and return result
  67.     // ----------------------------------------------------------------------
  68.  
  69.     return(SearchParts(somThis,lSet,lAction,ID,Count));
  70. }
  71.  
  72.  
  73. /*
  74.  * SOM_Scope boolean  SOMLINK Add(Part somSelf,  Environment *ev, 
  75.  *                                long lSet, long LAction, long* ID, 
  76.  *                                long* Count)
  77.  */
  78.  
  79. /*
  80.  * The prototype for Add was replaced by the following prototype:
  81.  */
  82. SOM_Scope boolean  SOMLINK Add(Part somSelf,  Environment *ev, 
  83.                                long lSet, long LAction, long* ID, 
  84.                                long* Count)
  85. {
  86.     long nIndex;
  87.    PartData *somThis = PartGetData(somSelf);
  88.    PartMethodDebug("Part","Add");
  89.  
  90.     // ----------------------------------------------------------------------
  91.     // if stack count is equal to or great than max return FALSE
  92.     // ----------------------------------------------------------------------
  93.  
  94.     if (somThis->stackCount >= Part_stackSize)
  95.         return (FALSE); 
  96.      
  97.     // ----------------------------------------------------------------------
  98.     // Call lowlevel search if found, then return FALSE
  99.     // ----------------------------------------------------------------------
  100.  
  101.     if (SearchParts(somThis,lSet,LAction,ID,Count))
  102.             return (FALSE);
  103.  
  104.     // ----------------------------------------------------------------------
  105.     // create a new item
  106.     // ----------------------------------------------------------------------
  107.  
  108.     nIndex = somThis->stackCount++;
  109.     somThis->stackSet[nIndex] = lSet;
  110.     somThis->stackAction[nIndex] = LAction;
  111.     somThis->stackActionCount[nIndex] = 1;
  112.  
  113.     // ----------------------------------------------------------------------
  114.     // if Debugging then dump out some information to the DSOM server window
  115.     // ----------------------------------------------------------------------
  116.  
  117.     if (somThis->DebugState)
  118.         printf("Adding Set = %d, Function = %d, Index = %d\n", lSet, LAction, nIndex);
  119.  
  120.     // ----------------------------------------------------------------------
  121.     // return the newly created index, count of 1 and TRUE
  122.     // ----------------------------------------------------------------------
  123.  
  124.     (*ID) = nIndex;
  125.     (*Count) = 1l;
  126.  
  127.     return (TRUE);
  128. }
  129.  
  130.  
  131. /*
  132.  * SOM_Scope boolean  SOMLINK Update(Part somSelf,  Environment *ev, 
  133.  *                                   long lSet, long LAction, long* ID, 
  134.  *                                   long* Count)
  135.  */
  136.  
  137. /*
  138.  * The prototype for Update was replaced by the following prototype:
  139.  */
  140. SOM_Scope boolean  SOMLINK Update(Part somSelf,  Environment *ev, 
  141.                                   long lSet, long LAction, long* ID, 
  142.                                   long* Count)
  143. {
  144.    long nIndex;
  145.    PartData *somThis = PartGetData(somSelf);
  146.    PartMethodDebug("Part","Update");
  147.  
  148.     // ----------------------------------------------------------------------
  149.     // Call lowlevel search if not found, then return FALSE
  150.     // ----------------------------------------------------------------------
  151.  
  152.     if (!SearchParts(somThis,lSet,LAction,ID,Count))
  153.             return (FALSE);
  154.  
  155.     // ----------------------------------------------------------------------
  156.     // update Count for item found above
  157.     // ----------------------------------------------------------------------
  158.  
  159.     nIndex = (*ID);
  160.     somThis->stackActionCount[nIndex]++;
  161.  
  162.     // ----------------------------------------------------------------------
  163.     // if Debugging then dump out some information to the DSOM server window
  164.     // ----------------------------------------------------------------------
  165.  
  166.     if (somThis->DebugState)
  167.         printf("Updating Set = %d, Function = %d, Index = %d, Count = %d\n", lSet, LAction, nIndex,(*Count));
  168.  
  169.     // ----------------------------------------------------------------------
  170.     // make sure count has update count and return it and TRUE
  171.     // ----------------------------------------------------------------------
  172.  
  173.     (*Count) = somThis->stackActionCount[nIndex];
  174.     return (TRUE);
  175. }
  176.  
  177. SOM_Scope boolean  SOMLINK Debug(Part somSelf,  Environment *ev, 
  178.                                  boolean NewState)
  179. {
  180.     boolean OldState; 
  181.    PartData *somThis = PartGetData(somSelf);
  182.    PartMethodDebug("Part","Debug");
  183.  
  184.     OldState = somThis->DebugState;
  185.    somThis->DebugState = NewState;
  186.    return (OldState);
  187. }
  188.  
  189.  
  190. /*
  191.  * SOM_Scope long  SOMLINK Size(Part somSelf,  Environment *ev)
  192.  */
  193.  
  194. /*
  195.  * The prototype for Size was replaced by the following prototype:
  196.  */
  197. SOM_Scope long  SOMLINK Size(Part somSelf,  Environment *ev)
  198. {
  199.     PartData *somThis = PartGetData(somSelf);
  200.     PartMethodDebug("Part","Size");
  201.  
  202.      // -------------------------------------------------------------------
  203.      //  return total count of objects
  204.      // -------------------------------------------------------------------
  205.  
  206.      return (somThis->stackCount);
  207. }
  208.  
  209.  
  210. /*
  211.  * SOM_Scope void  SOMLINK somInit(Part somSelf)
  212.  */
  213.  
  214. /*
  215.  * The prototype for somInit was replaced by the following prototype:
  216.  */
  217. SOM_Scope void  SOMLINK somInit(Part somSelf)
  218. {
  219.     PartData *somThis = PartGetData(somSelf);
  220.     PartMethodDebug("Part","somInit");
  221.  
  222.      somThis->stackCount = 0;
  223.      somThis->DebugState = FALSE;
  224.  
  225.     Part_parent_SOMObject_somInit(somSelf);
  226. }
  227.  
  228.