home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
sompar.zip
/
SOM
/
PART.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-10
|
7KB
|
228 lines
/*
* This file was generated by the SOM Compiler.
* Generated using:
* SOM incremental update: somc/smmain.c
*/
/*
* This file was generated by the SOM Compiler and Emitter Framework.
* Generated using:
* SOM Emitter emitctm: somc/smmain.c
*/
#define Part_Class_Source
#include <stdio.h>
#include <part.ih>
static boolean SearchParts(PartData *pData, long lSet,
long lAction, long* ID, long* Count)
{
long nIndex, nCount;
// --------------------------------------------------------------------
// Search through the internal data structures for same item
// --------------------------------------------------------------------
nCount = pData->stackCount;
for (nIndex=0;nIndex<nCount;nIndex++)
{
if ((pData->stackSet[nIndex] == lSet) && (pData->stackAction[nIndex] == lAction))
{
(*ID) = nIndex;
(*Count) = pData->stackActionCount[nIndex];
return (TRUE);
}
}
// --------------------------------------------------------------------
// item is not found so return back FALSE;
// --------------------------------------------------------------------
(*ID) = 0l;
(*Count) = 0l;
return (FALSE);
}
/*
* SOM_Scope boolean SOMLINK Search(Part somSelf, Environment *ev,
* long lSet, long lAction, long* ID,
* long* Count)
*/
/*
* The prototype for Search was replaced by the following prototype:
*/
SOM_Scope boolean SOMLINK Search(Part somSelf, Environment *ev,
long lSet, long lAction, long* ID,
long* Count)
{
PartData *somThis = PartGetData(somSelf);
PartMethodDebug("Part","Search");
// ----------------------------------------------------------------------
// Call internal function to search for ID and return result
// ----------------------------------------------------------------------
return(SearchParts(somThis,lSet,lAction,ID,Count));
}
/*
* SOM_Scope boolean SOMLINK Add(Part somSelf, Environment *ev,
* long lSet, long LAction, long* ID,
* long* Count)
*/
/*
* The prototype for Add was replaced by the following prototype:
*/
SOM_Scope boolean SOMLINK Add(Part somSelf, Environment *ev,
long lSet, long LAction, long* ID,
long* Count)
{
long nIndex;
PartData *somThis = PartGetData(somSelf);
PartMethodDebug("Part","Add");
// ----------------------------------------------------------------------
// if stack count is equal to or great than max return FALSE
// ----------------------------------------------------------------------
if (somThis->stackCount >= Part_stackSize)
return (FALSE);
// ----------------------------------------------------------------------
// Call lowlevel search if found, then return FALSE
// ----------------------------------------------------------------------
if (SearchParts(somThis,lSet,LAction,ID,Count))
return (FALSE);
// ----------------------------------------------------------------------
// create a new item
// ----------------------------------------------------------------------
nIndex = somThis->stackCount++;
somThis->stackSet[nIndex] = lSet;
somThis->stackAction[nIndex] = LAction;
somThis->stackActionCount[nIndex] = 1;
// ----------------------------------------------------------------------
// if Debugging then dump out some information to the DSOM server window
// ----------------------------------------------------------------------
if (somThis->DebugState)
printf("Adding Set = %d, Function = %d, Index = %d\n", lSet, LAction, nIndex);
// ----------------------------------------------------------------------
// return the newly created index, count of 1 and TRUE
// ----------------------------------------------------------------------
(*ID) = nIndex;
(*Count) = 1l;
return (TRUE);
}
/*
* SOM_Scope boolean SOMLINK Update(Part somSelf, Environment *ev,
* long lSet, long LAction, long* ID,
* long* Count)
*/
/*
* The prototype for Update was replaced by the following prototype:
*/
SOM_Scope boolean SOMLINK Update(Part somSelf, Environment *ev,
long lSet, long LAction, long* ID,
long* Count)
{
long nIndex;
PartData *somThis = PartGetData(somSelf);
PartMethodDebug("Part","Update");
// ----------------------------------------------------------------------
// Call lowlevel search if not found, then return FALSE
// ----------------------------------------------------------------------
if (!SearchParts(somThis,lSet,LAction,ID,Count))
return (FALSE);
// ----------------------------------------------------------------------
// update Count for item found above
// ----------------------------------------------------------------------
nIndex = (*ID);
somThis->stackActionCount[nIndex]++;
// ----------------------------------------------------------------------
// if Debugging then dump out some information to the DSOM server window
// ----------------------------------------------------------------------
if (somThis->DebugState)
printf("Updating Set = %d, Function = %d, Index = %d, Count = %d\n", lSet, LAction, nIndex,(*Count));
// ----------------------------------------------------------------------
// make sure count has update count and return it and TRUE
// ----------------------------------------------------------------------
(*Count) = somThis->stackActionCount[nIndex];
return (TRUE);
}
SOM_Scope boolean SOMLINK Debug(Part somSelf, Environment *ev,
boolean NewState)
{
boolean OldState;
PartData *somThis = PartGetData(somSelf);
PartMethodDebug("Part","Debug");
OldState = somThis->DebugState;
somThis->DebugState = NewState;
return (OldState);
}
/*
* SOM_Scope long SOMLINK Size(Part somSelf, Environment *ev)
*/
/*
* The prototype for Size was replaced by the following prototype:
*/
SOM_Scope long SOMLINK Size(Part somSelf, Environment *ev)
{
PartData *somThis = PartGetData(somSelf);
PartMethodDebug("Part","Size");
// -------------------------------------------------------------------
// return total count of objects
// -------------------------------------------------------------------
return (somThis->stackCount);
}
/*
* SOM_Scope void SOMLINK somInit(Part somSelf)
*/
/*
* The prototype for somInit was replaced by the following prototype:
*/
SOM_Scope void SOMLINK somInit(Part somSelf)
{
PartData *somThis = PartGetData(somSelf);
PartMethodDebug("Part","somInit");
somThis->stackCount = 0;
somThis->DebugState = FALSE;
Part_parent_SOMObject_somInit(somSelf);
}