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, bool resolveEnvVars=false) throw ( ConfigError )
| SessionSettings (const std::string &file, bool resolveEnvVars=false) 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
bool | m_resolveEnvVars

## Friends

std::istream & | operator>> (std::istream &, SessionSettings &) throw ( ConfigError )
std::ostream & | operator<< (std::ostream &, const SessionSettings &)

## Detailed Description

Container for setting dictionaries mapped to sessions.

Definition at line 237 of file SessionSettings.h.

## Member Typedef Documentation

## Dictionaries

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

Definition at line 260 of file SessionSettings.h.

## Constructor & Destructor Documentation

## SessionSettings() [1/3]

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

inline

Definition at line 240 of file SessionSettings.h.

{ return m_settings.size(); }

## SessionSettings() [2/3]

FIX::SessionSettings::SessionSettings | ( | std::istream & | stream,
|  | bool | resolveEnvVars = `false`
| ) |  |
throw | ( | ConfigError
| ) |  |

Definition at line 50 of file SessionSettings.cpp.

{
Settings settings(s.m_resolveEnvVars);
stream >> settings;

## SessionSettings() [3/3]

FIX::SessionSettings::SessionSettings | ( | const std::string & | file,
|  | bool | resolveEnvVars = `false`
| ) |  |
throw | ( | ConfigError
| ) |  |

Definition at line 57 of file SessionSettings.cpp.

{

## Member Function Documentation

## get() [1/2]

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

inline

Get global default settings.

Definition at line 253 of file SessionSettings.h.

## get() [2/2]

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

Get a dictionary for a session.

Definition at line 144 of file SessionSettings.cpp.

Referenced by FIX::Acceptor::Acceptor(), FIX::Initiator::getSessionSettings(), and FIX::SocketAcceptor::SocketAcceptor().

## getSessions()

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

Definition at line 177 of file SessionSettings.cpp.

{
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" &&

References FIX::BEGINSTRING.

Referenced by FIX::Acceptor::Acceptor(), and FIX::SocketAcceptor::SocketAcceptor().

## has()

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

Check if session setings are present.

Definition at line 139 of file SessionSettings.cpp.

{
if( has(sessionID) )
throw ConfigError( "Duplicate Session " + sessionID.toString() );

References FIX::BEGINSTRING.

## set() [1/2]

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

Set global default settings.

Definition at line 169 of file SessionSettings.cpp.

{
std::string beginString = dictionary.getString( BEGINSTRING );
if( beginString != BeginString_FIX40 &&
beginString != BeginString_FIX41 &&
beginString != BeginString_FIX42 &&

References FIX::BEGINSTRING, FIX::BeginString_FIX40, FIX::BeginString_FIX41, FIX::BeginString_FIX42, and FIX::BeginString_FIX43.

## set() [2/2]

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

Set a dictionary for a session.

Definition at line 153 of file SessionSettings.cpp.

{
m_defaults = defaults;
Dictionaries::iterator i = m_settings.begin();
for( i = m_settings.begin(); i != m_settings.end(); ++i )
i->second.merge( defaults );
}
std::set < SessionID > SessionSettings::getSessions() const
{
std::set < SessionID > result;
Dictionaries::const_iterator i;
for ( i = m_settings.begin(); i != m_settings.end(); ++i )
result.insert( i->first );
return result;
}

## size()

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

inline

Number of session settings.

Definition at line 258 of file SessionSettings.h.

## validate()

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

private

Definition at line 186 of file SessionSettings.cpp.

{
throw ConfigError( std::string(CONNECTION_TYPE) + " must be 'initiator' or 'acceptor'" );
}
}
}

References FIX::CONNECTION_TYPE.

## Friends And Related Function Documentation

## operator<<

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

friend

Definition at line 106 of file SessionSettings.cpp.

{
if( defaults.has(i->first) && defaults.getString(i->first) == i->second )
continue;
stream << i->first << "=" << i->second << std::endl;
}
stream << std::endl;
}
return stream;
}
const bool SessionSettings::has( const SessionID& sessionID ) const
{
return m_settings.find( sessionID ) != m_settings.end();
}
const Dictionary& SessionSettings::get( const SessionID& sessionID ) const
throw( ConfigError )
{
Dictionaries::const_iterator i;
i = m_settings.find( sessionID );
if ( i == m_settings.end() ) throw ConfigError( "Session not found" );
return i->second;
}
void SessionSettings::set( const SessionID& sessionID,
Dictionary settings )

## operator>>

std::istream& operator>> | ( | std::istream & | ,
|  | SessionSettings & |
| ) |  |
throw | ( | ConfigError
| ) |  |

friend

Definition at line 67 of file SessionSettings.cpp.

{
dict = section[ session ];
dict.merge( def );
BeginString beginString
( dict.getString( BEGINSTRING ) );
SenderCompID senderCompID
( dict.getString( SENDERCOMPID ) );
TargetCompID targetCompID
( dict.getString( TARGETCOMPID ) );
std::string sessionQualifier;
if( dict.has( SESSION_QUALIFIER ) )
sessionQualifier = dict.getString( SESSION_QUALIFIER );
SessionID sessionID( beginString, senderCompID, targetCompID, sessionQualifier );
s.set( sessionID, dict );
}
return stream;
}
std::ostream& operator<<( std::ostream& stream, const SessionSettings& s )
{
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 )
{

## Member Data Documentation

## m_defaults

Dictionary FIX::SessionSettings::m_defaults

private

Definition at line 267 of file SessionSettings.h.

## m_resolveEnvVars

bool FIX::SessionSettings::m_resolveEnvVars

private

Definition at line 268 of file SessionSettings.h.

## m_settings

Dictionaries FIX::SessionSettings::m_settings

private

Definition at line 266 of file SessionSettings.h.

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

- SessionSettings.h
- SessionSettings.cpp

FIX::SessionSettings::set
void set(const SessionID &, Dictionary)
Set a dictionary for a session.
Definition: SessionSettings.cpp:153
FIX::BeginString_FIX41
const char BeginString_FIX41[]
Definition: Values.h:52
FIX::SessionSettings::has
const bool has(const SessionID &) const
Check if session setings are present.
Definition: SessionSettings.cpp:139
FIX::BeginString_FIX40
const char BeginString_FIX40[]
Definition: Values.h:53
FIX::SessionSettings::m_defaults
Dictionary m_defaults
Definition: SessionSettings.h:267
FIX::BeginString_FIX42
const char BeginString_FIX42[]
Definition: Values.h:51
FIX::CONNECTION_TYPE
const char CONNECTION_TYPE[]
Definition: SessionSettings.h:59
FIX::SESSION_QUALIFIER
const char SESSION_QUALIFIER[]
Definition: SessionSettings.h:57
FIX::Dictionary::iterator
Data::const_iterator iterator
Definition: Dictionary.h:78
FIX::SessionSettings::operator<<
friend std::ostream & operator<<(std::ostream &, const SessionSettings &)
Definition: SessionSettings.cpp:106
FIX::SessionSettings::m_settings
Dictionaries m_settings
Definition: SessionSettings.h:266
FIX::BEGINSTRING
const char BEGINSTRING[]
Definition: SessionSettings.h:54
FIX::SENDERCOMPID
const char SENDERCOMPID[]
Definition: SessionSettings.h:55
FIX::SessionSettings::getSessions
std::set< SessionID > getSessions() const
Definition: SessionSettings.cpp:177
FIX::SessionSettings::SessionSettings
SessionSettings()
Definition: SessionSettings.h:240
FIX::SessionSettings::get
const Dictionary & get() const
Get global default settings.
Definition: SessionSettings.h:253
FIX::TARGETCOMPID
const char TARGETCOMPID[]
Definition: SessionSettings.h:56