FIX::SessionSettings Class Reference

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

`#include <SessionSettings.h>`

Collaboration diagram for FIX::SessionSettings:
[legend]

## 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. More...
const Dictionary & | get (const SessionID &) const throw ( ConfigError )
| Get a dictionary for a session. More...
void | set (const SessionID &, Dictionary) throw ( ConfigError )
| Set a dictionary for a session. More...
const Dictionary & | get () const
| Get global default settings. More...
void | set (const Dictionary &defaults) throw ( ConfigError )
| Set global default settings. More...
size_t | size () const
| Number of session settings. More...
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 130 of file SessionSettings.h.

## Member Typedef Documentation

## Dictionaries

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

Definition at line 153 of file SessionSettings.h.

## Constructor & Destructor Documentation

## SessionSettings() [1/3]

FIX::SessionSettings::SessionSettings | ( |  | ) |

inline

Definition at line 133 of file SessionSettings.h.

References has().

{}

## SessionSettings() [2/3]

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

Definition at line 33 of file SessionSettings.cpp.

{
stream >> *this;
}

## SessionSettings() [3/3]

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

Definition at line 39 of file SessionSettings.cpp.

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

## Member Function Documentation

## get() [1/2]

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

Get a dictionary for a session.

Definition at line 125 of file SessionSettings.cpp.

References m_settings.

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

{
Dictionaries::const_iterator i;
i = m_settings.find( sessionID );
if ( i == m_settings.end() ) throw ConfigError( "Session not found" );
return i->second;
}
FIX::SessionSettings::m_settings
Dictionaries m_settings
Definition: SessionSettings.h:159

## get() [2/2]

const Dictionary& FIX::SessionSettings::get | ( |  | ) | const

inline

Get global default settings.

Definition at line 146 of file SessionSettings.h.

References m_defaults.

{ return m_defaults; }
FIX::SessionSettings::m_defaults
Dictionary m_defaults
Definition: SessionSettings.h:160

## getSessions()

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

Definition at line 158 of file SessionSettings.cpp.

References m_settings.

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

{
std::set < SessionID > result;
Dictionaries::const_iterator i;
for ( i = m_settings.begin(); i != m_settings.end(); ++i )
result.insert( i->first );
return result;
}
FIX::SessionSettings::m_settings
Dictionaries m_settings
Definition: SessionSettings.h:159

## has()

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

Check if session setings are present.

Definition at line 120 of file SessionSettings.cpp.

References m_settings.

Referenced by FIX::ScreenLogFactory::create(), SessionSettings(), and set().

{
return m_settings.find( sessionID ) != m_settings.end();
}
FIX::SessionSettings::m_settings
Dictionaries m_settings
Definition: SessionSettings.h:159

## set() [1/2]

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

Set a dictionary for a session.

Definition at line 134 of file SessionSettings.cpp.

References FIX::BEGINSTRING, has(), m_defaults, m_settings, FIX::SENDERCOMPID, FIX::TARGETCOMPID, and validate().

{
if( has(sessionID) )
throw ConfigError( "Duplicate Session " + sessionID.toString() );
settings.setString( BEGINSTRING, sessionID.getBeginString() );
settings.setString( SENDERCOMPID, sessionID.getSenderCompID() );
settings.setString( TARGETCOMPID, sessionID.getTargetCompID() );
settings.merge( m_defaults );
validate( settings );
m_settings[ sessionID ] = settings;
}
FIX::SessionSettings::m_defaults
Dictionary m_defaults
Definition: SessionSettings.h:160
FIX::BEGINSTRING
const char BEGINSTRING[]
Definition: SessionSettings.h:37
FIX::SessionSettings::has
const bool has(const SessionID &) const
Check if session setings are present.
Definition: SessionSettings.cpp:120
FIX::TARGETCOMPID
const char TARGETCOMPID[]
Definition: SessionSettings.h:39
FIX::SessionSettings::validate
void validate(const Dictionary &) const
Definition: SessionSettings.cpp:167
FIX::SENDERCOMPID
const char SENDERCOMPID[]
Definition: SessionSettings.h:38
FIX::SessionSettings::m_settings
Dictionaries m_settings
Definition: SessionSettings.h:159

## set() [2/2]

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

Set global default settings.

Definition at line 150 of file SessionSettings.cpp.

References m_defaults, and m_settings.

{
m_defaults = defaults;
Dictionaries::iterator i = m_settings.begin();
for( i = m_settings.begin(); i != m_settings.end(); ++i )
i->second.merge( defaults );
}
FIX::SessionSettings::m_defaults
Dictionary m_defaults
Definition: SessionSettings.h:160
FIX::SessionSettings::m_settings
Dictionaries m_settings
Definition: SessionSettings.h:159

## size()

size_t FIX::SessionSettings::size | ( |  | ) | const

inline

Number of session settings.

Definition at line 151 of file SessionSettings.h.

References m_settings.

{ return m_settings.size(); }
FIX::SessionSettings::m_settings
Dictionaries m_settings
Definition: SessionSettings.h:159

## validate()

void FIX::SessionSettings::validate | ( | const Dictionary & | dictionary | ) | const
throw | ( | ConfigError
| ) |  |

private

Definition at line 167 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.

Referenced by set().

{
std::string beginString = dictionary.getString( BEGINSTRING );
if( beginString != BeginString_FIX40 &&
beginString != BeginString_FIX41 &&
beginString != BeginString_FIX42 &&
beginString != BeginString_FIX43 &&
beginString != BeginString_FIX44 &&
beginString != BeginString_FIXT11 )
{
throw ConfigError( std::string(BEGINSTRING) + " must be FIX.4.0 to FIX.4.4 or FIXT.1.1" );
}
std::string connectionType = dictionary.getString( CONNECTION_TYPE );
if( connectionType != "initiator" &&
connectionType != "acceptor" )
{
throw ConfigError( std::string(CONNECTION_TYPE) + " must be 'initiator' or 'acceptor'" );
}
}
FIX::BeginString_FIX44
const char BeginString_FIX44[]
Definition: Values.h:32
FIX::CONNECTION_TYPE
const char CONNECTION_TYPE[]
Definition: SessionSettings.h:42
FIX::BeginString_FIX42
const char BeginString_FIX42[]
Definition: Values.h:34
FIX::BeginString_FIXT11
const char BeginString_FIXT11[]
Definition: Values.h:30
FIX::BEGINSTRING
const char BEGINSTRING[]
Definition: SessionSettings.h:37
FIX::BeginString_FIX43
const char BeginString_FIX43[]
Definition: Values.h:33
FIX::BeginString_FIX41
const char BeginString_FIX41[]
Definition: Values.h:35
FIX::BeginString_FIX40
const char BeginString_FIX40[]
Definition: Values.h:36

## Friends And Related Function Documentation

## operator<<

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

friend

Definition at line 87 of file SessionSettings.cpp.

{
const Dictionary& defaults = s.m_defaults;
if( defaults.size() )
{
stream << "[DEFAULT]" << std::endl;
Dictionary::iterator i;
for( i = defaults.begin(); i != defaults.end(); ++i )
stream << i->first << "=" << i->second << std::endl;
stream << std::endl;
}
std::set<SessionID> sessions = s.getSessions();
std::set<SessionID>::iterator i;
for( i = sessions.begin(); i != sessions.end(); ++i )
{
stream << "[SESSION]" << std::endl;
const Dictionary& section = s.get( *i );
if( !section.size() ) continue;
Dictionary::iterator i;
for( i = section.begin(); i != section.end(); ++i )
{
if( defaults.has(i->first) && defaults.getString(i->first) == i->second )
continue;
stream << i->first << "=" << i->second << std::endl;
}
stream << std::endl;
}
return stream;
}
FIX::Dictionary::iterator
Data::const_iterator iterator
Definition: Dictionary.h:44

## Member Data Documentation

## m_defaults

Dictionary FIX::SessionSettings::m_defaults

private

Definition at line 160 of file SessionSettings.h.

Referenced by get(), FIX::operator<<(), and set().

## m_settings

Dictionaries FIX::SessionSettings::m_settings

private

Definition at line 159 of file SessionSettings.h.

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

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

- SessionSettings.h
- SessionSettings.cpp