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

# FIX::SessionSettings Class Reference

Container for setting dictionaries mapped to sessions. More...

`#include <SessionSettings.h>`

Collaboration diagram for FIX::SessionSettings:
[legend]

List of all members.

## Public Types

typedef std::map< SessionID, Dictionary > | Dictionaries

## Public Member Functions

| SessionSettings ()
| SessionSettings (std::istream &stream) throw ( ConfigError )
| SessionSettings (const std::string &file) throw ( ConfigError )
const bool | has (const SessionID &) const
| Check if session setings are present.
const Dictionary & | get (const SessionID &) const throw ( ConfigError )
| Get a dictionary for a session.
void | set (const SessionID &, Dictionary) throw ( ConfigError )
| Set a dictionary for a session.
const Dictionary & | get () const
| Get global default settings.
void | set (const Dictionary &defaults) throw ( ConfigError )
| Set global default settings.
int | size () const
| Number of session settings.
std::set< SessionID > | getSessions () const

## Private Member Functions

void | validate (const Dictionary &) const throw ( ConfigError )

## Private Attributes

Dictionaries | m_settings
Dictionary | m_defaults

## Friends

std::ostream & | operator<< (std::ostream &, const SessionSettings &)

## Detailed Description

Container for setting dictionaries mapped to sessions.

Definition at line 129 of file SessionSettings.h.

## Member Typedef Documentation

typedef std::map< SessionID, Dictionary > FIX::SessionSettings::Dictionaries

Definition at line 152 of file SessionSettings.h.

## Constructor & Destructor Documentation

FIX::SessionSettings::SessionSettings | ( |  | ) | `[inline]`

Definition at line 132 of file SessionSettings.h.

    00132 {}

FIX::SessionSettings::SessionSettings | ( | std::istream & | stream | ) | throw ( ConfigError )

Definition at line 34 of file SessionSettings.cpp.

    00036 {
    00037   stream >> *this;
    00038 }

FIX::SessionSettings::SessionSettings | ( | const std::string & | file | ) | throw ( ConfigError )

Definition at line 40 of file SessionSettings.cpp.

    00042 {
    00043   std::ifstream fstream( file.c_str() );
    00044   if ( !fstream.is_open() )
    00045     throw ConfigError( ( "File " + file + " not found" ).c_str() );
    00046   fstream >> *this;
    00047 }

## Member Function Documentation

const Dictionary& FIX::SessionSettings::get | ( |  | ) | const`[inline]`

Get global default settings.

Definition at line 145 of file SessionSettings.h.

References m_defaults.

Referenced by get().

    00145 { return m_defaults; }

const Dictionary & FIX::SessionSettings::get | ( | const SessionID & | sessionID | ) | const throw ( ConfigError )

Get a dictionary for a session.

Definition at line 127 of file SessionSettings.cpp.

References get(), QF_STACK_POP, and QF_STACK_PUSH.

Referenced by FIX::Initiator::connect(), FIX::ScreenLogFactory::create(), FIX::FileStoreFactory::create(), FIX::FileLogFactory::create(), FIX::Initiator::getSessionSettings(), FIX::Acceptor::getSessionSettings(), FIX::Initiator::initialize(), and FIX::Acceptor::initialize().

    00129 { QF_STACK_PUSH(SessionSettings::get)
    00130
    00131   Dictionaries::const_iterator i;
    00132   i = m_settings.find( sessionID );
    00133   if ( i == m_settings.end() ) throw ConfigError( "Session not found" );
    00134   return i->second;
    00135
    00136   QF_STACK_POP
    00137 }

std::set< SessionID > FIX::SessionSettings::getSessions | ( |  | ) | const

Definition at line 166 of file SessionSettings.cpp.

References m_settings, QF_STACK_POP, and QF_STACK_PUSH.

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

    00167 { QF_STACK_PUSH(SessionSettings::getSessions)
    00168
    00169   std::set < SessionID > result;
    00170   Dictionaries::const_iterator i;
    00171   for ( i = m_settings.begin(); i != m_settings.end(); ++i )
    00172     result.insert( i->first );
    00173   return result;
    00174
    00175   QF_STACK_POP
    00176 }

const bool FIX::SessionSettings::has | ( | const SessionID & | sessionID | ) | const

Check if session setings are present.

Definition at line 121 of file SessionSettings.cpp.

References m_settings, QF_STACK_POP, and QF_STACK_PUSH.

Referenced by FIX::ScreenLogFactory::create().

    00122 { QF_STACK_PUSH(SessionSettings::has)
    00123   return m_settings.find( sessionID ) != m_settings.end();
    00124   QF_STACK_POP
    00125 }

void FIX::SessionSettings::set | ( | const Dictionary & | defaults | ) | throw ( ConfigError )

Set global default settings.

Definition at line 158 of file SessionSettings.cpp.

    00159 {
    00160   m_defaults = defaults;
    00161   Dictionaries::iterator i = m_settings.begin();
    00162   for( i = m_settings.begin(); i != m_settings.end(); ++i )
    00163     i->second.merge( defaults );
    00164 }

void FIX::SessionSettings::set | ( | const SessionID & | sessionID,
|  | Dictionary | settings |
| ) |  |  | throw ( ConfigError )

Set a dictionary for a session.

Definition at line 139 of file SessionSettings.cpp.

References FIX::BEGINSTRING, QF_STACK_POP, QF_STACK_PUSH, FIX::SENDERCOMPID, and FIX::TARGETCOMPID.

    00142 { QF_STACK_PUSH(SessionSettings::set)
    00143
    00144   if( has(sessionID) )
    00145     throw ConfigError( "Duplicate Session " + sessionID.toString() );
    00146
    00147   settings.setString( BEGINSTRING, sessionID.getBeginString() );
    00148   settings.setString( SENDERCOMPID, sessionID.getSenderCompID() );
    00149   settings.setString( TARGETCOMPID, sessionID.getTargetCompID() );
    00150
    00151   settings.merge( m_defaults );
    00152   validate( settings );
    00153   m_settings[ sessionID ] = settings;
    00154
    00155   QF_STACK_POP
    00156 }

int FIX::SessionSettings::size | ( |  | ) | const`[inline]`

Number of session settings.

Definition at line 150 of file SessionSettings.h.

References m_settings.

    00150 { return m_settings.size(); }

void FIX::SessionSettings::validate | ( | const Dictionary & | dictionary | ) | const throw ( ConfigError )`[private]`

Definition at line 178 of file SessionSettings.cpp.

References FIX::BEGINSTRING, FIX::BeginString_FIX40, FIX::BeginString_FIX41, FIX::BeginString_FIX42, FIX::BeginString_FIX43, FIX::BeginString_FIX44, FIX::BeginString_FIXT11, and FIX::CONNECTION_TYPE.

    00180 {
    00181   std::string beginString = dictionary.getString( BEGINSTRING );
    00182   if( beginString != BeginString_FIX40 &&
    00183       beginString != BeginString_FIX41 &&
    00184       beginString != BeginString_FIX42 &&
    00185       beginString != BeginString_FIX43 &&
    00186       beginString != BeginString_FIX44 &&
    00187       beginString != BeginString_FIXT11 )
    00188   {
    00189     throw ConfigError( std::string(BEGINSTRING) + " must be FIX.4.0 to FIX.4.4 or FIXT.1.1" );
    00190   }
    00191
    00192   std::string connectionType = dictionary.getString( CONNECTION_TYPE );
    00193   if( connectionType != "initiator" &&
    00194       connectionType != "acceptor" )
    00195   {
    00196     throw ConfigError( std::string(CONNECTION_TYPE) + " must be 'initiator' or 'acceptor'" );
    00197   }
    00198 }

## Friends And Related Function Documentation

std::ostream& operator<< | ( | std::ostream & | ,
|  | const SessionSettings & |  |
| ) |  |  | `[friend]`

## Member Data Documentation

Dictionary FIX::SessionSettings::m_defaults`[private]`

Definition at line 159 of file SessionSettings.h.

Referenced by get().

Dictionaries FIX::SessionSettings::m_settings`[private]`

Definition at line 158 of file SessionSettings.h.

Referenced by getSessions(), has(), and size().

The documentation for this class was generated from the following files:

- /home/omiller/Development/autobuild/quickfix/src/C++/SessionSettings.h
- /home/omiller/Development/autobuild/quickfix/src/C++/SessionSettings.cpp