In contrast to flat model (FIX Message) object model allows addressing messages and fields by names. Although this interface is slower than the flat model, it may appear friendlier for Intellisense - the development-time on-line help.
Create
There is a dedicated namespace for each FIX protocol version. There is a dedicated class for each message type. To create "new order single" message using object model, simply create an instance of the corresponding class.
#include "B2BITS_Exception.h"
#include "B2BITS_FixEngine.h"
#include "b2bits/FixMessages/FIX44/Enums.h"
#include "b2bits/FixMessages/FIX44/AllMessages.h"
#include "b2bits/FixMessages/FIX44/Tags.h"
#include "b2bits/FixMessages/LocalMktDateType.h"
#include "b2bits/FixMessages/UTCTimestampType.h"
b2bits::FixMessages::FIX42::NewOrderSingleMessage order42;
b2bits::FixMessages::FIX44::IndicationOfInterestMessage ioi44;
Access fields
Fields can be accessed by names.
b2bits::FixMessages::FIX42::ExecutionReportMessage exec;
exec.OrderID().set("2247");
exec.ExecType().set(ExecType::Fill);
exec.OrdStatus().set(OrdStatus::Filled);
exec.LeavesQty().set(0);
exec.TransactTime().set(UTCTimestampType::now());
exec.OrderID().remove();
Repeating groups
Repeating groups can be accessed by the name of the leading tag. Repeating group is treated as array, means that entries are accessed via indices.
AllocationInstructionMessage alloc;
AllocationInstructionMessage::OrdersGroup ordReportGrp = alloc.Orders();
ordReportGrp.resize(1);
ordReportGrp[0].ClOrdID().set("1789");
AllocationInstructionMessage::AllocsGroup allocInstrGrp = alloc.Allocs();
allocInstrGrp.resize(2);
allocInstrGrp[0].AllocAccount().set("Account1");
allocInstrGrp[0].AllocQty().set(4);
allocInstrGrp[1].AllocAccount().set("Account2");
allocInstrGrp[1].AllocQty().set(6);
alloc.Orders().remove();
Release
No specific actions are required to release resources.
Combine flat and object model
b2bits::FixMessages::FIX42::NewOrderSingleMessage order42(pOrder);
Basic FIX message.
Definition B2BITS_FIXMessage.h:82
static FIXMsgFactory * singleton()
Returns the instance of the class.
virtual FIXMessage * newSkel(FIXVersion ver, const char *msgType, FIXVersion ssnver=NA) const =0
Creates the new skeleton of the application message and returns it.
virtual const std::string * get(int tag) const =0
Retrieves field value by tag number.
Send object message
Object message can be send the same way as flat message
b2bits::FixMessages::FIX42::NewOrderSingleMessage order42(pOrder);
FIX Session.
Definition B2BITS_Session.h:171
virtual void put(FIXMessage *pMsg, PutMessageOptions const *options=NULL)=0
Sends the given message to the remote FIX engine.