#include <RegisterReference.h>
Inheritance diagram for RegisterRef< TMPLT >:
Public Types | |
enum | ERegisterSet { EFirstSet = 0, ELiteral = 0, EInput = 1, EOutput = 2, ELocal = 3, EStatus = 4, ELastSet, EUnknown = 1000 } |
Index all register sets. More... | |
enum | EProperties { EPropNone = 0, EPropReadOnly = 1, EPropCachePointer = 2, EPropPtrReset = 4, EPropByRefOnly = 8 } |
Properties control behavior of RegisterReference. More... | |
Public Member Functions | |
RegisterRef () | |
Creates an invalid object. | |
RegisterRef (ERegisterSet set, unsigned long index, StandardTypeDescriptorOrdinal datatype) | |
Creates a valid register reference. | |
TMPLT | value () const |
gets/peeks/reads a value from a register | |
void | value (TMPLT newV) |
puts/pokes/sets a value into a register | |
bool | isNullable () |
Returns true if the register can be set to null. | |
void | toNull () |
Sets a register to null. | |
bool | isNull () const |
Checks if register is null. | |
TMPLT | pointer () const |
Gets pointer value, rather than what pointer references. | |
void | pointer (TMPLT newP, TupleStorageByteLength len) |
Sets pointer value, rather than what pointer references. | |
TMPLT * | refer () const |
Gets reference by pointer for non-pointer types. | |
void | refer (RegisterRef< TMPLT > *from) |
Refers to other RegisterRef for non-pointer types. | |
TupleStorageByteLength | length () const |
Gets length, in bytes, of data buffer. | |
TupleStorageByteLength | storage () const |
Gets storage length / maximum length, in bytes, of data buffer. | |
TupleStorageByteLength | stringLength () const |
Gets length of string, in bytes, based on string type. | |
void | length (TupleStorageByteLength newLen) |
Sets length, in bytes, of data buffer. | |
void | stringLength (TupleStorageByteLength newLen) |
Sets length of string, in bytes, based on string type. | |
string | valueToString () const |
Returns a nicely formatted string representing register's current value. | |
void | setCalc (Calculator *calcP) |
Provides a pointer to encapsulating Calculator. | |
void | cachePointer () |
Performs pre-execution optimizations. | |
ERegisterSet | setIndex () const |
Returns set index. | |
unsigned long | index () const |
Returns register index within a set. | |
bool | isValid () const |
Is this a valid RegisterReference? | |
StandardTypeDescriptorOrdinal | type () const |
Returns type information. | |
string | toString () const |
Provides a nicely formatted string describing this register. | |
DynamicParamManager * | getDynamicParamManager () const |
Gets the DynamicParamManager belonging to the Calculator. | |
TupleDatum * | getBinding (bool resetFromNull=false) const |
gets the register binding | |
Static Public Member Functions | |
static string | getSetName (ERegisterSet set) |
Returns a string describing the register set. | |
static string | toString (ERegisterSet set, unsigned long index) |
Provides a nicely formatted string describing the register for the specified set and index. | |
Static Public Attributes | |
static const uint32_t | KLiteralSetDefault |
Literal set can be cached, and really should be read only. | |
static const uint32_t | KInputSetDefault = EPropReadOnly |
Input must be read only. Caching doesn't make sense for input. | |
static const uint32_t | KOutputSetDefault = EPropNone |
Caching doesn't make sense for output. | |
static const uint32_t | KLocalSetDefault |
Local set can be cached, and must reset pointers if Calculator::exec() is to be called again and NULLs are written or pointers are moved. | |
static const uint32_t | KStatusSetDefault = EPropNone |
Status register can be cached if it is never re-bound. | |
Protected Member Functions | |
void | setDefaultProperties () |
Defines default properties for registers based on register set. | |
Protected Attributes | |
const ERegisterSet | mSetIndex |
Register set index. | |
const unsigned long | mIndex |
Register index within a register set. | |
const StandardTypeDescriptorOrdinal | mType |
Underlying type of register. | |
TRegisterSetP | mRegisterSetP |
Array of pointers to register set bindings. | |
TRegisterSetDescP | mRegisterSetDescP |
Array of pointers to register set descriptors. | |
vector< RegisterReference * > * | mResetP |
RegisterReferences that will be reset before next exec. | |
bool | mCachePtrModified |
Cached pointer was set to null or moved. | |
PBuffer | mPData |
Cached and/or duplicated data pointer. | |
TupleStorageByteLength | mCbData |
Cached and/or duplicated length of mPData;. | |
TupleStorageByteLength | mCbStorage |
Cached and/or duplicated capacity of mPData;. | |
TRegisterRefProp | mProp |
Behavior properties of this register. | |
DynamicParamManager * | mPDynamicParamManager |
The DynamicParamManager set after a call to setCalc. |
Definition at line 353 of file RegisterReference.h.
enum RegisterReference::ERegisterSet [inherited] |
Index all register sets.
EFirstSet | |
ELiteral | |
EInput | |
EOutput | |
ELocal | |
EStatus | |
ELastSet | Insert new register set before this entry. |
EUnknown |
Definition at line 117 of file RegisterReference.h.
00117 { 00118 EFirstSet = 0, 00119 ELiteral = 0, 00120 EInput = 1, 00121 EOutput = 2, 00122 ELocal = 3, 00123 EStatus = 4, 00124 ELastSet, 00125 EUnknown = 1000 00126 };
enum RegisterReference::EProperties [inherited] |
Properties control behavior of RegisterReference.
Note: Values are powers of two to allow bitmasking.
EPropNone | No properties set. |
EPropReadOnly |
Prevent writes and re-pointing pData.
Enforced only through assert() |
EPropCachePointer | Keep a pointer to data instead of just in time indexing. |
EPropPtrReset | Journal pointer changes to allow resetting. |
EPropByRefOnly |
No memory associated.
Can only be repointed to other registers. See Calculator::outputRegisterByReference(). |
Definition at line 172 of file RegisterReference.h.
00172 { 00173 EPropNone = 0, 00174 EPropReadOnly = 1, 00175 00176 EPropCachePointer = 2, 00177 00178 EPropPtrReset = 4, 00179 EPropByRefOnly = 8 00180 00181 00182 };
RegisterRef< TMPLT >::RegisterRef | ( | ) | [inline, explicit] |
Creates an invalid object.
Definition at line 358 of file RegisterReference.h.
00358 : RegisterReference() 00359 {}
RegisterRef< TMPLT >::RegisterRef | ( | ERegisterSet | set, | |
unsigned long | index, | |||
StandardTypeDescriptorOrdinal | datatype | |||
) | [inline, explicit] |
Creates a valid register reference.
set | Register set | |
index | Register with a given set | |
datatype | The type of the underlying data. |
Definition at line 367 of file RegisterReference.h.
00371 : RegisterReference(set, index, datatype) 00372 {}
TMPLT RegisterRef< TMPLT >::value | ( | ) | const [inline] |
gets/peeks/reads a value from a register
Assumes register is not null.
Definition at line 377 of file RegisterReference.h.
Referenced by WinAggHistogram< STDTYPE >::addRow(), castApproxToStrA(), castBooleanToStrA(), CastDateTimeToInt64(), CastDateToStrA(), castExactToStrA(), CastStrAToDate(), CastStrAToTime(), CastStrAToTimestamp(), castStrToApproxA(), castStrToBooleanA(), castStrToExactA(), CastTimestampToStrA(), CastTimeToStrA(), convertDecimal(), convertDoubleToFloat(), convertExactNumberToString(), convertFloatToDouble(), convertFloatToInt(), convertIntToFloat(), convertStringToExactNumber(), ctxInst1(), ctxInst2(), ctxInst3(), ctxInst4(), ctxInst5(), CurrentTime(), CurrentTimestamp(), dynamicVariable(), PointerSub< PTR_TYPE >::exec(), PointerAdd< PTR_TYPE >::exec(), WinAggHistogram< STDTYPE >::getAvg(), WinAggHistogram< STDTYPE >::getCount(), getData(), WinAggHistogram< STDTYPE >::getFirstValue(), WinAggHistogram< STDTYPE >::getLastValue(), WinAggHistogram< STDTYPE >::getMax(), WinAggHistogram< STDTYPE >::getMin(), WinAggHistogram< STDTYPE >::getSum(), LocalTime(), LocalTimestamp(), mathAbs(), mathLn(), mathLog10(), mathPow(), strCmpA(), strCmpOct(), strLenBitA(), strLenCharA(), strLenOctA(), strLikeEscapeA(), strOverlayA4(), strOverlayA5(), strPosA(), strSimilarEscapeA(), strSubStringA3(), strSubStringA4(), strTrimA(), and RegisterRef< char * >::valueToString().
00377 { 00378 if (mProp & (EPropCachePointer | EPropPtrReset)) { 00379 assert(mPData); 00380 return *(reinterpret_cast<TMPLT*>(mPData)); 00381 } else { 00382 TupleDatum *bind = getBinding(); 00383 assert(bind->pData); // Cannot read from a NULL value. 00384 return *(reinterpret_cast<TMPLT*>( 00385 const_cast<PBuffer>(bind->pData))); 00386 } 00387 }
void RegisterRef< TMPLT >::value | ( | TMPLT | newV | ) | [inline] |
puts/pokes/sets a value into a register
Definition at line 392 of file RegisterReference.h.
00393 { 00394 // JDF 06/19/06 Need to find out why output register used for 00395 // histogram support gets marked as ReadOnly. 00396 if (0) { 00397 assert(!(mProp & EPropReadOnly)); 00398 } 00399 00400 if (mProp & (EPropCachePointer | EPropPtrReset)) { 00401 assert(mPData); 00402 *(reinterpret_cast<TMPLT*>(mPData)) = newV; 00403 } else { 00404 TupleDatum *bind = getBinding(true); // reset when null 00405 assert(bind->pData); 00406 *(reinterpret_cast<TMPLT*>( 00407 const_cast<PBuffer>(bind->pData))) = newV; 00408 } 00409 }
bool RegisterRef< TMPLT >::isNullable | ( | ) | [inline] |
Returns true if the register can be set to null.
Definition at line 412 of file RegisterReference.h.
Referenced by NativeNativeInstruction< TMPLT >::fnSetRegisterToNull().
00413 { 00414 return !(mProp & EPropReadOnly); 00415 }
void RegisterRef< TMPLT >::toNull | ( | ) | [inline] |
Sets a register to null.
Will append to mResetP to allow register to be reset.
Definition at line 420 of file RegisterReference.h.
Referenced by castApproxToStrA(), castBooleanToStrA(), CastDateTimeToInt64(), CastDateToStrA(), castExactToStrA(), CastStrAToDate(), CastStrAToTime(), CastStrAToTimestamp(), castStrToApproxA(), castStrToBinaryA(), castStrToBooleanA(), castStrToCharA(), castStrToExactA(), castStrToVarBinaryA(), castStrToVarCharA(), CastTimestampToStrA(), CastTimeToStrA(), PointerSub< PTR_TYPE >::exec(), PointerAdd< PTR_TYPE >::exec(), NativeNativeInstruction< TMPLT >::fnSetRegisterToNull(), WinAggHistogramStrA::getFirstValue(), WinAggHistogram< STDTYPE >::getFirstValue(), WinAggHistogramStrA::getLastValue(), WinAggHistogram< STDTYPE >::getLastValue(), WinAggHistogramStrA::getMax(), WinAggHistogram< STDTYPE >::getMax(), WinAggHistogramStrA::getMin(), WinAggHistogram< STDTYPE >::getMin(), WinAggHistogram< STDTYPE >::getSum(), mathAbs(), mathLn(), mathLog10(), mathPow(), strCatA2(), strCatA3(), strCmpA(), strCmpOct(), strCpyA(), strLenBitA(), strLenCharA(), strLenOctA(), strLikeEscapeA(), strOverlayA4(), strOverlayA5(), strPosA(), strSimilarEscapeA(), strSubStringA3(), strSubStringA4(), strToLowerA(), strToUpperA(), and strTrimA().
00420 { 00421 assert(!(mProp & EPropReadOnly)); 00422 if (mProp & (EPropCachePointer | EPropPtrReset)) { 00423 if ((mProp & EPropPtrReset) && !mCachePtrModified) { 00424 mCachePtrModified = true; 00425 mResetP->push_back(this); 00426 } 00427 mPData = NULL; 00428 mCbData = 0; 00429 } else { 00430 TupleDatum *bind = getBinding(); 00431 bind->pData = NULL; 00432 } 00433 }
bool RegisterRef< TMPLT >::isNull | ( | ) | const [inline, virtual] |
Checks if register is null.
Implements RegisterReference.
Definition at line 436 of file RegisterReference.h.
Referenced by WinAggHistogramStrA::addRow(), WinAggHistogram< STDTYPE >::addRow(), castApproxToStrA(), castBooleanToStrA(), CastDateTimeToInt64(), CastDateToStrA(), castExactToStrA(), CastStrAToDate(), CastStrAToTime(), CastStrAToTimestamp(), castStrToApproxA(), castStrToBinaryA(), castStrToBooleanA(), castStrToCharA(), castStrToExactA(), castStrToVarBinaryA(), castStrToVarCharA(), CastTimestampToStrA(), CastTimeToStrA(), ExtendedInstruction::describeArg(), JumpInstruction::describeHelper(), WinAggHistogramStrA::dropRow(), WinAggHistogram< STDTYPE >::dropRow(), PointerSub< PTR_TYPE >::exec(), PointerAdd< PTR_TYPE >::exec(), getData(), mathAbs(), mathLn(), mathLog10(), mathPow(), strCatA2(), strCatA3(), strCpyA(), strLenBitA(), strLenCharA(), strLenOctA(), strLikeEscapeA(), strOverlayA4(), strOverlayA5(), strPosA(), strSimilarEscapeA(), strSubStringA3(), strSubStringA4(), strToLowerA(), strToUpperA(), and strTrimA().
00436 { 00437 if (mProp & (EPropCachePointer | EPropPtrReset)) { 00438 return (mPData ? false : true); 00439 } else { 00440 TupleDatum *bind = getBinding(); 00441 return (bind->pData ? false : true); 00442 } 00443 }
TMPLT RegisterRef< TMPLT >::pointer | ( | ) | const [inline] |
Gets pointer value, rather than what pointer references.
Used by PointerInstruction, where TMPLT is a pointer type, never in other Instruction types, where TMPLT is not a pointer.
Definition at line 451 of file RegisterReference.h.
Referenced by castApproxToStrA(), castBooleanToStrA(), CastDateToStrA(), castExactToStrA(), CastStrAToDate(), CastStrAToTime(), CastStrAToTimestamp(), castStrToApproxA(), castStrToBinaryA(), castStrToBooleanA(), castStrToCharA(), castStrToExactA(), castStrToVarBinaryA(), castStrToVarCharA(), CastTimestampToStrA(), CastTimeToStrA(), convertExactNumberToString(), convertStringToExactNumber(), WinAggHistogramStrA::dropRow(), PointerSub< PTR_TYPE >::exec(), PointerAdd< PTR_TYPE >::exec(), LocalTime(), LocalTimestamp(), WinAggHistogramStrA::setReturnReg(), strCatA2(), strCatA3(), strCpyA(), strLenCharA(), strLikeEscapeA(), strOverlayA4(), strOverlayA5(), strPosA(), strSimilarEscapeA(), strSubStringA3(), strSubStringA4(), strToLowerA(), strToUpperA(), and strTrimA().
00451 { 00452 assert(StandardTypeDescriptor::isArray(mType)); 00453 if (mProp & (EPropCachePointer | EPropPtrReset)) { 00454 assert(mPData); // useful or harmful? 00455 return reinterpret_cast<TMPLT>(mPData); 00456 } else { 00457 TupleDatum *bind = getBinding(); 00458 assert(bind->pData); 00459 return reinterpret_cast<TMPLT>(const_cast<PBuffer>(bind->pData)); 00460 } 00461 }
void RegisterRef< TMPLT >::pointer | ( | TMPLT | newP, | |
TupleStorageByteLength | len | |||
) | [inline] |
Sets pointer value, rather than what pointer references.
Used by PointerInstruction, where TMPLT is a pointer type, never in other Instruction types, where TMPLT is not a pointer. Will append to mResetP to allow register to be reset.
Definition at line 469 of file RegisterReference.h.
00470 { 00471 assert(!(mProp & EPropReadOnly)); 00472 assert(newP); // use toNull() 00473 assert(StandardTypeDescriptor::isArray(mType)); 00474 if (mProp & (EPropCachePointer | EPropPtrReset)) { 00475 if ((mProp & EPropPtrReset) && !mCachePtrModified) { 00476 mCachePtrModified = true; 00477 mResetP->push_back(this); 00478 } 00479 mPData = reinterpret_cast<PBuffer>(newP); 00480 mCbData = len; 00481 } else { 00482 TupleDatum *bind = getBinding(); 00483 bind->pData = reinterpret_cast<PConstBuffer>(newP); 00484 bind->cbData = len; 00485 } 00486 }
TMPLT* RegisterRef< TMPLT >::refer | ( | ) | const [inline] |
Gets reference by pointer for non-pointer types.
Definition at line 489 of file RegisterReference.h.
Referenced by WinAggHistogram< STDTYPE >::dropRow(), and RegisterRef< char * >::refer().
00489 { 00490 if (mProp & (EPropCachePointer | EPropPtrReset)) { 00491 return reinterpret_cast<TMPLT*>(const_cast<PBuffer>(mPData)); 00492 } else { 00493 TupleDatum *bind = getBinding(); 00494 return reinterpret_cast<TMPLT*>(const_cast<PBuffer>(bind->pData)); 00495 } 00496 }
void RegisterRef< TMPLT >::refer | ( | RegisterRef< TMPLT > * | from | ) | [inline] |
Refers to other RegisterRef for non-pointer types.
Convenience function, replaces: to->pointer(from->pointer(), from->length()) Currently does not support cachepointer or reset as ByRefOnly implies a do-not-care register set.
Definition at line 504 of file RegisterReference.h.
00505 { 00506 assert(!(mProp & (EPropCachePointer | EPropPtrReset))); 00507 TupleDatum *bind = getBinding(); 00508 bind->pData = reinterpret_cast<PConstBuffer>( 00509 const_cast<TMPLT*>(from->refer())); 00510 bind->cbData = from->length(); 00511 }
TupleStorageByteLength RegisterRef< TMPLT >::length | ( | ) | const [inline] |
Gets length, in bytes, of data buffer.
This is the actual length of the object pointed to, not the amount of memory allocated for the object. For example, this could be the length, in bytes, of a VARCHAR string.
Definition at line 519 of file RegisterReference.h.
Referenced by castApproxToStrA(), castBooleanToStrA(), CastDateToStrA(), castExactToStrA(), castStrToBinaryA(), castStrToCharA(), castStrToVarBinaryA(), castStrToVarCharA(), CastTimestampToStrA(), CastTimeToStrA(), WinAggHistogramStrA::dropRow(), PointerSub< PTR_TYPE >::exec(), PointerAdd< PTR_TYPE >::exec(), RegisterRef< char * >::refer(), WinAggHistogramStrA::setReturnReg(), strCatA2(), strCatA3(), strCpyA(), RegisterRef< char * >::stringLength(), strLikeEscapeA(), strOverlayA4(), strOverlayA5(), strSimilarEscapeA(), strSubStringA3(), strSubStringA4(), strToLowerA(), strToUpperA(), and strTrimA().
00520 { 00521 if (mProp & (EPropCachePointer | EPropPtrReset)) { 00522 return mCbData; 00523 } else { 00524 TupleDatum *bind = getBinding(); 00525 return bind->cbData; 00526 } 00527 }
TupleStorageByteLength RegisterRef< TMPLT >::storage | ( | ) | const [inline] |
Gets storage length / maximum length, in bytes, of data buffer.
Note that there is no corresponding write storage(arg). Calculator considers cbStorage to be read-only information. Calculator can change neither the defined column width nor the amount of memory allocated.
Definition at line 535 of file RegisterReference.h.
Referenced by WinAggHistogramStrA::addRow(), castApproxToStrA(), castBooleanToStrA(), CastDateToStrA(), castExactToStrA(), castStrToBinaryA(), castStrToCharA(), castStrToVarBinaryA(), castStrToVarCharA(), CastTimestampToStrA(), CastTimeToStrA(), convertExactNumberToString(), WinAggHistogramStrA::dropRow(), PointerSub< PTR_TYPE >::exec(), strCatA2(), strCatA3(), strCpyA(), RegisterRef< char * >::stringLength(), strOverlayA4(), strOverlayA5(), strSubStringA3(), strSubStringA4(), strToLowerA(), and strToUpperA().
00536 { 00537 if (mProp & (EPropCachePointer | EPropPtrReset)) { 00538 return mCbStorage; 00539 } else { 00540 assert(mRegisterSetP); 00541 assert(mSetIndex < ELastSet); 00542 assert(mRegisterSetDescP[mSetIndex]); 00543 //Next 3 lines clarify complex 4th line: 00544 //TupleDescriptor* tupleDescP = mRegisterSetDescP[mSetIndex]; 00545 //TupleAttributeDescriptor* attrP = &((*tupleDescP)[mIndex]); 00546 //return attrP->cbStorage; 00547 return ((*(mRegisterSetDescP[mSetIndex]))[mIndex]).cbStorage; 00548 } 00549 }
TupleStorageByteLength RegisterRef< TMPLT >::stringLength | ( | ) | const [inline] |
Gets length of string, in bytes, based on string type.
Fixed width, CHAR, BINARY: Returns storage() Variable width, VARCHAR, VARBINARY: Returns length()
Definition at line 555 of file RegisterReference.h.
Referenced by CastStrAToDate(), CastStrAToTime(), CastStrAToTimestamp(), castStrToApproxA(), castStrToBinaryA(), castStrToBooleanA(), castStrToCharA(), castStrToExactA(), castStrToVarBinaryA(), castStrToVarCharA(), convertStringToExactNumber(), LocalTime(), LocalTimestamp(), strCpyA(), strLenBitA(), strLenCharA(), strLenOctA(), strOverlayA4(), strOverlayA5(), strPosA(), strSubStringA3(), strSubStringA4(), strToLowerA(), strToUpperA(), and strTrimA().
00556 { 00557 assert(StandardTypeDescriptor::isArray(mType)); 00558 if (StandardTypeDescriptor::isVariableLenArray(mType)) { 00559 return length(); 00560 } else { 00561 return storage(); 00562 } 00563 }
void RegisterRef< TMPLT >::length | ( | TupleStorageByteLength | newLen | ) | [inline] |
Sets length, in bytes, of data buffer.
This is the actual length of the object pointed to, not the amount of memory allocated for the object. For example, this could be the length, in bytes, of a VARCHAR string.
Definition at line 570 of file RegisterReference.h.
00571 { 00572 if (mProp & (EPropCachePointer | EPropPtrReset)) { 00573 // useful or harmful? 00574 assert(newLen == 0 ? true : (mPData == 0 ? false : true)); 00575 // useful or harmful? 00576 assert(newLen <= mCbStorage); 00577 mCbData = newLen; 00578 } else { 00579 assert( 00580 newLen 00581 <= ((*(mRegisterSetDescP[mSetIndex]))[mIndex]).cbStorage); 00582 TupleDatum *bind = getBinding(); 00583 bind->cbData = newLen; 00584 } 00585 }
void RegisterRef< TMPLT >::stringLength | ( | TupleStorageByteLength | newLen | ) | [inline] |
Sets length of string, in bytes, based on string type.
Fixed width, CHAR/BINARY: has no effect. Variable width, VARCHAR/VARBINARY: acts as a length(arg) wrapper.
Definition at line 591 of file RegisterReference.h.
00592 { 00593 assert(StandardTypeDescriptor::isArray(mType)); 00594 if (StandardTypeDescriptor::isVariableLenArray(mType)) { 00595 length(newLen); 00596 } 00597 }
string RegisterRef< TMPLT >::valueToString | ( | ) | const [inline, virtual] |
Returns a nicely formatted string representing register's current value.
Note: Currently does not support pointer/array types like VARCHAR.
Implements RegisterReference.
Definition at line 604 of file RegisterReference.h.
Referenced by convertExactNumberToString(), convertStringToExactNumber(), ExtendedInstruction::describeArg(), and JumpInstruction::describeHelper().
00604 { 00605 if (this->isNull()) { // does assert checking for us 00606 return "NULL"; 00607 } 00608 if (StandardTypeDescriptor::isArray(mType)) { 00609 #if 0 00610 // Does not compile due to ptr/non-ptr compile issue 00611 // TODO: Make this work with VARBINARY and I18N 00612 // TODO: Remove the reinterpret_cast. Ugly. 00613 string ret((char *)(this->pointer()), this->getS()); 00614 return ret; 00615 #endif 00616 return "Unimpl"; 00617 } else { 00618 // TODO: Remove boost call, use stream instead 00619 return boost::lexical_cast<std::string>(this->value()); 00620 } 00621 }
void RegisterReference::setCalc | ( | Calculator * | calcP | ) | [inherited] |
Provides a pointer to encapsulating Calculator.
Must be in .cpp file for recursive include requirement reasons. Refers to Calculator and RegisterReference objects. See also Calculator::outputRegisterByReference().
See Calculator::outputRegisterByReference()
Definition at line 79 of file RegisterReference.cpp.
References RegisterReference::EOutput, RegisterReference::EPropByRefOnly, RegisterReference::EPropReadOnly, Calculator::getDynamicParamManager(), Calculator::mOutputRegisterByReference, RegisterReference::mPDynamicParamManager, RegisterReference::mProp, Calculator::mRegisterReset, Calculator::mRegisterSetBinding, RegisterReference::mRegisterSetDescP, Calculator::mRegisterSetDescriptor, RegisterReference::mRegisterSetP, RegisterReference::mResetP, and RegisterReference::mSetIndex.
Referenced by Calculator::appendRegRef().
00079 { 00080 mRegisterSetP = calcP->mRegisterSetBinding; 00081 mRegisterSetDescP = calcP->mRegisterSetDescriptor; 00082 mResetP = &(calcP->mRegisterReset); 00083 mPDynamicParamManager = calcP->getDynamicParamManager(); 00084 if (mSetIndex == EOutput && calcP->mOutputRegisterByReference) { 00086 mProp |= (EPropByRefOnly | EPropReadOnly); 00087 } 00088 }
void RegisterReference::cachePointer | ( | ) | [inherited] |
Performs pre-execution optimizations.
If CachePointer or PtrReset properties are set, save a pointer directly to the data.
Definition at line 91 of file RegisterReference.cpp.
References TupleDatum::cbData, RegisterReference::EPropCachePointer, RegisterReference::EPropPtrReset, RegisterReference::getBinding(), RegisterReference::mCachePtrModified, RegisterReference::mCbData, RegisterReference::mCbStorage, RegisterReference::mIndex, RegisterReference::mPData, RegisterReference::mProp, RegisterReference::mRegisterSetDescP, RegisterReference::mSetIndex, and TupleDatum::pData.
Referenced by Calculator::bind(), and Calculator::exec().
00091 { 00092 if (mProp & (EPropCachePointer | EPropPtrReset)) { 00093 TupleDatum *bind = getBinding(); 00094 mPData = const_cast<PBuffer>(bind->pData); 00095 mCbData = bind->cbData; 00096 00097 // Next 3 lines clarify complex 4th line: 00098 // TupleDescriptor* tupleDescP = mRegisterSetDescP[mSetIndex]; 00099 // TupleAttributeDescriptor* attrP = &((*tupleDescP)[mIndex]); 00100 // mCbStorage = attrP->cbStorage; 00101 mCbStorage = ((*(mRegisterSetDescP[mSetIndex]))[mIndex]).cbStorage; 00102 mCachePtrModified = false; 00103 } 00104 }
ERegisterSet RegisterReference::setIndex | ( | ) | const [inline, inherited] |
Returns set index.
Definition at line 217 of file RegisterReference.h.
Referenced by Calculator::appendRegRef().
00218 { 00219 return mSetIndex; 00220 }
unsigned long RegisterReference::index | ( | ) | const [inline, inherited] |
Returns register index within a set.
Definition at line 222 of file RegisterReference.h.
00223 { 00224 return mIndex; 00225 }
bool RegisterReference::isValid | ( | ) | const [inline, inherited] |
Is this a valid RegisterReference?
Definition at line 227 of file RegisterReference.h.
Referenced by JumpInstruction::describeHelper(), and Instruction::describeHelper().
StandardTypeDescriptorOrdinal RegisterReference::type | ( | ) | const [inline, inherited] |
Returns type information.
Definition at line 232 of file RegisterReference.h.
Referenced by WinAggHistogramStrA::addRow(), castApproxToStrA(), castBooleanToStrA(), CastDateTimeToInt64(), CastDateToStrA(), castExactToStrA(), CastStrAToDate(), CastStrAToTime(), CastStrAToTimestamp(), castStrToApproxA(), castStrToBinaryA(), castStrToBooleanA(), castStrToCharA(), castStrToExactA(), castStrToVarBinaryA(), castStrToVarCharA(), CastTimestampToStrA(), CastTimeToStrA(), CurrentTime(), CurrentTimestamp(), WinAggHistogramStrA::dropRow(), CalcAssembler::getRegisterType(), histogramAlloc(), LocalTime(), LocalTimestamp(), mathAbs(), mathLn(), mathLog10(), mathPow(), strCpyA(), strLenBitA(), strLenCharA(), strLenOctA(), strLikeEscapeA(), strOverlayA4(), strOverlayA5(), strPosA(), strSimilarEscapeA(), strSubStringA3(), strSubStringA4(), strToLowerA(), strToUpperA(), and strTrimA().
00232 { 00233 return mType; 00234 }
static string RegisterReference::getSetName | ( | ERegisterSet | set | ) | [inline, static, inherited] |
Returns a string describing the register set.
Definition at line 237 of file RegisterReference.h.
Referenced by CalcAssembler::getRegister().
00238 { 00239 switch (set) { 00240 case ELiteral: 00241 return "C"; 00242 case ELocal: 00243 return "L"; 00244 case EInput: 00245 return "I"; 00246 case EOutput: 00247 return "O"; 00248 case EStatus: 00249 return "S"; 00250 default: 00251 throw std::invalid_argument( 00252 "fennel/calculator/RegisterReference::getSetName"); 00253 } 00254 }
static string RegisterReference::toString | ( | ERegisterSet | set, | |
unsigned long | index | |||
) | [inline, static, inherited] |
Provides a nicely formatted string describing the register for the specified set and index.
Definition at line 259 of file RegisterReference.h.
Referenced by CalcAssembler::createInstruction(), ExtendedInstruction::describeArg(), JumpInstruction::describeHelper(), and Instruction::describeHelper().
00260 { 00261 ostringstream ostr(""); 00262 ostr << getSetName(set) << index; 00263 return ostr.str(); 00264 }
string RegisterReference::toString | ( | ) | const [inherited] |
Provides a nicely formatted string describing this register.
Definition at line 133 of file RegisterReference.cpp.
References RegisterReference::mIndex, and RegisterReference::mSetIndex.
Referenced by CalcAssembler::bindRegisterValue(), and CalcAssembler::createRegisterReference().
DynamicParamManager* RegisterReference::getDynamicParamManager | ( | ) | const [inline, inherited] |
Gets the DynamicParamManager belonging to the Calculator.
Definition at line 274 of file RegisterReference.h.
00274 { 00275 assert(mPDynamicParamManager); 00276 return mPDynamicParamManager; 00277 }
TupleDatum* RegisterReference::getBinding | ( | bool | resetFromNull = false |
) | const [inline, inherited] |
gets the register binding
resetFromNull,: | if the register is null, reset the address to the target buffer so the value can be changed. |
Definition at line 282 of file RegisterReference.h.
References TupleDatum::pData.
Referenced by add(), WinAggHistogramStrA::addRow(), avg(), RegisterReference::cachePointer(), count(), drop(), firstValue(), histogramAlloc(), RegisterRef< char * >::isNull(), lastValue(), RegisterRef< char * >::length(), max(), min(), RegisterRef< char * >::pointer(), RegisterRef< char * >::refer(), sum(), RegisterRef< char * >::toNull(), and RegisterRef< char * >::value().
00282 { 00283 // validate indexes 00284 assert(mRegisterSetP); 00285 assert(mSetIndex < ELastSet); 00286 assert(mRegisterSetP[mSetIndex]); 00287 RegisterSetBinding* rsb = mRegisterSetP[mSetIndex]; 00288 TupleDatum& bind = (*rsb)[mIndex]; 00289 if (resetFromNull) { 00290 if (!bind.pData) { 00291 bind.pData = mRegisterSetP[mSetIndex]->getTargetAddr(mIndex); 00292 } 00293 } 00294 return &bind; 00295 }
void RegisterReference::setDefaultProperties | ( | ) | [protected, inherited] |
Defines default properties for registers based on register set.
Definition at line 107 of file RegisterReference.cpp.
References RegisterReference::EInput, RegisterReference::ELiteral, RegisterReference::ELocal, RegisterReference::EOutput, RegisterReference::EPropNone, RegisterReference::EStatus, RegisterReference::KInputSetDefault, RegisterReference::KLiteralSetDefault, RegisterReference::KLocalSetDefault, RegisterReference::KOutputSetDefault, RegisterReference::KStatusSetDefault, RegisterReference::mProp, and RegisterReference::mSetIndex.
00108 { 00109 switch (mSetIndex) { 00110 case ELiteral: 00111 mProp = KLiteralSetDefault; 00112 break; 00113 case EInput: 00114 mProp = KInputSetDefault; 00115 break; 00116 case EOutput: 00117 mProp = KOutputSetDefault; 00118 break; 00119 case ELocal: 00120 mProp = KLocalSetDefault; 00121 break; 00122 case EStatus: 00123 mProp = KStatusSetDefault; 00124 break; 00125 default: 00126 mProp = EPropNone; 00127 } 00128 }
const uint32_t RegisterReference::KLiteralSetDefault [static, inherited] |
Initial value:
Literal set can be cached, and really should be read only.
Definition at line 186 of file RegisterReference.h.
Referenced by RegisterReference::setDefaultProperties().
const uint32_t RegisterReference::KInputSetDefault = EPropReadOnly [static, inherited] |
Input must be read only. Caching doesn't make sense for input.
Definition at line 190 of file RegisterReference.h.
Referenced by RegisterReference::setDefaultProperties().
const uint32_t RegisterReference::KOutputSetDefault = EPropNone [static, inherited] |
Caching doesn't make sense for output.
Definition at line 193 of file RegisterReference.h.
Referenced by RegisterReference::setDefaultProperties().
const uint32_t RegisterReference::KLocalSetDefault [static, inherited] |
Initial value:
Local set can be cached, and must reset pointers if Calculator::exec() is to be called again and NULLs are written or pointers are moved.
Definition at line 197 of file RegisterReference.h.
Referenced by RegisterReference::setDefaultProperties().
const uint32_t RegisterReference::KStatusSetDefault = EPropNone [static, inherited] |
Status register can be cached if it is never re-bound.
Definition at line 201 of file RegisterReference.h.
Referenced by RegisterReference::setDefaultProperties().
const ERegisterSet RegisterReference::mSetIndex [protected, inherited] |
Register set index.
Definition at line 299 of file RegisterReference.h.
Referenced by RegisterReference::cachePointer(), RegisterRef< char * >::length(), RegisterReference::setCalc(), RegisterReference::setDefaultProperties(), RegisterRef< char * >::storage(), and RegisterReference::toString().
const unsigned long RegisterReference::mIndex [protected, inherited] |
Register index within a register set.
Definition at line 302 of file RegisterReference.h.
Referenced by RegisterReference::cachePointer(), RegisterRef< char * >::length(), RegisterRef< char * >::storage(), and RegisterReference::toString().
const StandardTypeDescriptorOrdinal RegisterReference::mType [protected, inherited] |
Underlying type of register.
Definition at line 305 of file RegisterReference.h.
Referenced by RegisterRef< char * >::pointer(), RegisterRef< char * >::stringLength(), and RegisterRef< char * >::valueToString().
TRegisterSetP RegisterReference::mRegisterSetP [protected, inherited] |
Array of pointers to register set bindings.
Used as starting point to index through sets and registers.
Definition at line 310 of file RegisterReference.h.
Referenced by RegisterReference::setCalc(), and RegisterRef< char * >::storage().
TRegisterSetDescP RegisterReference::mRegisterSetDescP [protected, inherited] |
Array of pointers to register set descriptors.
Used as starting point to index through sets and registers.
Definition at line 315 of file RegisterReference.h.
Referenced by RegisterReference::cachePointer(), RegisterRef< char * >::length(), RegisterReference::setCalc(), and RegisterRef< char * >::storage().
vector<RegisterReference *>* RegisterReference::mResetP [protected, inherited] |
RegisterReferences that will be reset before next exec.
Points to Calculator. Appended to iff PtrReset property is set.
Definition at line 320 of file RegisterReference.h.
Referenced by RegisterRef< char * >::pointer(), RegisterReference::setCalc(), and RegisterRef< char * >::toNull().
bool RegisterReference::mCachePtrModified [protected, inherited] |
Cached pointer was set to null or moved.
Definition at line 323 of file RegisterReference.h.
Referenced by RegisterReference::cachePointer(), RegisterRef< char * >::pointer(), and RegisterRef< char * >::toNull().
PBuffer RegisterReference::mPData [protected, inherited] |
Cached and/or duplicated data pointer.
Only valid if CachePointer or PtrReset property is set.
Definition at line 328 of file RegisterReference.h.
Referenced by RegisterReference::cachePointer(), RegisterRef< char * >::isNull(), RegisterRef< char * >::length(), RegisterRef< char * >::pointer(), RegisterRef< char * >::refer(), RegisterRef< char * >::toNull(), and RegisterRef< char * >::value().
TupleStorageByteLength RegisterReference::mCbData [protected, inherited] |
Cached and/or duplicated length of mPData;.
Only valid if CachePointer or PtrReset property is set.
Definition at line 333 of file RegisterReference.h.
Referenced by RegisterReference::cachePointer(), RegisterRef< char * >::length(), RegisterRef< char * >::pointer(), and RegisterRef< char * >::toNull().
TupleStorageByteLength RegisterReference::mCbStorage [protected, inherited] |
Cached and/or duplicated capacity of mPData;.
Only valid if CachePointer or PtrReset property is set.
Definition at line 338 of file RegisterReference.h.
Referenced by RegisterReference::cachePointer(), RegisterRef< char * >::length(), and RegisterRef< char * >::storage().
TRegisterRefProp RegisterReference::mProp [protected, inherited] |
Behavior properties of this register.
Definition at line 341 of file RegisterReference.h.
Referenced by RegisterReference::cachePointer(), RegisterRef< char * >::isNull(), RegisterRef< char * >::isNullable(), RegisterRef< char * >::length(), RegisterRef< char * >::pointer(), RegisterRef< char * >::refer(), RegisterReference::setCalc(), RegisterReference::setDefaultProperties(), RegisterRef< char * >::storage(), RegisterRef< char * >::toNull(), and RegisterRef< char * >::value().
DynamicParamManager* RegisterReference::mPDynamicParamManager [protected, inherited] |
The DynamicParamManager set after a call to setCalc.
Definition at line 344 of file RegisterReference.h.
Referenced by RegisterReference::setCalc().