Re: [Quickfix-users] MessageCracker
Brought to you by:
orenmnero
From: Dale W. <wil...@oc...> - 2006-03-23 14:41:27
|
Charles Sicotte wrote: > > If I want my application to handle multiple version of FIX (like 4.1 > and 4.2). > If I implement a MessageCracker, do I have to override, the > ExecutionReport for example, of each version of FIX? As Oren already said, yes. > What would be the best way to handle multiple version? The approach I took involves templated member functions. A typical declaration looks like: template<typename MESSAGE> void onExecutionReport( const MESSAGE & message, const FIX::SessionID & sessionID); The virtual methods to be called from the MessageCracker look like: void Exchange::onMessage( const FIX42::ExecutionReport & message, const FIX::SessionID & sessionID) { this->onExecutionReport(message, sessionID); } void Exchange::onMessage( const FIX43::ExecutionReport & message, const FIX::SessionID & sessionID) { this->onExecutionReport(message, sessionID); } etc. Note the this-> is there to help avoid a nasty template/name resolution problem in C++. Some of the templated methods are messier. For example template<typename MESSAGE, typename GROUP> void onMarketDataSnapshotFullRefresh( const MESSAGE & message, const FIX::SessionID &); Which has to be called like so: void Exchange::onMessage( const FIX42::MarketDataSnapshotFullRefresh & message, const FIX::SessionID &sessionID) { this->onMarketDataSnapshotFullRefresh <FIX42::MarketDataSnapshotFullRefresh, FIX42::MarketDataSnapshotFullRefresh::NoMDEntries> (message, sessionID); } But once you get past the template tricks, you can write common code to handle all the protocols (to the extent that they are similar, anyway.) Note: If you're using VC6 or older versions of gcc, do not try this -- it's painful on old compilers. HTH, Dale |