B2BITS FIX Antenna C++ 2.32.0
Loading...
Searching...
No Matches
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.
 
char * getMsgSeqNum (size_t *size) throw ()
 Returns pointer to buffer of the MsgSeqNum field.
 
bool isLastMsgSeqNumProcessedReserved () const throw ()
 Returns true, if LastMsgSeqNumProcessed is initalized.
 
bool isSendingTimeReserved () const throw ()
 Returns true, if SendingTime is initalized.
 
 PreparedMessage () throw ()
 
char const * rawMsg () const throw ()
 Returns pointer to the RAW FIX message.
 
std::size_t rawMsgSize () const throw ()
 Returns size of the RAW FIX message.
 
void setCheckSum (char const *value) throw ()
 Updates CheckSum value.
 
void setLastMsgSeqNumProcessed (int value) throw ()
 Updates LastMsgSeqNumProcessed value.
 
int setMsgSeqNum (int value) throw ()
 Updates MsgSeqNum value.
 
void setSendingTime (char const *value, std::size_t size) throw ()
 Updates SendingTime value.
 
void setSendingTime (const TZTimeHelper::UTCTimestamp &value) throw ()
 Updates SendingTime value.
 
void setSendingTime (UTCTimestamp value) throw ()
 Updates SendingTime value.
 
size_t sizeSendingTimeReserved () const throw ()
 Returns size reserved for SendingTime.
 
void updateCheckSum () throw ()
 Recalculates checksum.
 
virtual ~PreparedMessage () throw ()
 Polymorphous destructor.
 

Protected Member Functions

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

Static Protected Member Functions

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

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 );
}
Encapsulates float type.
Definition B2BITS_Decimal.h:64
Basic FIX message.
Definition B2BITS_FIXMessage.h:81
virtual FIXMessage * parse(char const *rawMessage, std::size_t rawMessageSize, SecurityAttributes *pSA=NULL, bool verifyBodyLength=false, bool verifyCheckSum=false, ProtocolIndex preferredVersion=NA, unsigned char tagsDelimiter='\x01') const =0
Parses the input std::string and creates corresponding structured message.
static FIXMsgProcessor * singleton()
Returns the instance of the class.
Provides minimal functionality to work with prepared fields.
Definition B2BITS_PreparedMessage.h:592
FIX Session.
Definition B2BITS_Session.h:171
virtual void reserve(int tag, PreparedFieldIndex index, std::size_t size)=0
Reserves memory to store prepared field value.
static const unsigned int ValueSizeWithMilliseconds
Maximum buffer size required to store value.
Definition B2BITS_UTCTimestamp.h:71
static UTCTimestamp now(bool withMilliseconds=false)
Returns UTCTimestamp with current time.
static const int SendingTime
Definition B2BITS_FIXFields.h:106
static const int TransactTime
Definition B2BITS_FIXFields.h:114
static const int ClOrdID
Definition B2BITS_FIXFields.h:66
static const int Price
Definition B2BITS_FIXFields.h:99
static const int OrderQty
Definition B2BITS_FIXFields.h:93
Options to Session::put method.
Definition B2BITS_Session.h:90
bool overrideSendingTime_
Specifies either Session should override SendingTime field of the passed FIXMessage or not.
Definition B2BITS_Session.h:116

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()

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

◆ ~PreparedMessage()

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

Polymorphous destructor.

Member Function Documentation

◆ getChecked()

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 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,
bool value )
throw ( )
inlinestaticprotected

Copies passed value to the message.

◆ set() [2/10]

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

◆ set() [3/10]

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

Copies passed value to the message.

◆ set() [4/10]

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

◆ set() [5/10]

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

Copies passed value to the message.

◆ set() [6/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() [7/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() [8/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() [9/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() [10/10]

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

◆ 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 ( const TZTimeHelper::UTCTimestamp & value)
throw ( )
inline

Updates SendingTime value.

References set().

◆ setSendingTime() [3/3]

void Engine::PreparedMessage::setSendingTime ( 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 Engine::PreparedMessage::updateCheckSum ( )
throw ( )

Recalculates checksum.

Friends And Related Symbol Documentation

◆ FIXMessage

friend class FIXMessage
friend