ProgrammersGuide.h

Go to the documentation of this file.
00001 /*! \mainpage FIXForge C++ FIX Engine - Programmer's Guide
00002 
00003 \section Content Content
00004 
00005 <ul>
00006       <li>\ref Introduction </li>
00007       <li>\ref SystemRequirements</li>
00008 <li>\ref GettingStarted
00009         <ul>
00010               <li>\ref Error-reporting</li>
00011               <li>\ref Engine</li>
00012               <li>\ref Version</li>
00013                 <li>\ref Message
00014                     <ul>
00015                     <li>\ref Fields</li>
00016                     </ul>
00017                 </li>
00018                 <li>\ref Session    
00019                 <ul>
00020                   <li>\ref MessageExchange</li> 
00021                   <li>\ref SequenceNumbers</li>
00022                 </ul>
00023                 </li> 
00024         </ul>
00025 </li>
00026 <li>\ref Administration 
00027         <ul>
00028             <li>\ref LicenseFile</li>
00029             <li>\ref PersistentMessagesStorage</li>
00030           <li>\ref Settings</li> 
00031         </ul>
00032 </li>
00033 <li>\ref Advanced
00034     <ul>
00035       <li>\ref RepeatingGroup</li> 
00036       <li>\ref SessionStates</li> 
00037       <li>\ref SessionEvents</li> 
00038       <li>\ref CustomLogonMessage</li> 
00039       <li>\ref Dialects</li> 
00040       <li>\ref ResendRequestProcessing</li>
00041       <li>\ref AcceptingFixSessionWithoutCreationSessionObject</li>
00042     </ul>
00043 </li> 
00044 <li>\ref SslEncryption</li>
00045 <li>\ref FAST</li>
00046 <li>\ref FrequentlyAskedQuestions</li> 
00047 <li>\ref Glossary</li> 
00048 <li>\ref Resources</li> 
00049 </ul>
00050 
00051 \section Introduction Introduction
00052 
00053 <a href="http://www.onixs.biz/">Onix Solutions</a> FIXForge C++ FIX Engine is a C++ library that will FIX-enable applications written in C++.
00054 The FIX Engine provides the following services:
00055  <ul> 
00056     <li>manages a network connection</li> 
00057     <li>manages the session layer (for the delivery of application messages)</li> 
00058     <li>manages the application layer (defines business related data content)</li> 
00059     <li>creates (outgoing) messages</li> 
00060     <li>parses (incoming) messages</li> 
00061     <li>validates messages</li> 
00062     <li>persists messages (the ability to log data to a flat file)</li> 
00063     <li>session recovery in accordance with the FIX state model</li> 
00064   </ul> 
00065 \subsection SystemRequirements System Requirements
00066 
00067  \subsubsection DevelopmentEnvironment Development environment:
00068   <ul> 
00069     <li>Microsoft Visual Studio .NET 2003</li> 
00070     <li>Microsoft Visual Studio .NET 2005</li>
00071     <li>Microsoft Visual Studio .NET 2008</li>
00072     <li>Linux Kernel 2.6, gcc</li>
00073     <li>Sun Solaris, Sun Studio 12</li>
00074   </ul> 
00075   \subsubsection DeploymentEnvironment Deployment environment:
00076   <ul> 
00077     <li>Microsoft Windows NT 4.0 (Service Pack 6 recommended), Windows 2000, Windows XP, Windows Server 2003, Windows Vista.</li> 
00078     <li>Linux Kernel 2.6</li>
00079     <li>Sun Solaris</li>
00080   </ul> 
00081 
00082  \section GettingStarted Getting Started 
00083   All FIX Engine classes are located in the FIXForge::FIX namespace, header files are assembled in the FIXForge_FIXEngine.h header file. 
00084   The typical way of using the Engine is as follows: 
00085   <ol start=1 type=1> 
00086     <li>Initialize the \ref Engine .</li> 
00087     <li>Create the \ref Session object.</li> 
00088     <li>Establish the \ref FIX_Session "FIX session" as \ref Initiator "Initiator" or \ref Acceptor "Acceptor".</li> 
00089     <li>Send and receive application-level \ref Message "FIX messages".</li> 
00090     <li>Disconnect the session.</li> 
00091     <li>Shutdown the Engine.</li> 
00092   </ol> 
00093 
00094    \subsection Error-reporting Error-reporting 
00095 
00096   Exception handling is used as a fundamental error-reporting mechanism. In the event of any errors arising the
00097  FIXForge::FIX::EngineException is thrown.
00098  
00099 \subsubsection Engine Engine 
00100 
00101   To initialize the FIX Engine class library one of the FIXForge::FIX::Engine::init methods is used. 
00102 \warning This method must be called before all other FIX Engine library methods.
00103 
00104   The FIXForge::FIX::Engine::init(const std::string& configFile) method is used to specify the \ref Settings "configuration file". 
00105 
00106   To shutdown the Engine the FIXForge::FIX::Engine::shutdown method is used.
00107   \warning No other FIX Engine library methods must be called after this method.
00108 
00109  Example: 
00110 \code 
00111 #include <FIXForge_FIXEngine.h>
00112 
00113 using namespace FIXForge::FIX;
00114 
00115 try{
00116     Engine::init();
00117 
00118     // Session-related logic...
00119 
00120     Engine::shutdown();
00121 }catch(const EngineException& ex){
00122     clog << "Exception: " << ex.what() << endl;
00123 }
00124 \endcode
00125 
00126 \subsubsection Version FIX Version 
00127 
00128 As the FIX protocol evolves its new versions will be released to you to extend the current functionality.  
00129   Supported FIX versions are: FIX 4.0, FIX 4.1, FIX 4.2, FIX 4.3 and FIX 4.4. The FIXForge::FIX::Version enum is used to identify them. 
00130 
00131 Example: 
00132 \code
00133 Version currentFixVersion = FIX_44;
00134 \endcode
00135 
00136 Each FIX version has its own namespace that contains objects that are unique for the version, e.g.: 
00137 \code
00138 using namespace FIXForge::FIX::FIX40;
00139 \endcode
00140 
00141 \subsubsection Message Message 
00142   The general format of a FIX message is a stream of <tag=value> fields with a \ref DelimiterCharacter "field delimiter (SOH)" 
00143      between fields in the stream (so-called "tag=value FIX format"). 
00144 
00145   Below is an example of a FIX message:   
00146   \image html FIXMessage.gif
00147 
00148   It is represented with the FIXForge::FIX::Message class. 
00149 
00150   <strong>To create a message</strong> the FIXForge::FIX::Message(const std::string& type, FIXForge::FIX::Version version) constructor is used. 
00151 
00152   <strong>To parse a message</strong> in the raw (tag=value) FIX format the FIXForge::FIX::Message(const std::string& rawMessage) constructor is used. 
00153 
00154   <strong>To validate a message</strong> the FIXForge::FIX::Message::validate method is used. 
00155     This method checks for the presence of \ref RequiredFields "required fields". 
00156 
00157   There are several overloaded methods FIXForge::FIX::Message::toString() to simplify debugging and monitoring.
00158   To update the <a href="http://www.onixs.biz/fixdictionary/4.2/tagNum_9.html">BodyLength (9)</a> 
00159   and <a href="http://www.onixs.biz/fixdictionary/4.2/tagNum_10.html">CheckSum (10)</a> fields 
00160   the FIXForge::FIX::Message::updateCheckSum() method is used. 
00161 
00162   Example:
00163 \code
00164 #include <FIXForge_FIXEngine.h>
00165 
00166 using namespace FIXForge::FIX;
00167 
00168 {
00169     Message order("D", FIX_42); // New Order - Single (MsgType = D)
00170     order.updateCheckSum();
00171     clog << "Order" << order << endl;
00172 }
00173 
00174 {
00175     string rawMsg = "8=FIX.4.0\0x019=86\0x0135=D\0x0149=0\0x0156=0\0x0134=1\0x0152=99990909-17:17:17\0x0111=90001008\0x0121=1\0x0155=IBM\0x0154=1\0x0138=10\0x0140=1\0x0159=0\0x0110=191\0x01";
00176     Message order(rawMsg);
00177     order.validate();
00178 
00179     clog << order.toString() << endl;
00180     clog << order.toString(' ') << endl;
00181     clog << order.toString(Message::TAG_NAME | Message::TAG_NUMBER) << endl;
00182 }
00183 \endcode
00184 
00185 \subsubsection Fields Fields 
00186 
00187 <strong>To set a field value</strong> the FIXForge::FIX::Message::set method is used. 
00188 
00189 <strong>To get a field value</strong> the FIXForge::FIX::Message::get method is used. 
00190 
00191 Example: 
00192 \code
00193 #include <FIXForge_FIXEngine.h>
00194 
00195 using namespace FIXForge::FIX;
00196 using namespace FIXForge::FIX::FIX40;
00197 
00198 Message order("D", FIX_40); // New Order - Single
00199 
00200 order.set(11, "Unique identifier of execution message");
00201 string ClOrdID = order.get(11);
00202 \endcode
00203 
00204 <strong>To remove a field</strong> the FIXForge::FIX::Message::remove method is used. 
00205 
00206 The FIXForge::FIX::FIX42::Tags class contains the constants for the tag values. This class is defined for each FIX version namespace. 
00207     The use of these constants makes the source code more readable.  
00208 
00209 Example: 
00210 \code
00211 #include <FIXForge_FIXEngine.h>
00212 
00213 using namespace FIXForge::FIX;
00214 using namespace FIXForge::FIX::FIX40;
00215 
00216 Message order("D", FIX_40); // New Order - Single
00217 order.set(Tags::ClOrdID, "90001008");
00218 order.set(Tags::Side, "1");
00219 order.set(Tags::TimeInForce, "0");
00220 \endcode
00221 
00222 \see \ref RepeatingGroup "Repeating Group".
00223 
00224 \subsubsection Session Session 
00225 
00226 A FIX session is defined as a bi-directional stream of ordered messages between two parties within a continuous sequence number series. 
00227 It is represented by the FIXForge::FIX::Session class. 
00228 
00229 To create a session the FIXForge::FIX::Session's constructors are used. 
00230 
00231 To terminate the session the FIXForge::FIX::Session::shutdown method is used. 
00232 
00233 A session has one of two possible roles: <strong>Acceptor</strong> or <strong>Initiator</strong>. 
00234 
00235 <strong>Acceptor</strong> is the receiving party of the FIX session. It listens for the incoming connection on the pre-defined port. 
00236     The acceptor has responsibility to perform first level authentication and formally declare the connection request "accepted" through transmission of an acknowledgment <i>Logon</i> message.
00237  
00238 <strong>Initiator</strong> establishes the telecommunications link and initiates the session via transmission of the initial 
00239 <a href="http://onixs.biz/fixdictionary/4.3/msgType_A_65.html">Logon</a> message. 
00240 
00241 To obtain the current role the FIXForge::FIX::Session::getRole method is used. 
00242 
00243 To establish the session as Acceptor the FIXForge::FIX::Session::logonAsAcceptor method is used. 
00244 
00245 To establish the session as Initiator the FIXForge::FIX::Session::logonAsInitiator method is used. 
00246 
00247 To disconnect the session the FIXForge::FIX::Session::logout method is used. 
00248 
00249 Example: 
00250 \code
00251 #include <FIXForge_FIXEngine.h>
00252 
00253 using namespace FIXForge::FIX; 
00254 using namespace FIXForge::FIX::FIX40;
00255 
00256 const string SENDER_COMP_ID = "SenderCompID";
00257 const string TARGET_COMP_ID = "TargetCompID";
00258 const Version VERSION = FIX_40;
00259 const string HOST = "Localhost";
00260 int ACCEPTOR_PORT = Engine::instance()->getListenPort();
00261 
00262 ISessionListener listener;
00263 
00264 Session acceptor(SENDER_COMP_ID, TARGET_COMP_ID, VERSION, &listener);
00265 Session initiator(TARGET_COMP_ID, SENDER_COMP_ID, VERSION, &listener);
00266 
00267 acceptor.logonAsAcceptor(); 
00268 initiator.logonAsInitiator(HOST, ACCEPTOR_PORT); // Sends the Logon message and waits for the acknowledgment Logon
00269 
00270 // Message exchange and processing ...
00271 
00272 acceptor.logout(); // Sends the Logout message and waits for the confirming Logout
00273 initiator.logout();
00274 
00275 acceptor.shutdown(); // Free resources
00276 initiator.shutdown(); // Free resources
00277 \endcode
00278 
00279 \see \ref SessionStates, \ref CustomLogonMessage, \ref SequenceNumbers. 
00280 
00281 \subsubsection MessageExchange Message Exchange 
00282 
00283 To send a message to counterparty the FIXForge::FIX::Session::send method is used. 
00284   As soon as a session is created it is possible to start sending messages via the session. 
00285    If the session is not established, the messages will be sent when the connection is established with the counterparty. 
00286 
00287 To receive incoming application-level messages it is necessary to override the 
00288 FIXForge::FIX::ISessionListener::onInboundApplicationMsg method. 
00289 
00290 Example: 
00291 \code
00292 #include <FIXForge_FIXEngine.h>
00293 
00294 using namespace FIXForge::FIX;
00295 using namespace FIXForge::FIX::FIX42;
00296 
00297 class SessionListener : public ISessionListener{
00298     public:
00299     
00300     virtual void onInboundApplicationMsg(const Message& msg, Session* sn){
00301         clog << "Incoming application-level message: " << msg << endl;
00302         // processing of the application-level incoming message...
00303     }
00304 };
00305 
00306 const string SENDER_COMP_ID = "AcceptorAndInitiator_SND";
00307 const string TARGET_COMP_ID = "AcceptorAndInitiator_TRG";
00308 
00309 const Version VERSION = FIX_42;
00310 
00311 const string ACCEPTOR_HOST = "localhost";
00312 int ACCEPTOR_PORT = Engine::instance()->getListenPort();
00313 
00314 SessionListener listener;
00315 
00316 Session acceptor(SENDER_COMP_ID, TARGET_COMP_ID, VERSION, &listener);
00317 acceptor.logonAsAcceptor();
00318 
00319 Session initiator(TARGET_COMP_ID, SENDER_COMP_ID, VERSION, &listener);
00320 initiator.logonAsInitiator(ACCEPTOR_HOST, ACCEPTOR_PORT);
00321 
00322 Message order("D", VERSION); 
00323 
00324 order.set(Tags::ClOrdID, "Unique identifier for Order as assigned by the buy-side");
00325 order.set(Tags::HandlInst, "1");
00326 order.set(Tags::Symbol, "Ticker symbol");
00327 order.set(Tags::Side, "1");
00328 order.set(Tags::TransactTime, "20051012-22:10:11");
00329 order.set(Tags::OrdType, "1");
00330 
00331 order.validate();
00332 
00333 acceptor.send(&order);
00334 
00335 // continue the message exchange...
00336 
00337 acceptor.logout();
00338 initiator.logout();
00339 
00340 acceptor.shutdown(); 
00341 initiator.shutdown();
00342 \endcode
00343 
00344 \subsubsection SequenceNumbers Sequence Numbers 
00345 
00346 All FIX messages are identified by a unique sequence number (the FIXForge::FIX::Message::getSeqNum() method).  
00347 
00348   Sequence numbers are initialized at the start of each \ref FIX_Session "FIX Session" starting at 1 (one) and increment throughout the session.
00349 Each session establishes an independent incoming and outgoing sequence series. 
00350   A single FIX session can exist across multiple sequential (not concurrent) physical connections. 
00351 Parties can connect and disconnect multiple times while maintaining a single FIX session.
00352 
00353 In other words, FIX Session is comprised of one or more \ref FIX_Connection "FIX Connections". 
00354 
00355   Resetting the inbound and outbound sequence numbers back to 1, for whatever reason, constitutes the beginning of a new FIX session. 
00356   Monitoring sequence numbers enables parties to gracefully synchronize applications when reconnecting during a FIX session.  
00357 
00358   To get or set the expected sequence number of the next incoming message the FIXForge::FIX::Session::getInSeqNum(), 
00359   FIXForge::FIX::Session::setInSeqNum() methods are used. 
00360 
00361   To get or set the sequence number of the next outgoing message the FIXForge::FIX::Session::getOutSeqNum(), FIXForge::FIX::Session::setOutSeqNum() methods are used. 
00362 
00363   To disconnect the FIX Connection while maintaining a single FIX Session the FIXForge::FIX::Session::logout() method is used. 
00364 
00365     It is possible to continue the session later using the FIXForge::FIX::Session::logonAsAcceptor() 
00366     or FIXForge::FIX::Session::logonAsInitiator() methods again.
00367  
00368   To terminate a FIX Session the FIXForge::FIX::Session::shutdown() method is used. 
00369    
00370   The Engine automatically synchronizes sequence numbers when reconnecting during a FIX session on the base of the information previously stored in log files.
00371 
00372   To synchronize sequence numbers manually FIXForge::FIX::Session::setInSeqNum() and FIXForge::FIX::Session::setOutSeqNum() methods 
00373   are used (<strong>before</strong> FIXForge::FIX::Session::logonAsAcceptor() or 
00374         FIXForge::FIX::Session::logonAsInitiator() method calls). 
00375 
00376         \image html SequenceNumbers.gif
00377 
00378   Some implementations of FIX protocol (\ref FIX_Dialect "FIX Dialects") expect that the \ref FIX_Session "FIX Session" coincides with 
00379     \ref FIX_Connection "FIX Connection", in other words that the sequence numbers are reset back to 1 after the Logout messages exchange.  
00380   To interact with such FIX dialects, the keepSequenceNumbersAfterLogout parameter of 
00381     FIXForge::FIX::Session's constructor should be set to <var>false</var>.
00382 
00383 In this case after FIXForge::FIX::Session::shutdown() method sequence numbers are set back to 1. Next time when the FIXForge::FIX::Session object is created incoming and outgoing sequence numbers will start from 1 (in other words, a new FIX Session will be created). 
00384 
00385 \section Administration Administration 
00386 
00387 \subsection LicenseFile License File
00388 
00389  The license file (FIXForge.Cpp.FIX.Engine.lic) is taken from the current directory. 
00390  
00391  It is possible to specify the absolute path to the license file using the \ref Settings_LicenseFile "LicenseFile" configuration setting.
00392 
00393 \subsection PersistentMessagesStorage Persistent message storage and the log files
00394 
00395   The MsgStorage folder must be created for storing log data. 
00396    Incoming and outgoingmessages, session's state data and the FIX Engine log file (FixEngineLog.txt) are stored in this folder.
00397    
00398   For each FIX session two files are created: 
00399 <ul>
00400    <li>SESSION_NAME.summary - contains both inbound and outbound FIX messages.</li>
00401   <li>SESSION_NAME.state - contains session state data.</li> 
00402 </ul>
00403   SESSION_NAME is formed on the base of \ref SenderCompID_field "SenderCompID", \ref TargetCompID_field "TargetCompID" and a timestamp. 
00404 
00405   When the FIXForge::FIX::Session object is created anew after the Engine's restart, FIX Session's state (the sequence numbers of last received and sent messages, previously sent messages, etc) is restored from these files.  
00406 
00407   To start a FIX session as a new one (so called "clean start"), it is necessary to remove the log files from the previous runs. 
00408 
00409   Connecting parties must bi-laterally agree as to when sessions are to be started/stopped and log files are backed up based upon individual system and time zone requirements.
00410 
00411   When the FIX session is finished, the log files are not needed anymore. They can be backed up and later a new FIX session with the same SenderCompID and TargetCompID will start 
00412   sequence numbers from 1. The usual practice is to backup the log files at the end of each business day (so called "End Of Day procedure") 
00413 to start the sequence numbers from 1 at the beginning of the next day. 
00414 
00415   \see 
00416   \ref Settings_Log_Directory "Log.Directory", 
00417   \ref Settings_Log_FlushFileAfterEachMessage "Log.FlushFileAfterEachMessage",
00418   \ref Settings_Log_InboundMessages "Log.InboundMessages",
00419   \ref SequenceNumbers.
00420 
00421 \subsubsection Settings Settings 
00422 
00423 The default values of FIX Engine settings can be changed using the configuration file that is given as a parameter of 
00424 FIXForge::FIX::Engine::init(const std::string& configFile) method.
00425 
00426   Example: 
00427 \code
00428 <?xml version="1.0" encoding="utf-8" ?>
00429 <configuration>
00430 
00431     <configSections>
00432         <section name="FixEngine" type="System.Configuration.NameValueSectionHandler"/>
00433     </configSections>
00434 
00435     <FixEngine>
00436         <add key="Dialect" value="LavaDialect.xml"/> 
00437         <add key="ListenPort" value="4500"/>
00438         <add key="Log.InboundMessages" value="true"/>
00439         <add key="Validate.NumberOfRepeatingGroupInstances" value="false"/> 
00440         <add key="Validate.RequiredFields" value="true"/>
00441         <add key="Resending.QueueSize" value="2500"/>
00442         <add key="Validate.UnknownFields" value="true"/>
00443         <add key="Validate.UnknownMessages" value="true"/>
00444     </FixEngine> 
00445 </configuration>
00446 \endcode
00447 
00448 <table border=1 cellspacing=0 cellpadding=0> 
00449     <caption>FIX Engine configuration settings</caption>
00450     <tr> 
00451       <th>Setting</th> 
00452       <th>Description</th> 
00453       <th>Default value</th> 
00454     </tr> 
00455 
00456     <tr> 
00457       <td>\anchor Settings_ConnectionRetries_Number ConnectionRetries.Number</td> 
00458       <td>Number of attempts to restore the telecommunication link.</td> 
00459       <td class="constant">3</td> 
00460     </tr> 
00461 
00462     <tr> 
00463       <td>\anchor Settings_ConnectionRetries_Interval ConnectionRetries.Interval</td> 
00464       <td>The time interval between the attempts to restore the telecommunication link (in seconds).</td> 
00465       <td class="constant">30</td> 
00466     </tr> 
00467 
00468     <tr> 
00469       <td>Dialect</td> 
00470       <td>Specify the path to the XML file with the description of the \ref Dialects "FIX Dialect".</td> 
00471       <td>Empty</td> 
00472     </tr>
00473 
00474     <tr> 
00475       <td>\anchor Settings_LicenseFile LicenseFile</td> 
00476       <td>Specify the path to the license file.</td> 
00477       <td>FIXForge.Cpp.FIX.Engine.lic</td> 
00478     </tr>
00479 
00480     <tr>
00481       <td>ListenPort</td>
00482       <td>FIX Engine listens on this port for incoming connections. <br>
00483         &nbsp;&nbsp;&nbsp;If '0' then only session-initiators can be created. <br>
00484       &nbsp;&nbsp;&nbsp;If '-1' then the telecommunication level is disabled and only message parsing/assembling can be used.</td>
00485       <td class="constant">0</td>
00486     </tr> 
00487     <tr> 
00488       <td>\anchor Settings_Log_Directory Log.Directory</td> 
00489       <td> Inbound and outboundmessages, session's state data and the FIX Engine log file (FixEngine.log) are stored in this directory.</td> 
00490       <td class="fileSystem">MsgStorage</td> 
00491     </tr> 
00492     <tr> 
00493       <td>\anchor Settings_Log_FlushFileAfterEachMessage Log.FlushFileAfterEachMessage</td> 
00494       <td>Option to flush output files after each logged message.</td> 
00495       <td class="constant">True</td> 
00496     </tr> 
00497     <tr> 
00498       <td>\anchor Settings_Log_InboundMessages Log.InboundMessages</td>
00499         <td>Option to log inbound messages.</td>
00500         <td class="constant">True</td> 
00501     </tr> 
00502 
00503     <tr> 
00504       <td>\anchor Settings_Log_SessionSummary Log.SessionSummary</td>
00505         <td>Option to create a summary log file with inbound and outbound messages (in *.summary file).</td>
00506         <td class="constant">True</td> 
00507     </tr> 
00508 
00509  <tr> 
00510       <td>Resending.QueueSize</td> 
00511       <td>Number of sent messages that are available for resending on counterparty's <a href="http://www.onixs.biz/fixdictionary/4.0/msgType_2_2.html">Resend Request <2></a> message. </td> 
00512       <td class="constant">1000</td> 
00513     </tr>
00514 
00515      <tr> 
00516       <td>\anchor SslCertificateFile SSL.CertificateFile</td> 
00517       <td>The path to the SSL certificate file in (Privacy Enhanced Mail) Base64 encoded (.pem) format.</td> 
00518       <td class="constant">Empty</td> 
00519     </tr>     
00520 
00521     <tr> 
00522       <td>SSL.ListenPort</td> 
00523       <td>FIX Engine listens on this port for incoming SSL connections. If it is set to '0' then only SSL-based session-initiators can be created. If '-1' then the SSL encryption is disabled. 
00524 </td> 
00525       <td class="constant">0</td> 
00526     </tr>     
00527 
00528      <tr> 
00529       <td>\anchor SslPrivateKeyFile SSL.PrivateKeyFile</td> 
00530       <td>The path to the SSL private key file in (Privacy Enhanced Mail) Base64 encoded (.pem) format.</td> 
00531       <td class="constant">Empty</td> 
00532     </tr>    
00533 
00534     <tr> 
00535       <td>SSL.PrivateKeyPassword</td> 
00536       <td>The password to load private keys that are protected by a password.</td> 
00537       <td class="constant">Empty</td> 
00538     </tr>   
00539 
00540     <tr> 
00541       <td>SSL.VerifyPeer</td> 
00542       <td>Option to request client certificates and perform the certificate verification.</td> 
00543       <td class="constant">False</td> 
00544     </tr>   
00545 
00546     <tr> 
00547       <td>Validate.NumberOfRepeatingGroupInstances</td> 
00548       <td>Option to validate that the declared number of \ref RepeatingGroup instances is equal to the actual one.</td> 
00549       <td class="constant">True</td> 
00550     </tr> 
00551     <tr> 
00552       <td>Validate.RequiredFields</td> 
00553       <td>Option to validate the presence of \ref RequiredFields "required fields" in inbound and outbound messages.</td> 
00554       <td class="constant">False</td> 
00555     </tr> 
00556     <tr> 
00557       <td>Validate.UnknownFields</td> 
00558       <td>Option to validate the presence of unknown fields (fields that do not belong to the message in accordance with 
00559       the FIX protocol or its \ref FIX_Dialect "FIX Dialect".</td> 
00560       <td class="constant">False</td> 
00561     </tr> 
00562 
00563     <tr> 
00564       <td>Validate.UnknownMessages</td> 
00565       <td>Option to validate the presence of unknown FIX messages (messages that do not belong to the message in accordance with 
00566       the FIX protocol  or its \ref FIX_Dialect "FIX Dialect".</td> 
00567       <td class="constant">False</td> 
00568     </tr> 
00569 
00570   </table> 
00571 
00572   \see \ref Engine
00573 
00574 \section Advanced Advanced
00575 
00576 \subsection RepeatingGroup Repeating Group 
00577 
00578  It is permissible for fields to be repeated in the same message within a repeating group. 
00579 For example, <pre>"215=2<SOH></a>216=2<SOH>217=Dest_1<SOH>216=4<SOH>217=Dest_2<SOH>"</pre>
00580  represents a repeating group with two repeating instances "delimited" by tag <strong>216</strong> (first field in the repeating group.). 
00581   The NoRoutingIDs<215> field specifies the number of repeating group instances (2 in this case). This is so called <strong>NumberOfInstances field</strong>. 
00582     The NumberOfInstances field must immediately precede the repeating group contents (repeating group instances). 
00583 
00584  \image html RepeatingGroup.gif
00585 
00586 The FIX repeating group is represented with the FIXForge::FIX::Group class. 
00587 
00588 To get the Group object that represents the existing repeating group of the message the 
00589 FIXForge::FIX::Message::getGroup(int numberOfInstancesTag) method is used.  
00590 
00591 To create a new repeating group or modify the number of instances in the existing one the 
00592 FIXForge::FIX::Message::setGroup(int numberOfInstancesTag, int numberOfInstances) method is used. 
00593 
00594 To remove a repeating group method FIXForge::FIX::Message::remove(int numberOfInstancesTag) is used. 
00595 
00596 The FIXForge::FIX::Group class works with fields and embedded repeating groups in the same manner as the FIXForge::FIX::Message class, 
00597 but each method has an additional parameter that defines the index of the repeating group instance (starting from 0). 
00598 
00599 <strong>Note:</strong> To avoid memory leaks call FIXForge::FIX::Group::release().
00600 
00601   Example: 
00602 \code
00603 #include <FIXForge_FIXEngine.h>
00604 
00605 using namespace FIXForge::FIX;
00606 using namespace FIXForge::FIX::FIX42;
00607 
00608 Message request("V", FIX_42);
00609 
00610 request.set(Tags::MDReqID, "ABSD");
00611 request.set(Tags::SubscriptionRequestType, 1);
00612 request.set(Tags::MarketDepth, 1);
00613 request.set(Tags::MDUpdateType, 1);
00614 request.set(Tags::AggregatedBook, "N");
00615 
00616 // create a repeating group NoMDEntryTypes with two instances
00617 Group* groupMDEntryTypes = request.setGroup(Tags::NoMDEntryTypes, 2);
00618 
00619 groupMDEntryTypes->set(Tags::MDEntryType, 0, "EntryType_1"); // first instance
00620 groupMDEntryTypes->set(Tags::MDEntryType, 1, "EntryType_2"); // second instance
00621 
00622 groupMDEntryTypes->release(); // to free resources
00623 
00624 // create a repeating group NoRelatedSym with two instances
00625 Group* groupRelatedSym = request.setGroup(Tags::NoRelatedSym, 2);
00626 
00627 groupRelatedSym->set(Tags::Symbol, 0, "EURUSD_0"); // first instance
00628 groupRelatedSym->set(Tags::Symbol, 1, "EURUSD_1"); // second instance
00629 
00630 groupRelatedSym->release(); // to free resources
00631 
00632 request.validate();
00633 
00634 clog << request << endl;
00635 \endcode
00636 
00637 \subsection SessionStates Session States 
00638 
00639 To obtain the current session state the FIXForge::FIX::Session::getState() method is used. 
00640 
00641   The states of the FIX session are listed below. 
00642   <table  border=1 cellspacing=0 cellpadding=0> 
00643     <caption>FIX Session states</caption>
00644     <tr> 
00645       <th width=190 rowspan=2>State</th> 
00646       <th width=489 colspan=2>Description</th> 
00647     </tr> 
00648     <tr> 
00649       <td width=237>Role == <strong>Acceptor</strong></td> 
00650       <td width=252>Role == <strong>Initiator</strong></td> 
00651     </tr> 
00652     <tr> 
00653       <td width=190>DISCONNECTED</td> 
00654       <td width=489 colspan=2>The session is disconnected.</td> 
00655     </tr> 
00656     <tr> 
00657       <td width=190>\anchor State_LOGON_IN_PROGRESS  LOGON_IN_PROGRESS</td> 
00658       <td width=237> The session is waiting for the initial <i>Logon</i> message.</td> 
00659       <td width=252> The initial <i>Logon</i> message was sent and the session is waiting for the acknowledgment <i>Logon</i> message.</td> 
00660     </tr> 
00661     <tr> 
00662       <td width=190> ACTIVE</td> 
00663       <td width=489 colspan=2> The session is fully established (after the successful <i>Logon</i> exchange).</td> 
00664     </tr> 
00665     <tr> 
00666       <td width=190>\anchor State_RECONNECTING RECONNECTING</td> 
00667       <td width=237>N/A (only session-initiator can be in this state).</td> 
00668       <td width=252> Session-initiator is trying to restore the telecommunication link.</td> 
00669     </tr> 
00670     <tr> 
00671       <td width=190> LOGOUT_IN_PROGRESS</td> 
00672       <td width=489 colspan=2> The initial Logout message was sent and the session is waiting for the acknowledgment Logout message.</td> 
00673     </tr> 
00674   </table> 
00675 
00676   To be notified about the changes in the session stateoverwrite the FIXForge::FIX::ISessionListener::onStateChange method. 
00677   
00678 Example:
00679 \code
00680 class Listener : public ISessionListener{
00681 public :
00682     virtual void Listener::onStateChange(Session::State newState, Session::State prevState, Session* sn){       
00683         clog << "\nSession's state is changed, prevState=" << Session::state2string(prevState) 
00684              << ", newState=" << Session::state2string(newState) << endl;
00685     }
00686 };
00687 \endcode
00688 
00689 \subsection SessionEvents Session Events 
00690 
00691 To be notified about session events overwrite the FIXForge::FIX::ISessionListener class methods. 
00692 
00693 The methods of the FIXForge::FIX::ISessionListener class are listed below.
00694 
00695 <table border=1 cellspacing=0 cellpadding=0> 
00696     <caption>Session events</caption>
00697     <tr> 
00698       <th width=367>Method (Event handler)</th> 
00699       <th width=367>Description</th> 
00700     </tr> 
00701     <tr> 
00702       <td width=367>onStateChange</td> 
00703       <td width=367>Session state is changed.</td> 
00704     </tr> 
00705     <tr> 
00706       <td width=367>onError</td> 
00707       <td width=367>Error condition is detected.</td> 
00708     </tr> 
00709     <tr> 
00710       <td width=367>onInboundApplicationMsg</td> 
00711       <td width=367>Application-level message is received from the counterparty.</td> 
00712     </tr> 
00713     <tr> 
00714       <td width=367>onInboundSessionMsg</td> 
00715       <td width=367>Session-level message is received from the counterparty.</td> 
00716     </tr> 
00717     <tr> 
00718       <td width=367>onOutboundApplicationMsg</td> 
00719       <td width=367>Application-level message will be sent to the counterparty.</td> 
00720     </tr> 
00721     <tr> 
00722       <td width=367>onOutboundSessionMsg</td> 
00723       <td width=367>Session-level message will be sent to the counterparty.</td> 
00724     </tr> 
00725 
00726     <tr> 
00727       <td width=367>onResendRequest</a></td> 
00728       <td width=367>Sent application-level message is about to be resent to the counterparty.</td> 
00729     </tr> 
00730     <tr> 
00731       <td width=367>onWarning</td> 
00732       <td width=367>Warning condition is detected.</td> 
00733     </tr> 
00734 </table> 
00735 
00736   \warning It is important not perform time-consuming tasks inside event handlers. 
00737 
00738 \subsection CustomLogonMessage Custom Logon Message 
00739 
00740 Sometime there is need to set additional fields (e.g. <a href="http://onixs.biz/fixdictionary/5.0/tagNum_553.html">Username (553)</a>,
00741 <a href="http://onixs.biz/fixdictionary/5.0/tagNum_554.html">Password (554)</a>) in the initiation 
00742 <a href="http://onixs.biz/fixdictionary/4.1/msgType_A_65.html">Logon</a> message. 
00743 In this case the FIXForge::FIX::Session::logonAsInitiator(const std::string &host, int port, int heartBtInt, Message *customLogonMsg) method must be used.
00744  
00745 Example: 
00746 \code
00747 #include <FIXForge_FIXEngine.h>
00748 
00749 using namespace FIXForge::FIX;
00750 using namespace FIXForge::FIX::FIX43;
00751 
00752 const string SENDER_COMP_ID = "CustomLogonMessage_SND";
00753 const string TARGET_COMP_ID = "CustomLogonMessage_TRG";
00754 
00755 const Version VERSION = FIX_43;
00756 
00757 const int HBI = 30;
00758 const string USERNAME = "USER_NAME";
00759 const string PASSWORD = "PASSWORD";
00760 
00761 int port = Engine::instance()->getListenPort();
00762 
00763 ISessionListener listener;
00764 
00765 Session acceptor(SENDER_COMP_ID, TARGET_COMP_ID, VERSION, &listener);
00766 acceptor.logonAsAcceptor();
00767 Session initiator(TARGET_COMP_ID, SENDER_COMP_ID, VERSION, &listener);
00768 
00769 Message customLogonMsg("A", FIX_43);
00770 
00771 customLogonMsg.set(Tags::Username, USERNAME);
00772 customLogonMsg.set(Tags::Password, PASSWORD);
00773 
00774 initiator.logonAsInitiator("localhost", port, HBI, &customLogonMsg);
00775 
00776 // message exchange and processing ...
00777 
00778 acceptor.logout();
00779 initiator.logout();
00780 
00781 acceptor.shutdown();
00782 initiator.shutdown();
00783 \endcode
00784 
00785 \subsection Dialects FIX Dialects 
00786 
00787 It is not uncommon for firms to implement slightly different interpretations of the FIX protocol (dialects), 
00788 so sometime there is need to validate that such messages confirm to a particular FIX dialect. 
00789  
00790 The FixEngine.Dialect \ref Settings "configuration setting" specifies the description of such dialects in XML format. 
00791 This description must confirm to the <a href="Dialect.xsd">Dialect.xsd</a> XML Schema file. 
00792 
00793 <strong>To add a new user-defined field to a FIX Message </strong>add the corresponding Field entity to the FIX Dialect description.
00794 For example: 
00795 
00796 \code
00797 <FIX version="4.0">
00798     <Message type="D">
00799         <Field tag="526" name="SecondaryClOrdID"/> <!-- Does not belong to Standard FIX 4.0 --> 
00800     </Message> 
00801 </FIX>
00802 \endcode
00803 
00804 <strong>To add a new user-defined repeating group to a FIX Message </strong>add the corresponding Group entity to the FIX Dialect description.
00805 For example: 
00806 \code 
00807 <FIX version="4.0">
00808     <Message type="D">
00809         <Group numberOfInstancesTag="78" name="NoAllocs"> <!-- Number of repeating groups for pre-trade allocation, does not belong to Standard FIX 4.0 -->
00810             <Field tag="79" name="AllocAccount"/> <!--  Does not belong to Standard FIX 4.0 --> 
00811             <Field tag="661" name="AllocAcctIDSource"/> <!--  Does not belong to Standard FIX 4.0 --> 
00812             <Field tag="736" name="AllocSettlCurrency"/> <!--  Does not belong to Standard FIX 4.0 --> 
00813             <!-- Other group fields -->
00814         </Group>
00815     </Message> 
00816 </FIX>
00817 \endcode
00818 
00819 <strong>To make a field, which is required according to the FIX Protocol specification, optional, and visa-versa,
00820 </strong> add  the corresponding Field entity to the FIX Dialect description and set the isRequired attribute accordingly. 
00821 For example:
00822 \code
00823   
00824 <FIX version="4.0">
00825     <Message type="D">
00826         <Field tag="21" isRequired="false" name="HandlInst"/> <!-- Required in Standard FIX 4.0, but optional in this FIX dialect --> 
00827         <Field tag="109" isRequired="true" name="ClientID"/> <!-- Optional in Standard FIX 4.0, but required in this FIX dialect --> 
00828     </Message> 
00829 </FIX>
00830 \endcode
00831 
00832 <strong>To define a User Defined Message</strong> add the corresponding Message entity to the FIX Dialect description.
00833 For example: 
00834 \code  
00835 <FIX version="4.0">
00836     <Message type="UserDefinedMessage_1">
00837         <Field tag="100"/> 
00838         <Field tag="101"/> 
00839     </Message> 
00840 </FIX>
00841 \endcode
00842 
00843 Such a user-defined message can be used exactly the same way as the standard FIX Message:
00844 \code
00845 Message udm_1("UserDefinedMessage_1", FIX_43);
00846 
00847 udm_1.set(100, "Field 100");
00848 udm_1.set(101, "Field 101");
00849 
00850 udm_1.validate();
00851 
00852 clog << "UDM: " << udm_1 << endl;
00853 \endcode
00854 
00855 Example of a FIX Dialect description file:
00856 \code
00857 <?xml version="1.0" encoding="utf-8"?>
00858 <Dialect xmlns="http://tempuri.org/Dialect.xsd" name="Lava">
00859 
00860 <FIX version="4.2"> 
00861     <Message type="N">      
00862         <Group numberOfInstancesTag="73" name="RefAllocID">
00863             <!-- An additional field in the existing repeating group -->
00864             <Field tag="37" name="OrderID"/>            
00865         </Group>
00866     </Message>
00867 </FIX>
00868     
00869 <FIX version="4.3">
00870     <Message type="y">
00871         <Group numberOfInstancesTag="146" name="NoRelatedSym">
00872             <!-- An additional field in the existing repeating group -->
00873             <Field tag="64" isRequired="true" name="FutSettDate"/>
00874         </Group>
00875     </Message>
00876         
00877     <Message type="W">
00878         <Group numberOfInstancesTag="268" name="NoMDEntries">
00879             <!-- An additional field in the existing repeating group -->
00880             <Field tag="278" name="MDEntryID"/>
00881         </Group>
00882         <Field tag="64" name="FutSettDate"/>
00883     </Message>
00884   
00885     <Message type="X">
00886         <!-- An additional field -->
00887         <Field tag="55" name="Symbol"/>
00888 
00889         <!-- An additional field -->
00890         <Field tag="64" name="FutSettDate"/>
00891     </Message>
00892 </FIX>
00893 </Dialect>
00894 \endcode
00895 
00896  \subsection ResendRequestProcessing Resend Request processing 
00897 
00898 When the <a href="http://www.onixs.biz/fixdictionary/4.0/msgType_2_2.html">Resend Request (4)</a> message is received 
00899 from the counterparty and the application has overridden
00900 the FIXForge::FIX::ISessionListener::onResendRequest() method, this method is called. 
00901 Otherwise the sent application-level message is  re-sent immediately.
00902 
00903 If the sent application-level message should not be resent to the counterparty (e.g. an aged order) then the FIXForge::FIX::ISessionListener::onResendRequest() method should return false. In this case the <a href="http://www.onixs.biz/fixdictionary/4.0/msgType_4_4.html">Sequence Reset-GapFill (4)</a> message will be sent instead.
00904 
00905 \subsection AcceptingFixSessionWithoutCreationSessionObject Accepting FIX Session without the prior creation of the Session object
00906 
00907 Sometimes it is required to accept an incoming FIX session 'on the fly', without the prior creation of the FIXForge::FIX::Session object and connecting it as Acceptor 
00908 (for example, when the <a href="http://www.onixs.biz/fixdictionary/5.0/tagNum_49.html">SenderCompID</a> or 
00909 <a href="http://www.onixs.biz/fixdictionary/5.0/tagNum_56.html">TargetCompID</a> of the incoming session is not known in advance). 
00910 
00911 To perform this task, inherit from the FIXForge::FIX::IEngineListener class, overwrite the FIXForge::FIX::IEngineListener::onUnknownIncomingConnection method 
00912 and register your listener object with the FIXForge::FIX::Engine instance using the FIXForge::FIX::Engine::registerListener method.
00913 
00914 An automatically created FIXForge::FIX::Session object that corresponds to the incoming FIX connection is available via the <code>session</code> parameter of the FIXForge::FIX::IEngineListener::onUnknownIncomingConnection callback method.
00915 
00916 To accept the incoming connection, set the <code>acceptConnection</code> parameter of the FIXForge::FIX::IEngineListener::onUnknownIncomingConnection callback method to <code>true</code>.  
00917 To listen to incoming messsages register your class inhereted from from the FIXForge::FIX::ISessionListener using the FIXForge::FIX::Session::registerListener method.
00918 
00919 Otherwise the incoming connection will be rejected and the created FIXForge::FIX::Session object will be disposed by the FIX Engine. 
00920 
00921 To send the <a href="http://www.onixs.biz/fixdictionary/5.0/msgType_5_5.html">Logout</a> message before closing the rejected connection set the <code>rejectReason</code> parameter of the FIXForge::FIX::IEngineListener::onUnknownIncomingConnection callback method to the rejection description.
00922 
00923 For example:
00924 
00925 \code
00926 
00927 class MyListener : public FIXForge::FIX::IEngineListener, public FIXForge::FIX::ISessionListener
00928 {
00929     public:
00930         MyListener(bool acceptConnection, const string& rejectReason)
00931             : acceptConnection_(acceptConnection), rejectReason_(rejectReason), session_(NULL){;}
00932 
00933         ~MyListener()
00934         {
00935             delete session_;
00936         }       
00937 
00938         virtual void onUnknownIncomingConnection(const Message& incomingLogon, Session* session, bool* acceptConnection, std::string* rejectReason)
00939         {           
00940             *acceptConnection = acceptConnection_;
00941 
00942             if(acceptConnection_)
00943             {
00944                 session_ = session;
00945                 session_->registerListener(this); // To listen to incoming messsages.
00946             }
00947             else
00948             {
00949                 *rejectReason = rejectReason_; // To send the Logout message before closing the rejected connection.
00950             }
00951         }
00952 
00953         virtual void onInboundApplicationMsg(const Message& message, Session* sn)
00954         {
00955             // ...
00956         }               
00957 
00958     private:
00959         FIXForge::FIX::Session* session_;
00960         bool acceptConnection_;     
00961 };
00962 
00963 // ...
00964 
00965 MyListener listener(true, "");
00966 
00967 Engine::instance()->registerListener(&listener);
00968 
00969 \endcode
00970 
00971 \section SslEncryption SSL encryption
00972 
00973 To use the Ssl (Secure Sockets Layer) connectivity the following steps should be taken:
00974 
00975 <ol>
00976 <li>If the counterparty requires client-side SSL certificate set the \ref SslCertificateFile "SSL.CertificateFile" and \ref SslPrivateKeyFile "SSL.PrivateKeyFile" 
00977 FIX Engine configuration settings. They can refer to the same file if it contains both the SSL certificate and the private key. </li>
00978 <li>Set the encryption to FIXForge::FIX::Session::SSL using the FIXForge::FIX::Session::setEncryptionMethod() method right after the creation of the FIXForge::FIX::Session object. </li>
00979 <li>Establish the FIX Connection \ref Session "as usual". </li>
00980 </ol>
00981 
00982 For example:
00983 \code
00984 
00985 ISessionListener listener;      
00986 
00987 Session initiator("SenderCompIDValue", "TargetCompIDValue", FIX_42, &listener);
00988 initiator.setEncryptionMethod(Session::SSL);
00989         
00990 initiator.logonAsInitiator("localhost", 443, true);
00991 
00992 // Message exchange ... 
00993                 
00994 initiator.logout("SSL connection is finished.");
00995 initiator.shutdown();   
00996 
00997 \endcode
00998 
00999 \subsection FormatOfSslCertificates Format of SSL certificates
01000 
01001 Only the (Privacy Enhanced Mail) Base 64 Encoded (<b>.pem</b>) SSL certificates are supported. 
01002 
01003 To convert into this format from other format types, the openssl command-line tool could be used (http://www.openssl.org).
01004 
01005 For example, to convert from "Personal Information Exchange - PKCS#12" (<b>.pfx</b>) to "Base64 Encoded" (<b>.pem</b>), the following command is run on the PFX file: 
01006 
01007 \code
01008 openssl pkcs12 -in <file_name>.pfx -out <file_name>.pem -nodes 
01009 \endcode
01010 
01011 \subsection PerSessionSslSettings Per-session SSL settings
01012 Per-session SSL settings ara available via FIXForge::FIX::Session::setSslCertificateFile() and FIXForge::FIX::Session::setSslPrivateKeyFile() methods. 
01013 
01014 For example:
01015 
01016 \code
01017 const string targetCompID = "CNX"; 
01018 const string host = "TargetHost"; 
01019 
01020 { // Stream FIX Session 
01021 
01022     const string streamSenderCompID = "str"; 
01023     ISessionListener listener;  
01024     Session streamSession(streamSenderCompID, targetCompID, FIX_42, &listener); 
01025     streamSession.setEncryptionMethod(Session::SSL); 
01026 
01027     const string streamSslCertificateAndPrivateKeyFile = "str.pem"; 
01028     // If your counterpart performs the verification of your SSL certificate you need to set both SSL Certificate File and SSL Private Key File. 
01029     streamSession.setSslCertificateFile(streamSslCertificateAndPrivateKeyFile);
01030     streamSession.setSslPrivateKeyFile(streamSslCertificateAndPrivateKeyFile);
01031 
01032     const int streamPort = 442;
01033     streamSession.logonAsInitiator(host, streamPort, 30, true);
01034 
01035     clog << "Stream session is established" << endl;
01036 
01037     streamSession.logout();
01038 }
01039 
01040 { // Trading FIX Session 
01041 
01042     const string tradingSenderCompID = "tr"; 
01043     ISessionListener listener;  
01044     Session tradingSession(tradingSenderCompID, targetCompID, FIX_42, &listener);
01045     tradingSession.setEncryptionMethod(Session::SSL); 
01046 
01047     const string tradingSslCertificateAndPrivateKeyFile = "tr.pem";
01048     // If your counterpart performs the verification of your SSL certificate you need to set both SSL Certificate File and SSL Private Key File.
01049     tradingSession.setSslCertificateFile(tradingSslCertificateAndPrivateKeyFile);
01050     tradingSession.setSslPrivateKeyFile(tradingSslCertificateAndPrivateKeyFile);
01051 
01052     const int tradingPort = 443;
01053     tradingSession.logonAsInitiator(host, tradingPort, 30, true);
01054 
01055     clog << "Trading session is established" << endl;
01056 
01057     tradingSession.logout();
01058 }
01059 \endcode
01060 
01061 \section FAST FAST encoding and decoding
01062 
01063 FAST (FIX Adapted for Streaming) is a binary encoding method for message oriented data streams.
01064 
01065 FAST-related classes can be found in the FIXForge::FIX::FAST_1_1 namespace.
01066 
01067 To encode a FIX message into a FAST stream the FIXForge::FIX::FAST_1_1::Encoder class is used.
01068 
01069 For example:
01070 \code
01071 string xmlFastTemplate = readTextFile("UdpFastTemplate.xml");
01072 const bool encodeEachMessageIndependently = true;
01073 Encoder encoder(xmlFastTemplate, sourceFixMessage.getVersion(), encodeEachMessageIndependently);
01074 
01075 const int fastTemplateID = 36;      
01076 const size_t bufferSize = 1024;
01077 char fastStreamChunk[bufferSize];
01078 size_t chunkSize = encoder.encode(sourceFixMessage, fastTemplateID, fastStreamChunk, bufferSize);
01079 \endcode
01080 
01081 To decode a part of a FAST stream back into a FIX message the FIXForge::FIX::FAST_1_1::Decoder class is used.
01082 
01083 For example:
01084 \code
01085 const bool decodeEachMessageIndependently = true;
01086 Decoder decoder(xmlFastTemplate, sourceFixMessage.getVersion(), decodeEachMessageIndependently);
01087 
01088 const Message& decodedMessage = decoder.decode(fastStreamChunk, chunkSize);
01089 \endcode
01090 
01091 \subsection FastTemplate FAST Template
01092 Both FIXForge::FIX::FAST_1_1::Encoder and FIXForge::FIX::FAST_1_1::Decoder constructors require the string that contains XML-based FAST templates.
01093 
01094 A FAST Template specifies the encoding and decoding rules in accordance with the FAST specification.
01095 
01096 For example:
01097 \code
01098 <?xml version="1.0" encoding="utf-8"?>
01099 <templates>
01100     <template name="Market Data - Incremental Refresh (X)" id="88">
01101         <uInt32 name="BodyLength" id="9"/>
01102         <string name="MessageType" id="35">
01103             <constant value="X" />
01104         </string>
01105         <string name="SenderCompID" id="49">
01106             <copy/>
01107         </string>
01108         <string name="TargetCompID" id="56">
01109             <copy/>
01110         </string>
01111         <uInt64 name="MsgSeqNum" id="34">
01112             <increment value="1"/>
01113         </uInt64>
01114         <string name="SendingTime" id="52">
01115             <tail/>
01116         </string>
01117         <string name="PosDupFlag" id="43" presence="optional">
01118             <default/>
01119         </string>
01120         <sequence name="MDEntries">
01121             <length name="NoMDEntries" id="268"/>
01122             <string name="MDUpdateAction" id="279"/>
01123             <string name="Symbol" id="55"/>
01124         </sequence>
01125         <string name="CheckSum" id="10"/>
01126     </template>
01127 <templates>
01128 \endcode
01129 
01130 \subsection FieldTypes Field Types
01131 The following field types are supported:
01132 
01133 <table align="center"  width="100%" border="0" cellspacing="1" cellpadding="2">
01134 <tr>
01135 <td class="white"><table  width="100%"  border="1" cellspacing="1" cellpadding="5" class="white">
01136 <tr class="th">
01137 <th>Field</th>
01138 <th>Example</th>
01139 <th>Notes</th>
01140 </tr>
01141 <tr class="tr1">
01142 <td valign="top"><strong>Signed 32-bit Integer</strong></td>
01143 <td valign="top" class="keyWord">&lt;<span class="constant">int32</span> <span class="attribute">name</span>=&quot;MDEntrySize&quot; <span class="attribute">id</span>=&quot;271&quot; <span class="attribute">presence</span>=&quot;optional&quot;&gt;</td>
01144 <td valign="top">Min value: -2147483648<br>Max value: 2147483647</td>
01145 </tr>
01146 <tr class="tr2">
01147 <td valign="top"><strong>Unsigned 32-bit Integer</strong></td>
01148 <td valign="top" class="keyWord">&lt;<span class="constant">uInt32</span> <span class="attribute">name</span>=&quot;BodyLength&quot; <span class="attribute">id</span>=&quot;9&quot;/&gt;</td>
01149 <td valign="top">Min value: 0<br>Max value: 4294967295</td>
01150 </tr>
01151 <tr class="tr1">
01152 <td valign="top"><strong>Signed 64-bit Integer</strong></td>
01153 <td valign="top" class="keyWord">&lt;<span class="constant">int64</span> <span class="attribute">name</span>=&quot;MinQty&quot; <span class="attribute">id</span>=&quot;110&quot;/&gt;</td>
01154 <td valign="top">Min value: -9223372036854775808<br>Max value: 9223372036854775807</td>
01155 </tr>
01156 <tr class="tr2">
01157 <td valign="top"><strong>Unsigned 64-bit Integer</strong></td>
01158 <td valign="top" class="keyWord">&lt;<span class="constant">uInt64</span> <span class="attribute">name</span>=&quot;MsgSeqNum&quot; <span class="attribute">id</span>=&quot;34&quot;/&gt;</td>
01159 <td valign="top">Min value: 0<br>Max value: 18446744073709551615</td>
01160 </tr>
01161 <tr class="tr1">
01162 <td valign="top"><strong>String</strong></td>
01163 <td valign="top" class="keyWord">&lt;<span class="constant">string</span> <span class="attribute">name</span>=&quot;SenderCompID&quot; <span class="attribute">id</span>=&quot;49&quot;/&gt;</td>
01164 <td valign="top">An optional charset attribute can be used to indicate the character set used in the string (&quot;ascii&quot; or &quot;unicode&quot;).</td>
01165 </tr>
01166 <tr class="tr2">
01167 <td valign="top"><strong>Decimal</strong></td>
01168 <td valign="top" class="keyWord">&lt;<span class="constant">decimal</span> <span class="attribute">name</span>=&quot;MDEntryPx&quot; <span class="attribute">id</span>=&quot;270&quot;&gt;<br>&lt;<span class="constant">exponent</span>/&gt;<br>&lt;<span class="constant">mantissa</span>/&gt;<br>&lt;/<span class="constant">decimal</span>&gt;</td>
01169 <td valign="top">Indicates that the field is represented by two parts: an exponent and a mantissa.</td>
01170 </tr>
01171 <tr class="tr1">
01172 <td valign="top"><strong>Byte Vector</strong></td>
01173 <td valign="top" class="keyWord">&lt;<span class="constant">byteVector</span> <span class="attribute">name</span>=&quot;RawData&quot; <span class="attribute">id</span> =&quot;96&quot; <span class="attribute">presence</span>=&quot;optional&quot;/&gt;</td>
01174 <td valign="top">Sequence of bytes.</td>
01175 </tr>
01176 <tr class="tr2">
01177 <td valign="top">\anchor FieldOperatorSequence <strong>Sequence</strong></td>
01178 <td valign="top" class="keyWord">&lt;<span class="constant">sequence</span> <span class="attribute">name</span>=&quot;NoSecurityAltID&quot; <span class="attribute">id</span>=&quot;454&quot; <span class="attribute">presence</span>=&quot;optional&quot;&gt;<br>&lt;<span class="constant">string</span> <span class="attribute">name</span>=&quot;SecurityAltID&quot; <span class="attribute">id</span>=&quot;455&quot;/&gt;<br>&lt;/<span class="constant">sequence</span>&gt;</td>
01179 <td valign="top"><p>Specifies that the contained group of instructions should be used repeatedly to encode each element (e.g. to encode/decode a FIX Repeating Group).</p><p>A sequence can have an associated <strong>length</strong> field containing an unsigned integer indicating the number of encoded elements.</p></td>
01180 </tr>
01181 </table>
01182 </td>
01183 </tr>
01184 </table>
01185 <p>The optional \a presence attribute indicates whether the field is mandatory or optional. If the attribute is not specified, the field is mandatory.</p>
01186 <p>The required \a name attribute identifies the corresponding field in the current FIX message type by the field name.</p>
01187 <p>The optional \a id  attribute identifies the corresponding field in the current FIX message type by the tag number.</p>
01188 
01189 \subsection FieldOperators Field Operators
01190 
01191 <p>A field that is not a \ref FieldOperatorSequence "Sequence" can have a field operator. The <span class="fileSystem"><strong>Field Operator</strong></span> specifies an optimization operation for the field.</p>
01192 <p>The following field operators are supported:</p>
01193 
01194 <table align="center"  width="100%" border="0" cellspacing="1" cellpadding="2" class="fixTableBorder">
01195 <tr>
01196 <td class="white"><table  width="100%"  border="1" cellspacing="1" cellpadding="5" class="white">
01197 <tr class="th">
01198 <th align="left">Field    Operator</th>
01199 <th>Example</th>
01200 <th>Notes</th>
01201 </tr>
01202 <tr class="tr1">
01203 <td valign="top"><p><strong>Constant</strong></p></td>
01204 <td valign="top"><p class="keyWord">&lt;<span class="constant">string</span> <span class="attribute">name</span>=&quot;MessageType&quot; <span class="attribute">id</span>=&quot;35&quot;&gt;<br>
01205 &lt;<span class="constant">constant</span> <span class="attribute">value</span>=&quot;X&quot; /&gt;<br>
01206 &lt;/<span class="constant">string</span>&gt; </p></td>
01207 <td valign="top"><p>Specifies    that the value of a field will always be the same initial value.</p>
01208 <p>Is    applicable to all field types.</p></td>
01209 </tr>
01210 <tr class="tr2">
01211 <td valign="top"><p><strong>Default</strong></p></td>
01212 <td valign="top"><p class="keyWord">&lt;<span class="constant">string</span> <span class="attribute">name</span>=&quot;PosDupFlag&quot; <span class="attribute">id</span>=&quot;43&quot; <span class="attribute">presence</span>=&quot;optional&quot;&gt;<br>
01213 &lt;<span class="constant">default    = &quot;N&quot;</span> /&gt;<br>
01214 &lt;/<span class="constant">string</span>&gt; </p></td>
01215 <td valign="top"><p>Specifies  that the value of a field is either present in the FAST stream or it will be the initial value.</p>
01216 <p>Is    applicable to all field types.</p></td>
01217 </tr>
01218 <tr class="tr1">
01219 <td valign="top"><p><strong>Copy </strong></p></td>
01220 <td valign="top"><p class="keyWord">&lt;<span class="constant">uInt32</span> <span class="attribute">name</span>=&quot;MDUpdateAction&quot; <span class="attribute">id</span>=&quot;279&quot;&gt;<br>
01221 &lt;<span class="constant">copy</span> <span class="attribute">value</span>=&quot;1&quot; /&gt;<br>
01222 &lt;/<span class="constant">uInt32</span>&gt;</p></td>
01223 <td valign="top"><p>If    the value is present in the stream it becomes the new previous value,    otherwise the value of the field is the previous value.</p>
01224 <p>Is    applicable to all field types.</p></td>
01225 </tr>
01226 <tr class="tr2">
01227 <td valign="top"><p><strong>Increment</strong></p></td>
01228 <td valign="top"><p class="keyWord">&lt;<span class="constant">uInt32</span> <span class="attribute">name</span>=&quot;RptSeq&quot; <span class="attribute">id</span>=&quot;83&quot;&gt;<br>
01229 &lt;<span class="constant">increment</span> /&gt;<br>
01230 &lt;/<span class="constant">uInt32</span>&gt;</p></td>
01231 <td valign="top"><p>If    the value is present in the stream it becomes the new previous value,    otherwise the value of the field is the previous value incremented by one.</p>
01232 <p>Is    applicable to Integer field types only.</p></td>
01233 </tr>
01234 <tr class="tr1">
01235 <td valign="top"><p><strong>Delta</strong></p></td>
01236 <td valign="top"><p class="keyWord">&lt;<span class="constant">int32</span> <span class="attribute">name</span>=&quot;MDEntrySize&quot; <span class="attribute">id</span>=&quot;271&quot;&gt;<br>
01237 &lt;<span class="constant">delta</span> /&gt;<br>
01238 &lt;/<span class="constant">int32</span>&gt;</p></td>
01239 <td valign="top"><p>Specifies that a delta value is present in the stream. The field is obtained by combining the delta value with the previous value.</p>
01240 <p>Is applicable to Integer, Decimal, String and Byte Vector field types.</p></td>
01241 </tr>
01242 <tr class="tr2">
01243 <td valign="top"><p><strong>Tail</strong></p></td>
01244 <td valign="top"><p class="keyWord">&lt;<span class="constant">string</span> <span class="attribute">name</span>=&quot;SendingTime&quot; <span class="attribute">id</span>=&quot;52&quot;&gt;<br>
01245 &lt;<span class="constant">tail</span>/&gt;<br>
01246 &lt;/<span class="constant">string</span>&gt;</p></td>
01247 <td valign="top"><p>Specifies that a tail value is present in the stream.
01248