B2BITS FIX Antenna C++  2.27.0
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
Engine::PreparedMessage Class Reference

Alternative for FIXMessage class. More...

#include <B2BITS_PreparedMessage.h>

+ Inheritance diagram for Engine::PreparedMessage:

Classes

struct  Field
 Prepared message field. More...
 

Public Types

enum  {
  First = 1000, MsgSeqNum = First, CheckSum, SendingTime,
  LastMsgSeqNumProcessed, Last
}
 Enumerates indexes for fields. More...
 

Public Member Functions

char * getCheckSum (size_t *size) throw ()
 Returns pointer to buffer of the CheckSum field. More...
 
char * getMsgSeqNum (size_t *size) throw ()
 Returns pointer to buffer of the MsgSeqNum field. More...
 
bool isLastMsgSeqNumProcessedReserved () const throw ()
 Returns true, if LastMsgSeqNumProcessed is initalized. More...
 
bool isSendingTimeReserved () const throw ()
 Returns true, if SendingTime is initalized. More...
 
V12_API PreparedMessage () throw ()
 
char const * rawMsg () const throw ()
 Returns pointer to the RAW FIX message. More...
 
std::size_t rawMsgSize () const throw ()
 Returns size of the RAW FIX message. More...
 
void setCheckSum (char const *value) throw ()
 Updates CheckSum value. More...
 
void setLastMsgSeqNumProcessed (int value) throw ()
 Updates LastMsgSeqNumProcessed value. More...
 
int setMsgSeqNum (int value) throw ()
 Updates MsgSeqNum value. More...
 
void setSendingTime (char const *value, std::size_t size) throw ()
 Updates SendingTime value. More...
 
void setSendingTime (UTCTimestamp value) throw ()
 Updates SendingTime value. More...
 
void setSendingTime (const TZTimeHelper::UTCTimestamp &value) throw ()
 Updates SendingTime value. More...
 
size_t sizeSendingTimeReserved () const throw ()
 Returns size reserved for SendingTime. More...
 
void V12_API updateCheckSum () throw ()
 Recalculates checksum. More...
 
virtual V12_API ~PreparedMessage () throw ()
 Polymorphous destructor. More...
 

Protected Member Functions

V12_API char * getChecked (PreparedFieldIndex index, std::size_t *size)
 Returns pointer to the buffer where field value is stored. More...
 
virtual void V12_API initField (PreparedFieldIndex index, char *start, std::size_t size)
 Initialize PreparedField. More...
 
void setBuffer (char *buf, char const *msgStart, std::size_t msgSize) throw ()
 Acquires passed buffer and its size. More...
 
void setMsgSize (std::size_t msgSize) throw ()
 Updates size of the RAW FIX message. More...
 
void setMsgStart (char const *msgStart) throw ()
 Updates pointer to the RAW FIX message. More...
 

Static Protected Member Functions

static void set (Field const &field, char const *value, std::size_t size) throw ()
 Copies passed value to the message. More...
 
static void set (Field const &field, char value) throw ()
 Copies passed value to the message. More...
 
static void set (Field const &field, bool value) throw ()
 Copies passed value to the message. More...
 
static void set (Field const &field, UTCTimestamp value) throw ()
 Copies passed value to the message. More...
 
static void set (Field const &field, const TZTimeHelper::UTCTimestamp &value) throw ()
 Copies passed value to the message. More...
 
static bool set (Field const &field, System::u32 value) throw ()
 Copies passed value to the message. More...
 
static bool set (Field const &field, System::u64 value) throw ()
 Copies passed value to the message. More...
 
static bool set (Field const &field, System::i32 value) throw ()
 Copies passed value to the message. More...
 
static bool set (Field const &field, System::i64 value) throw ()
 Copies passed value to the message. More...
 
static void set (Field const &field, Decimal const &value) throw ()
 Copies passed value to the message. More...
 

Friends

class FIXMessage
 

Detailed Description

Alternative for FIXMessage class.

Improves latency of the Session::put method if user sends same message many times and size of the volatile fields do not change. Volatile fields are fields which user changes between Session::put calls (e.g. OrderQty, Price, TransactTime, etc).

Sample of usage:

Engine::Session* initiator;
// ... create session
// Replace this string with correct raw FIX message
std::string const RAW_MSG = "8= ... NEW ORDER SINGLE RAW FIX MESSAGE HERE... ";
// Create New Order Single FIXMessage skeleton from raw fix message
//
// Reserve space for volatile fields.
//
msg->reserve( FIXFields::ClOrdID, 0, 10 ); // Assign index 0 for ClOrdID
msg->reserve( FIXFields::Price, 1, 7 ); // Assign index 1 for Price
msg->reserve( FIXFields::OrderQty, 2, 2 ); // Assign index 2 for OrderQty, etc.
//
// Reserve space for Session Level Fields like SenderCompID, TargetCompID, etc.
//
size_t const MsgSeqNumFieldSize = 7; // 7 digits for MsgSeqNum. Max value would be 9,999,999
putOptions.overrideSendingTime_ = false;
initiator_->inflate( msg, MsgSeqNumFieldSize, &putOptions );
// Create Prepared Message
Engine::GenericPreparedMessage preparedMessage( msg );
//
// Main sending loop
//
size_t sz;
size_t const TEST_COUNT = 1000000;
for( size_t i = 0; i < TEST_COUNT; ++i ) {
//
// Update volatile fields which were reserved later
//
preparedMessage.set( 0, static_cast<int>( i ) ); // ClOrdID
preparedMessage.set( 1, Engine::Decimal( 100023, -2 ) ); // Price
preparedMessage.set( 2, 10 ); // OrderQty
preparedMessage.set( 3, Engine::UTCTimestamp::now() ); // TransactTime
preparedMessage.set( 4, preparedMessage.get( 3, &sz ), Engine::UTCTimestamp::ValueSizeWithMilliseconds ); // TransactTime
// Put message to session
initiator_->put( &preparedMessage );
}

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Enumerates indexes for fields.

Enumerator
First 

First field index.

MsgSeqNum 

MsgSeqNum field.

CheckSum 

CheckSum field.

SendingTime 

SendingTime field.

LastMsgSeqNumProcessed 

LastMsgSeqNumProcessed field.

Last 

Last field index + 1.

Constructor & Destructor Documentation

◆ PreparedMessage()

V12_API Engine::PreparedMessage::PreparedMessage ( )
throw (
)

◆ ~PreparedMessage()

virtual V12_API Engine::PreparedMessage::~PreparedMessage ( )
throw (
)
virtual

Polymorphous destructor.

Member Function Documentation

◆ getChecked()

V12_API char* Engine::PreparedMessage::getChecked ( PreparedFieldIndex  index,
std::size_t *  size 
)
protected

Returns pointer to the buffer where field value is stored.

Parameters
[in]indexIndex of the field
[out]sizeSize of the field value
Exceptions
Utils::Exceptionif index is out of range

◆ getCheckSum()

char * Engine::PreparedMessage::getCheckSum ( size_t *  size)
throw (
)
inline

Returns pointer to buffer of the CheckSum field.

◆ getMsgSeqNum()

char * Engine::PreparedMessage::getMsgSeqNum ( size_t *  size)
throw (
)
inline

Returns pointer to buffer of the MsgSeqNum field.

◆ initField()

virtual void V12_API Engine::PreparedMessage::initField ( PreparedFieldIndex  index,
char *  start,
std::size_t  size 
)
protectedvirtual

Initialize PreparedField.

Used by FA in the FIXMessage::prepare.

◆ isLastMsgSeqNumProcessedReserved()

bool Engine::PreparedMessage::isLastMsgSeqNumProcessedReserved ( ) const
throw (
)
inline

Returns true, if LastMsgSeqNumProcessed is initalized.

References First, LastMsgSeqNumProcessed, and Engine::PreparedMessage::Field::size_.

◆ isSendingTimeReserved()

bool Engine::PreparedMessage::isSendingTimeReserved ( ) const
throw (
)
inline

Returns true, if SendingTime is initalized.

References First, SendingTime, and Engine::PreparedMessage::Field::size_.

◆ rawMsg()

char const * Engine::PreparedMessage::rawMsg ( ) const
throw (
)
inline

Returns pointer to the RAW FIX message.

◆ rawMsgSize()

std::size_t Engine::PreparedMessage::rawMsgSize ( ) const
throw (
)
inline

Returns size of the RAW FIX message.

◆ set() [1/10]

void Engine::PreparedMessage::set ( Field const &  field,
char const *  value,
std::size_t  size 
)
throw (
)
inlinestaticprotected

◆ set() [2/10]

void Engine::PreparedMessage::set ( Field const &  field,
char  value 
)
throw (
)
inlinestaticprotected

Copies passed value to the message.

◆ set() [3/10]

void Engine::PreparedMessage::set ( Field const &  field,
bool  value 
)
throw (
)
inlinestaticprotected

Copies passed value to the message.

◆ set() [4/10]

void Engine::PreparedMessage::set ( Field const &  field,
UTCTimestamp  value 
)
throw (
)
inlinestaticprotected

◆ set() [5/10]

void Engine::PreparedMessage::set ( Field const &  field,
const TZTimeHelper::UTCTimestamp value 
)
throw (
)
inlinestaticprotected

◆ set() [6/10]

bool Engine::PreparedMessage::set ( Field const &  field,
System::u32  value 
)
throw (
)
inlinestaticprotected

Copies passed value to the message.

Returns
true if value was written completely.

◆ set() [7/10]

bool Engine::PreparedMessage::set ( Field const &  field,
System::u64  value 
)
throw (
)
inlinestaticprotected

Copies passed value to the message.

Returns
true if value was written completely.

◆ set() [8/10]

bool Engine::PreparedMessage::set ( Field const &  field,
System::i32  value 
)
throw (
)
inlinestaticprotected

Copies passed value to the message.

Returns
true if value was written completely.

◆ set() [9/10]

bool Engine::PreparedMessage::set ( Field const &  field,
System::i64  value 
)
throw (
)
inlinestaticprotected

Copies passed value to the message.

Returns
true if value was written completely.

◆ set() [10/10]

void Engine::PreparedMessage::set ( Field const &  field,
Decimal const &  value 
)
throw (
)
inlinestaticprotected

Copies passed value to the message.

◆ setBuffer()

void Engine::PreparedMessage::setBuffer ( char *  buf,
char const *  msgStart,
std::size_t  msgSize 
)
throw (
)
inlineprotected

Acquires passed buffer and its size.

Used by FA in the FIXMessage::prepare

◆ setCheckSum()

void Engine::PreparedMessage::setCheckSum ( char const *  value)
throw (
)
inline

Updates CheckSum value.

Parameters
valueBuffer of three bytes

References set().

◆ setLastMsgSeqNumProcessed()

void Engine::PreparedMessage::setLastMsgSeqNumProcessed ( int  value)
throw (
)
inline

Updates LastMsgSeqNumProcessed value.

References set().

◆ setMsgSeqNum()

int Engine::PreparedMessage::setMsgSeqNum ( int  value)
throw (
)
inline

Updates MsgSeqNum value.

Returns
0 if value was written successfully.

References set().

◆ setMsgSize()

void Engine::PreparedMessage::setMsgSize ( std::size_t  msgSize)
throw (
)
inlineprotected

Updates size of the RAW FIX message.

◆ setMsgStart()

void Engine::PreparedMessage::setMsgStart ( char const *  msgStart)
throw (
)
inlineprotected

Updates pointer to the RAW FIX message.

◆ setSendingTime() [1/3]

void Engine::PreparedMessage::setSendingTime ( char const *  value,
std::size_t  size 
)
throw (
)
inline

Updates SendingTime value.

References set().

◆ setSendingTime() [2/3]

void Engine::PreparedMessage::setSendingTime ( UTCTimestamp  value)
throw (
)
inline

Updates SendingTime value.

References set().

◆ setSendingTime() [3/3]

void Engine::PreparedMessage::setSendingTime ( const TZTimeHelper::UTCTimestamp value)
throw (
)
inline

Updates SendingTime value.

References set().

◆ sizeSendingTimeReserved()

size_t Engine::PreparedMessage::sizeSendingTimeReserved ( ) const
throw (
)
inline

Returns size reserved for SendingTime.

References First, SendingTime, and Engine::PreparedMessage::Field::size_.

◆ updateCheckSum()

void V12_API Engine::PreparedMessage::updateCheckSum ( )
throw (
)

Recalculates checksum.

Friends And Related Function Documentation

◆ FIXMessage

friend class FIXMessage
friend