Accounting Software
Small Business Software Estimating Software
Inventory SoftwareInventory Control SoftwareInventory Tracking SoftwareInventory Management SoftwareConstruction Management SoftwareProject Management SoftwareBusiness Management Software

Range Selectors (Source Code)

Link to: header | other data directory

Copyright Turtle Creek Software 1996-2006. All Rights Reserved.

Comments

DB_RangeSelector

This class finds value ranges for the Goldenseal job cost accounting software,
project management software, construction estimating software
and construction project estimating software.

It's a selector for a range of values. This class stores pointers to two other selectors which
handle the high range and the low range.

SUPERCLASS= DB_MemberSelector

Constructor

/*********************************************************************************
default constructor changed inheritance TCS 12/18/01
*********************************************************************************/
DB_RangeSelector::DB_RangeSelector(const TagType aTag, DB_MemberSelector *lowSelector,
DB_MemberSelector *highSelector)
: DB_MemberSelector(aTag)
{
// we now allow the incoming selectors to be nil TCS 6/5/03

mMemberType = type_range; // TCS 6/5/03

// set up the incoming selectors. Note that we are responsible for
// the two selectors, and should dispose of them in the destructor
mLowSelector = lowSelector;
if (mLowSelector)
mLowSelector->setOrder(kNeoHighOrEqual);

mHighSelector = highSelector;
if (mHighSelector)
mHighSelector->setOrder(kNeoLowOrEqual);
}/*********************************************************************************
destructor
*********************************************************************************/
DB_RangeSelector::~DB_RangeSelector()
{
// kill the high and low selectors
TCS_Forget(mLowSelector); // TCS rev 11/5/00
TCS_Forget(mHighSelector); // TCS rev 11/5/00
}

Source Code

/*********************************************************************************

ReadFromStream TCS 6/4/03

read the selector in from a stream.

*********************************************************************************/
void DB_RangeSelector::ReadFromStream(CNeoStream *aStream, const TagType aTag)
{
// read in basic info
THE_SUPERCLASS::ReadFromStream(aStream, aTag);
// create the low selector
mLowSelector = CreateSelectorFromStream(aStream);
TCS_FailNILMsg(mLowSelector, TCS_GetErrString(errID_BadSelector));
mLowSelector->setOrder(kNeoHighOrEqual);

// create the high selector
mHighSelector = CreateSelectorFromStream(aStream);
TCS_FailNILMsg(mHighSelector, TCS_GetErrString(errID_BadSelector));
mHighSelector->setOrder(kNeoLowOrEqual);
}
/*********************************************************************************

WriteToStream TCS 6/4/03

write the selector to a stream

*********************************************************************************/
void DB_RangeSelector::WriteToStream(CNeoStream *aStream,
const TagType aTag) const
{
TCS_FailNILMsg(mLowSelector, TCS_GetErrString(errID_BadSelector));
TCS_FailNILMsg(mHighSelector, TCS_GetErrString(errID_BadSelector));

// write basic info
THE_SUPERCLASS::WriteToStream(aStream, aTag);

// write each selector individually
mLowSelector->WriteToStream(aStream, aTag);
mHighSelector->WriteToStream(aStream, aTag);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

compare

compare the given object to our selectors.

*********************************************************************************/
NeoOrder DB_RangeSelector::compare(const CNeoPersist *aObject,
const short aOffset,
NeoOrder *aKeyOrder) const
{
// sanity check
TCS_FailNILMsg(mLowSelector, TCS_GetErrString(errID_BadSelector));
TCS_FailNILMsg(mHighSelector, TCS_GetErrString(errID_BadSelector));

*aKeyOrder = mLowSelector->compare(aObject, aOffset, aKeyOrder);

if (*aKeyOrder != kNeoExact)
return *aKeyOrder;

*aKeyOrder = mHighSelector->compare(aObject, aOffset, aKeyOrder);
return *aKeyOrder;
}
/*********************************************************************************

MatchesString TCS 12/18/02

return whether this selector matches the given value. This is
a direct comparison that we use for matches with a menu array or index
array, rather than with an object

*********************************************************************************/
Boolean DB_RangeSelector::MatchesString(const CTextString &value) const
{
NeoOrder order = mLowSelector->CompareStrings(value);
if (order != kNeoExact)
return false;
order = mHighSelector->CompareStrings(value);
return (order == kNeoExact);
}
/*********************************************************************************

MatchesDate TCS 12/18/02

return whether this selector matches the given value. This is
a direct comparison that we use for matches with a menu array or index
array, rather than with an object

*********************************************************************************/
Boolean DB_RangeSelector::MatchesDate(const CDate &value) const
{
NeoOrder order = mLowSelector->CompareDates(value);
if (order != kNeoExact)
return false;
order = mHighSelector->CompareDates(value);
return (order == kNeoExact);
}
/*********************************************************************************

MatchesMoney TCS 12/18/02

return whether this selector matches the given value. This is
a direct comparison that we use for matches with a menu array or index
array, rather than with an object

*********************************************************************************/
Boolean DB_RangeSelector::MatchesMoney(const CMoney &value) const
{
NeoOrder order = mLowSelector->CompareMoney(value);
if (order != kNeoExact)
return false;
order = mHighSelector->CompareMoney(value);
return (order == kNeoExact);
}
/*********************************************************************************

MatchesLong TCS 12/18/02

return whether this selector matches the given value. This is
a direct comparison that we use for matches with a menu array or index
array, rather than with an object

*********************************************************************************/
Boolean DB_RangeSelector::MatchesLong(const DBid value) const
{
NeoOrder order = mLowSelector->CompareLongs(value);
if (order != kNeoExact)
return false;
order = mHighSelector->CompareLongs(value);
return (order == kNeoExact);
}