Index  Source Files  Annotated Class List  Alphabetical Class List  Class Hierarchy  Graphical Class Hierarchy   
 

FIX::SessionFactory Class Reference

Responsible for creating Session objects. More...

#include <SessionFactory.h>

Collaboration diagram for FIX::SessionFactory:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SessionFactory (Application &application, MessageStoreFactory &messageStoreFactory, LogFactory *pLogFactory)
 ~SessionFactory ()
Sessioncreate (const SessionID &sessionID, const Dictionary &settings) throw ( ConfigError )

Private Types

typedef std::map< std::string,
DataDictionary * > 
Dictionaries

Private Attributes

Applicationm_application
MessageStoreFactorym_messageStoreFactory
LogFactorym_pLogFactory
Dictionaries m_dictionaries

Detailed Description

Responsible for creating Session objects.

This factory will use QuickFIX SessionID, Dictionary settings, MessageStoreFactory, and optional LogFactory to create all the required sessions for an Application.

Definition at line 45 of file SessionFactory.h.


Member Typedef Documentation

typedef std::map< std::string, DataDictionary* > FIX::SessionFactory::Dictionaries [private]
 

Definition at line 61 of file SessionFactory.h.


Constructor & Destructor Documentation

FIX::SessionFactory::SessionFactory Application application,
MessageStoreFactory messageStoreFactory,
LogFactory pLogFactory
[inline]
 

Definition at line 48 of file SessionFactory.h.

00051 : m_application( application ),
00052   m_messageStoreFactory( messageStoreFactory ),
00053   m_pLogFactory( pLogFactory ) {}

FIX::SessionFactory::~SessionFactory  ) 
 

Definition at line 33 of file SessionFactory.cpp.

References m_dictionaries, QF_STACK_IGNORE_BEGIN, and QF_STACK_IGNORE_END.

00034 { QF_STACK_IGNORE_BEGIN
00035   Dictionaries::iterator i = m_dictionaries.begin();
00036   for ( ; i != m_dictionaries.end(); ++i )
00037     delete i->second;
00038   QF_STACK_IGNORE_END
00039 }


Member Function Documentation

Session * FIX::SessionFactory::create const SessionID sessionID,
const Dictionary settings
throw ( ConfigError )
 

Definition at line 41 of file SessionFactory.cpp.

References FIX::CHECK_COMPID, FIX::CHECK_LATENCY, FIX::Session::checkCompId(), FIX::DataDictionary::checkFieldsHaveValues(), FIX::DataDictionary::checkFieldsOutOfOrder(), FIX::Session::checkLatency(), FIX::DataDictionary::checkUserDefinedFields(), FIX::CONNECTION_TYPE, FIX::DATA_DICTIONARY, FIX::END_DAY, FIX::END_TIME, FIX::DateTime::getDay(), FIX::HEARTBTINT, FIX::LOGON_TIMEOUT, FIX::LOGOUT_TIMEOUT, FIX::MAX_LATENCY, FIX::MILLISECONDS_IN_TIMESTAMP, QF_STACK_POP, QF_STACK_PUSH, FIX::REFRESH_ON_LOGON, FIX::RESET_ON_DISCONNECT, FIX::RESET_ON_LOGON, FIX::RESET_ON_LOGOUT, FIX::SESSION_QUALIFIER, FIX::Session::setLogonTimeout(), FIX::Session::setLogoutTimeout(), FIX::Session::setMaxLatency(), FIX::Session::setMillisecondsInTimeStamp(), FIX::Session::setRefreshOnLogon(), FIX::Session::setResetOnDisconnect(), FIX::Session::setResetOnLogon(), FIX::Session::setResetOnLogout(), FIX::START_DAY, FIX::START_TIME, FIX::USE_DATA_DICTIONARY, FIX::VALIDATE_FIELDS_HAVE_VALUES, FIX::VALIDATE_FIELDS_OUT_OF_ORDER, and FIX::VALIDATE_USER_DEFINED_FIELDS.

Referenced by FIX::Initiator::initialize(), and FIX::Acceptor::initialize().

00043 { QF_STACK_PUSH(SessionFactory::create)
00044 
00045   std::string connectionType = settings.getString( CONNECTION_TYPE );
00046   if ( connectionType != "acceptor" && connectionType != "initiator" )
00047     throw ConfigError( "Invalid ConnectionType" );
00048 
00049   if( connectionType == "acceptor" && settings.has(SESSION_QUALIFIER) )
00050     throw ConfigError( "SessionQualifier cannot be used with acceptor." );
00051 
00052   bool useDataDictionary = true;
00053   if ( settings.has( USE_DATA_DICTIONARY ) )
00054     useDataDictionary = settings.getBool( USE_DATA_DICTIONARY );
00055 
00056   DataDictionary dataDictionary;
00057   if ( useDataDictionary )
00058   {
00059     std::string path = settings.getString( DATA_DICTIONARY );
00060     Dictionaries::iterator i = m_dictionaries.find( path );
00061     if ( i != m_dictionaries.end() )
00062       dataDictionary = *i->second;
00063     else
00064     {
00065       DataDictionary* p = new DataDictionary( path );
00066       dataDictionary = *p;
00067       m_dictionaries[ path ] = p;
00068     }
00069   }
00070 
00071   if( settings.has( VALIDATE_FIELDS_OUT_OF_ORDER ) )
00072   {
00073     dataDictionary.checkFieldsOutOfOrder
00074     ( settings.getBool( VALIDATE_FIELDS_OUT_OF_ORDER ) );
00075   }
00076   if( settings.has( VALIDATE_FIELDS_HAVE_VALUES ) )
00077   {
00078     dataDictionary.checkFieldsHaveValues
00079     ( settings.getBool( VALIDATE_FIELDS_HAVE_VALUES ) );
00080   }
00081   if( settings.has( VALIDATE_USER_DEFINED_FIELDS ) )
00082   {
00083     dataDictionary.checkUserDefinedFields
00084     ( settings.getBool( VALIDATE_USER_DEFINED_FIELDS ) );
00085   }    
00086 
00087   UtcTimeOnly startTime;
00088   UtcTimeOnly endTime;
00089   try
00090   {
00091     startTime = UtcTimeOnlyConvertor::convert
00092                 ( settings.getString( START_TIME ) );
00093     endTime = UtcTimeOnlyConvertor::convert
00094               ( settings.getString( END_TIME ) );
00095   }
00096   catch ( FieldConvertError & e ) { throw ConfigError( e.what() ); }
00097 
00098   int startDay = -1;
00099   int endDay = -1;
00100 
00101   try
00102   {
00103     startDay = settings.getDay( START_DAY );
00104     endDay = settings.getDay( END_DAY );
00105   }
00106   catch( ConfigError & ) {}
00107   catch( FieldConvertError & e ) { throw ConfigError( e.what() ); }
00108 
00109   if( startDay >= 0 && endDay < 0 )
00110     throw ConfigError( "StartDay used without EndDay" );
00111   if( endDay >= 0 && startDay < 0 )
00112     throw ConfigError( "EndDay used without StartDay" );
00113 
00114   HeartBtInt heartBtInt( 0 );
00115   if ( connectionType == "initiator" )
00116   {
00117     heartBtInt = HeartBtInt( settings.getLong( HEARTBTINT ) );
00118     if ( heartBtInt <= 0 ) throw ConfigError( "Heartbeat must be greater than zero" );
00119   }
00120 
00121   Session* pSession = 0;
00122   pSession = new Session( m_application, m_messageStoreFactory,
00123                           sessionID, dataDictionary,
00124                           SessionTime(startTime, endTime, startDay, endDay),
00125                           heartBtInt, m_pLogFactory );
00126 
00127   if ( settings.has( CHECK_COMPID ) )
00128     pSession->checkCompId( settings.getBool( CHECK_COMPID ) );
00129   if ( settings.has( CHECK_LATENCY ) )
00130     pSession->checkLatency( settings.getBool( CHECK_LATENCY ) );
00131   if ( settings.has( MAX_LATENCY ) )
00132     pSession->setMaxLatency( settings.getLong( MAX_LATENCY ) );
00133   if ( settings.has( LOGON_TIMEOUT ) )
00134     pSession->setLogonTimeout( settings.getLong( LOGON_TIMEOUT ) );
00135   if ( settings.has( LOGOUT_TIMEOUT ) )
00136     pSession->setLogoutTimeout( settings.getLong( LOGOUT_TIMEOUT ) );
00137   if ( settings.has( RESET_ON_LOGON ) )
00138     pSession->setResetOnLogon( settings.getBool( RESET_ON_LOGON ) );
00139   if ( settings.has( RESET_ON_LOGOUT ) )
00140     pSession->setResetOnLogout( settings.getBool( RESET_ON_LOGOUT ) );
00141   if ( settings.has( RESET_ON_DISCONNECT ) )
00142     pSession->setResetOnDisconnect( settings.getBool( RESET_ON_DISCONNECT ) );
00143   if ( settings.has( REFRESH_ON_LOGON ) )
00144     pSession->setRefreshOnLogon( settings.getBool( REFRESH_ON_LOGON ) );
00145   if ( settings.has( MILLISECONDS_IN_TIMESTAMP ) )
00146     pSession->setMillisecondsInTimeStamp( settings.getBool( MILLISECONDS_IN_TIMESTAMP ) );
00147 
00148   return pSession;
00149 
00150   QF_STACK_POP
00151 }


Member Data Documentation

Application& FIX::SessionFactory::m_application [private]
 

Definition at line 63 of file SessionFactory.h.

Dictionaries FIX::SessionFactory::m_dictionaries [private]
 

Definition at line 66 of file SessionFactory.h.

Referenced by ~SessionFactory().

MessageStoreFactory& FIX::SessionFactory::m_messageStoreFactory [private]
 

Definition at line 64 of file SessionFactory.h.

LogFactory* FIX::SessionFactory::m_pLogFactory [private]
 

Definition at line 65 of file SessionFactory.h.


The documentation for this class was generated from the following files:
Generated on Mon Jul 24 19:36:49 2006 for QuickFIX by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2001