void onUpdate (MamdaFundamentalListener::MamdaFundamentalListenerImpl& impl, const MamaMsgField& field) { switch (field.getType()) { case MAMA_FIELD_TYPE_I8: case MAMA_FIELD_TYPE_U8: case MAMA_FIELD_TYPE_I16: case MAMA_FIELD_TYPE_U16: case MAMA_FIELD_TYPE_I32: case MAMA_FIELD_TYPE_U32: impl.mDivFreq = impl.getDividendFrequency (field.getU32()); impl.mDivFreqFieldState = MODIFIED; break; case MAMA_FIELD_TYPE_STRING: impl.mDivFreq = impl.getDividendFrequency (field.getString()); impl.mDivFreqFieldState = MODIFIED; break; default: mama_log (MAMA_LOG_LEVEL_FINE, "Unhandled type %d for wDivFreq. " "Expected string or integer.", field.getType()); break; } }
void onUpdate (MamdaQuoteToBookListenerImpl& impl, const MamaMsgField& field) { if (field.getType () == MAMA_FIELD_TYPE_STRING) { impl.mQuoteCache.mQuoteQualNative = field.getString(); } else if (field.getType () == MAMA_FIELD_TYPE_CHAR) { impl.mQuoteCache.mQuoteQualNative = field.getChar(); } }
void onUpdate (MamdaFundamentalListener::MamdaFundamentalListenerImpl& impl, const MamaMsgField& field) { const char* marketSegment; int segment; switch (field.getType()) { case MAMA_FIELD_TYPE_I8: case MAMA_FIELD_TYPE_U8: case MAMA_FIELD_TYPE_I16: case MAMA_FIELD_TYPE_U16: case MAMA_FIELD_TYPE_I32: case MAMA_FIELD_TYPE_U32: segment = field.getU32(); if (0 == segment) { impl.mMarketSegment = MamdaFundamentalFields::MRKT_SEGMENT_NONE; impl.mMarketSegmentFieldState = MODIFIED; } else { ostringstream stringbuilder; stringbuilder << segment; impl.mMarketSegment = stringbuilder.str(); impl.mMarketSegmentFieldState = MODIFIED; } break; case MAMA_FIELD_TYPE_STRING: marketSegment = field.getString(); if (strcmp (marketSegment, "0") == 0) { // No market segment is known/available for this security impl.mMarketSegment = MamdaFundamentalFields::MRKT_SEGMENT_NONE; impl.mMarketSegmentFieldState = MODIFIED; } else { // Already a string; impl.mMarketSegment = marketSegment; impl.mMarketSegmentFieldState = MODIFIED; } break; default: mama_log (MAMA_LOG_LEVEL_FINE, "Unhandled type %d for wMarketSegment. " "Expected string or integer.", field.getType()); break; } }
uint32_t MamaRecordedMessageCodec::encodeVectorMsg(char*& buffer, MamaMsgField& mmf) { const MamaMsg** mmpp = NULL; char* orig_buffer = buffer; // Reserve these four bytes for the vector size buffer += 4; MamaMsg* mmp = NULL; mama_size_t count = 0; uint16_t r = 4; uint16_t msg_size = 0; mmf.getVectorMsg(mmpp, count); if(count == 0) { return 0; } uint16_t msg_length = (uint16_t)count; for(mama_size_t i = 0; i < count; i++) { mmp = (MamaMsg*)*mmpp; //printf("Encountering Message: %s\n", mmp->toString()); msg_size += encodeMsg(buffer, mmp); r += msg_size; buffer += msg_size; mmpp++; } // Now we know the total vector size, write it in. memcpy(orig_buffer, &r, 2); memcpy(orig_buffer+2, &msg_length, 2); //printf("Encoded [%d] Vector Message Fields of size [%d]...\n", count, r); return (uint32_t)r; }
void onUpdate (MamdaQuoteToBookListenerImpl& impl, const MamaMsgField& field) { ; field.getDateTime(impl.mQuoteCache.mSrcTime); impl.mQuoteCache.mSrcTimeFieldState = MODIFIED; }
uint32_t MamaRecordedMessageCodec::encodeTime(char*& buffer, MamaMsgField& mmf) { mmf.getDateTime(*mTempMamaDateTime); // Get the C version as well because some functionality is missing from C++ for some reason *mTempCMamaDateTime = mTempMamaDateTime->getCValue(); mama_u32_t seconds = 0; // 4 bytes mama_u32_t microseconds = 0; // 4 bytes mamaDateTimePrecision precision = (mamaDateTimePrecision)0; // 4 bytes mama_u8_t hints = 0; // 1 byte if(mTempMamaDateTime->hasDate()) hints = hints | MAMA_DATE_TIME_HAS_DATE; if(mTempMamaDateTime->hasTime()) hints = hints | MAMA_DATE_TIME_HAS_TIME; mamaDateTime_getWithHints(*mTempCMamaDateTime, &seconds, µseconds, &precision, &hints); memcpy(buffer, &seconds, 4); buffer += 4; memcpy(buffer, µseconds, 4); buffer += 4; memcpy(buffer, &precision, 4); buffer += 4; memcpy(buffer, &hints, 1); buffer += 1; //printf("Encoding DateTime Field [%d] = %d.%d (%d:%d)...\n", 13, seconds, microseconds, hints, precision); return 13; }
uint32_t MamaRecordedMessageCodec::encodeF64(char*& buffer, MamaMsgField& mmf) { mama_f64_t mfv = mmf.getF64(); size_t s = sizeof(mfv); memcpy(buffer, &mfv, s); buffer += s; //printf("Encoding U16 Field [%d] = %g...\n", s, mfv); return s; }
uint32_t MamaRecordedMessageCodec::encodeBool(char*& buffer, MamaMsgField& mmf) { bool mfv = mmf.getBool(); size_t s = sizeof(mfv); memcpy(buffer, &mfv, s); buffer += s; //printf("Encoding Boolean Field [%d] = %d...\n", s, mfv); return s; }
uint32_t MamaRecordedMessageCodec::encodeChar(char*& buffer, MamaMsgField& mmf) { char mfv = mmf.getChar(); size_t s = sizeof(mfv); memcpy(buffer, &mfv, s); buffer += s; //printf("Encoding Char Field [%d] = %c...\n", s, mfv); return s; }
void onUpdate (MamdaQuoteToBookListenerImpl& impl, const MamaMsgField& field) { mama_quantity_t askSize = field.getF64() * impl.mQuoteSizeMultiplier; if (impl.mQuoteCache.mAskSize != askSize) { impl.mQuoteCache.mAskSize = askSize; impl.mQuoteCache.mGotAskSize = true; } }
uint32_t MamaRecordedMessageCodec::encodeString(char*& buffer, MamaMsgField& mmf) { const char* mfv = mmf.getString(); mama_u16_t s = (mama_u16_t)strlen(mfv); // Add the size to the buffer as this is a non-fixed width field type memcpy(buffer, &s, 2); buffer += 2; memcpy(buffer, mfv, s); buffer += s; //printf("Encoding String Field[%d] = %s...\n", s, mfv); return (s+2); }
void onUpdate (MamdaQuoteToBookListenerImpl& impl, const MamaMsgField& field) { MamaPrice bidPrice; field.getPrice(bidPrice); if (impl.mQuoteCache.mBidPrice != bidPrice) { impl.mQuoteCache.mBidPrice = bidPrice; impl.mQuoteCache.mGotBidPrice = true; } }
void onUpdate (MamdaQuoteToBookListenerImpl& impl, const MamaMsgField& field) { MamaPrice askPrice; field.getPrice (askPrice); if (impl.mQuoteCache.mAskPrice != askPrice) { impl.mQuoteCache.mAskPrice = askPrice; impl.mQuoteCache.mGotAskPrice = true; } }
void onUpdate (MamdaQuoteToBookListenerImpl& impl, const MamaMsgField& field) { if (impl.mFullBook && impl.mFullBook->getSymbol()[0]=='\0') { const char* result = NULL; result = field.getString(); if (result) { impl.mFullBook->setSymbol (result); } } }
void MamdaQuoteToBookListenerImpl::onField (const MamaMsg& msg, const MamaMsgField& field, void* closure) { uint16_t fid = field.getFid(); if (fid <= mFieldUpdatersSize) { QuoteToBookFieldUpdate* updater = mFieldUpdaters[fid]; if (updater) { updater->onUpdate (*this, field); } } }
void MamdaFundamentalListener::MamdaFundamentalListenerImpl::onField ( const MamaMsg& msg, const MamaMsgField& field, void* closure) { uint16_t fid = field.getFid(); if (fid <= mFieldUpdatersSize) { FundamentalFieldUpdate* updater = mFieldUpdaters[fid]; if (updater) { updater->onUpdate (*this, field); } } }
uint32_t MamaRecordedMessageCodec::encodePrice(char*& buffer, MamaMsgField& mmf) { // Creates format of [8 bytes value|4 bytes mamaPricePrecision|1 byte mamaPriceHints] mmf.getPrice(*mTempMamaPrice); double v = mTempMamaPrice->getValue(); mamaPricePrecision mpp = mTempMamaPrice->getPrecision(); mamaPriceHints mph = mTempMamaPrice->getHints(); printf("value: %d, value: %d, value: %d\n", sizeof(v), sizeof(mpp), sizeof(mph)); size_t s = sizeof(v) + sizeof(mpp) + sizeof(mph); memcpy(buffer, &v, sizeof(v)); memcpy(buffer, &mpp, sizeof(mpp)); memcpy(buffer, &mph, sizeof(mph)); buffer += s; //printf("Encoding MamaPrice Field [%d] = %g...\n", s, v); return s; }
void onUpdate (MamdaFundamentalListener::MamdaFundamentalListenerImpl& impl, const MamaMsgField& field) { impl.mDivCurrency = field.getString(); impl.mDivCurrencyFieldState = MODIFIED; }
void onUpdate (MamdaFundamentalListener::MamdaFundamentalListenerImpl& impl, const MamaMsgField& field) { impl.mSharesFloat = field.getU64(); impl.mSharesFloatFieldState = MODIFIED; }
uint32_t MamaRecordedMessageCodec::encodeField(char*& buffer, MamaMsgField& mmf) { uint32_t r = 0; mamaFieldType mft = mmf.getType(); // These modifications will be applied regardless of data type mama_fid_t mff = mmf.getFid(); memcpy(buffer, &mff, 2); buffer += 2; memcpy(buffer, &mft, 4); buffer += 4; r += 6; switch(mft) { case MAMA_FIELD_TYPE_BOOL: r += encodeBool(buffer, mmf); break; case MAMA_FIELD_TYPE_CHAR: r += encodeChar(buffer, mmf); break; case MAMA_FIELD_TYPE_I8: r += encodeI8(buffer, mmf); break; case MAMA_FIELD_TYPE_U8: r += encodeU8(buffer, mmf); break; case MAMA_FIELD_TYPE_I16: r += encodeI16(buffer, mmf); break; case MAMA_FIELD_TYPE_U16: r += encodeU16(buffer, mmf); break; case MAMA_FIELD_TYPE_I32: r += encodeI32(buffer, mmf); break; case MAMA_FIELD_TYPE_U32: r += encodeU32(buffer, mmf); break; case MAMA_FIELD_TYPE_I64: r += encodeI64(buffer, mmf); break; case MAMA_FIELD_TYPE_U64: r += encodeU64(buffer, mmf); break; case MAMA_FIELD_TYPE_F32: r += encodeF32(buffer, mmf); break; case MAMA_FIELD_TYPE_F64: r += encodeF64(buffer, mmf); break; case MAMA_FIELD_TYPE_TIME: r += encodeTime(buffer, mmf); break; case MAMA_FIELD_TYPE_PRICE: r += encodePrice(buffer, mmf); break; case MAMA_FIELD_TYPE_STRING: r += encodeString(buffer, mmf); break; case MAMA_FIELD_TYPE_VECTOR_STRING: r += encodeVectorString(buffer, mmf); break; case MAMA_FIELD_TYPE_VECTOR_I32: r += encodeVectorI32(buffer, mmf); break; case MAMA_FIELD_TYPE_VECTOR_F64: r += encodeVectorF64(buffer, mmf); break; case MAMA_FIELD_TYPE_MSG: r += encodeMsgField(buffer, mmf); break; case MAMA_FIELD_TYPE_VECTOR_MSG: r += encodeVectorMsg(buffer, mmf); break; default: break; } return r; }
void onUpdate (MamdaQuoteToBookListenerImpl& impl, const MamaMsgField& field) { impl.mQuoteCache.mQuoteQualStr = field.getString(); }
void onUpdate (MamdaFundamentalListener::MamdaFundamentalListenerImpl& impl, const MamaMsgField& field) { impl.mDividendPrice = field.getF64(); impl.mDividendPriceFieldState = MODIFIED; }
void onUpdate (MamdaFundamentalListener::MamdaFundamentalListenerImpl& impl, const MamaMsgField& field) { impl.mHistVolatility = field.getF64(); impl.mHistVolatilityFieldState = MODIFIED; }
void onUpdate (MamdaQuoteToBookListenerImpl& impl, const MamaMsgField& field) { impl.mQuoteCache.mTmpQuoteCount = field.getU32(); }
void onUpdate (MamdaFundamentalListener::MamdaFundamentalListenerImpl& impl, const MamaMsgField& field) { impl.mRiskFreeRate = field.getF64(); impl.mRiskFreeRateFieldState = MODIFIED; }
void onUpdate (MamdaFundamentalListener::MamdaFundamentalListenerImpl& impl, const MamaMsgField& field) { field.getDateTime (impl.mLineTime); impl.mLineTimeFieldState = MODIFIED; }
void onUpdate (MamdaFundamentalListener::MamdaFundamentalListenerImpl& impl, const MamaMsgField& field) { impl.mMrktSectNative = field.getString(); impl.mMrktSectNativeFieldState = MODIFIED; }
void onUpdate (MamdaQuoteToBookListenerImpl& impl, const MamaMsgField& field) { field.getDateTime(impl.mQuoteCache.mBidTime); }
void onUpdate (MamdaFundamentalListener::MamdaFundamentalListenerImpl& impl, const MamaMsgField& field) { impl.mCorpActType = field.getString(); impl.mCorpActTypeFieldState = MODIFIED; }