SessionSettings.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* -*- C++ -*- */
  2. /****************************************************************************
  3. ** Copyright (c) 2001-2014
  4. **
  5. ** This file is part of the QuickFIX FIX Engine
  6. **
  7. ** This file may be distributed under the terms of the quickfixengine.org
  8. ** license as defined by quickfixengine.org and appearing in the file
  9. ** LICENSE included in the packaging of this file.
  10. **
  11. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  12. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  13. **
  14. ** See http://www.quickfixengine.org/LICENSE for licensing information.
  15. **
  16. ** Contact ask@quickfixengine.org if any conditions of this licensing are
  17. ** not clear to you.
  18. **
  19. ****************************************************************************/
  20. #ifndef FIX_SESSIONSETTINGS_H
  21. #define FIX_SESSIONSETTINGS_H
  22. #ifdef _MSC_VER
  23. #pragma warning( disable : 4503 4355 4786 4290 )
  24. #endif
  25. #include "Dictionary.h"
  26. #include "SessionID.h"
  27. #include "Exceptions.h"
  28. #include <map>
  29. #include <set>
  30. namespace FIX
  31. {
  32. const char BEGINSTRING[] = "BeginString";
  33. const char SENDERCOMPID[] = "SenderCompID";
  34. const char TARGETCOMPID[] = "TargetCompID";
  35. const char SESSION_QUALIFIER[] = "SessionQualifier";
  36. const char DEFAULT_APPLVERID[] = "DefaultApplVerID";
  37. const char CONNECTION_TYPE[] = "ConnectionType";
  38. const char USE_DATA_DICTIONARY[] = "UseDataDictionary";
  39. const char SEND_RESETSEQNUMFLAG[] = "SendResetSeqNumFlag";
  40. const char SEND_REDUNDANT_RESENDREQUESTS[] = "SendRedundantResendRequests";
  41. const char DATA_DICTIONARY[] = "DataDictionary";
  42. const char TRANSPORT_DATA_DICTIONARY[] = "TransportDataDictionary";
  43. const char APP_DATA_DICTIONARY[] = "AppDataDictionary";
  44. const char USE_LOCAL_TIME[] = "UseLocalTime";
  45. const char START_TIME[] = "StartTime";
  46. const char END_TIME[] = "EndTime";
  47. const char START_DAY[] = "StartDay";
  48. const char END_DAY[] = "EndDay";
  49. const char LOGON_TIME[] = "LogonTime";
  50. const char LOGOUT_TIME[] = "LogoutTime";
  51. const char LOGON_DAY[] = "LogonDay";
  52. const char LOGOUT_DAY[] = "LogoutDay";
  53. const char CHECK_COMPID[] = "CheckCompID";
  54. const char CHECK_LATENCY[] = "CheckLatency";
  55. const char MAX_LATENCY[] = "MaxLatency";
  56. const char HEARTBTINT[] = "HeartBtInt";
  57. const char SOCKET_ACCEPT_PORT[] = "SocketAcceptPort";
  58. const char SOCKET_REUSE_ADDRESS[] = "SocketReuseAddress";
  59. const char SOCKET_CONNECT_HOST[] = "SocketConnectHost";
  60. const char SOCKET_CONNECT_PORT[] = "SocketConnectPort";
  61. const char SOCKET_NODELAY[] = "SocketNodelay";
  62. const char SOCKET_SEND_BUFFER_SIZE[] = "SendBufferSize";
  63. const char SOCKET_RECEIVE_BUFFER_SIZE[] = "ReceiveBufferSize";
  64. const char RECONNECT_INTERVAL[] = "ReconnectInterval";
  65. const char VALIDATE_LENGTH_AND_CHECKSUM[] = "ValidateLengthAndChecksum";
  66. const char VALIDATE_FIELDS_OUT_OF_ORDER[] = "ValidateFieldsOutOfOrder";
  67. const char VALIDATE_FIELDS_HAVE_VALUES[] = "ValidateFieldsHaveValues";
  68. const char VALIDATE_USER_DEFINED_FIELDS[] = "ValidateUserDefinedFields";
  69. const char LOGON_TIMEOUT[] = "LogonTimeout";
  70. const char LOGOUT_TIMEOUT[] = "LogoutTimeout";
  71. const char FILE_STORE_PATH[] = "FileStorePath";
  72. const char MYSQL_STORE_USECONNECTIONPOOL[] = "MySQLStoreUseConnectionPool";
  73. const char MYSQL_STORE_DATABASE[] = "MySQLStoreDatabase";
  74. const char MYSQL_STORE_USER[] = "MySQLStoreUser";
  75. const char MYSQL_STORE_PASSWORD[] = "MySQLStorePassword";
  76. const char MYSQL_STORE_HOST[] = "MySQLStoreHost";
  77. const char MYSQL_STORE_PORT[] = "MySQLStorePort";
  78. const char POSTGRESQL_STORE_USECONNECTIONPOOL[] = "PostgreSQLStoreUseConnectionPool";
  79. const char POSTGRESQL_STORE_DATABASE[] = "PostgreSQLStoreDatabase";
  80. const char POSTGRESQL_STORE_USER[] = "PostgreSQLStoreUser";
  81. const char POSTGRESQL_STORE_PASSWORD[] = "PostgreSQLStorePassword";
  82. const char POSTGRESQL_STORE_HOST[] = "PostgreSQLStoreHost";
  83. const char POSTGRESQL_STORE_PORT[] = "PostgreSQLStorePort";
  84. const char ODBC_STORE_USER[] = "OdbcStoreUser";
  85. const char ODBC_STORE_PASSWORD[] = "OdbcStorePassword";
  86. const char ODBC_STORE_CONNECTION_STRING[] = "OdbcStoreConnectionString";
  87. const char FILE_LOG_PATH[] = "FileLogPath";
  88. const char FILE_LOG_BACKUP_PATH[] = "FileLogBackupPath";
  89. const char SCREEN_LOG_SHOW_INCOMING[] = "ScreenLogShowIncoming";
  90. const char SCREEN_LOG_SHOW_OUTGOING[] = "ScreenLogShowOutgoing";
  91. const char SCREEN_LOG_SHOW_EVENTS[] = "ScreenLogShowEvents";
  92. const char MYSQL_LOG_USECONNECTIONPOOL[] = "MySQLLogUseConnectionPool";
  93. const char MYSQL_LOG_DATABASE[] = "MySQLLogDatabase";
  94. const char MYSQL_LOG_USER[] = "MySQLLogUser";
  95. const char MYSQL_LOG_PASSWORD[] = "MySQLLogPassword";
  96. const char MYSQL_LOG_HOST[] = "MySQLLogHost";
  97. const char MYSQL_LOG_PORT[] = "MySQLLogPort";
  98. const char MYSQL_LOG_INCOMING_TABLE[] = "MySQLLogIncomingTable";
  99. const char MYSQL_LOG_OUTGOING_TABLE[] = "MySQLLogOutgoingTable";
  100. const char MYSQL_LOG_EVENT_TABLE[] = "MySQLLogEventTable";
  101. const char POSTGRESQL_LOG_USECONNECTIONPOOL[] = "PostgreSQLLogUseConnectionPool";
  102. const char POSTGRESQL_LOG_DATABASE[] = "PostgreSQLLogDatabase";
  103. const char POSTGRESQL_LOG_USER[] = "PostgreSQLLogUser";
  104. const char POSTGRESQL_LOG_PASSWORD[] = "PostgreSQLLogPassword";
  105. const char POSTGRESQL_LOG_HOST[] = "PostgreSQLLogHost";
  106. const char POSTGRESQL_LOG_PORT[] = "PostgreSQLLogPort";
  107. const char POSTGRESQL_LOG_INCOMING_TABLE[] = "PostgreSQLLogIncomingTable";
  108. const char POSTGRESQL_LOG_OUTGOING_TABLE[] = "PostgreSQLLogOutgoingTable";
  109. const char POSTGRESQL_LOG_EVENT_TABLE[] = "PostgreSQLLogEventTable";
  110. const char ODBC_LOG_USER[] = "OdbcLogUser";
  111. const char ODBC_LOG_PASSWORD[] = "OdbcLogPassword";
  112. const char ODBC_LOG_CONNECTION_STRING[] = "OdbcLogConnectionString";
  113. const char ODBC_LOG_INCOMING_TABLE[] = "OdbcLogIncomingTable";
  114. const char ODBC_LOG_OUTGOING_TABLE[] = "OdbcLogOutgoingTable";
  115. const char ODBC_LOG_EVENT_TABLE[] = "OdbcLogEventTable";
  116. const char RESET_ON_LOGON[] = "ResetOnLogon";
  117. const char RESET_ON_LOGOUT[] = "ResetOnLogout";
  118. const char RESET_ON_DISCONNECT[] = "ResetOnDisconnect";
  119. const char REFRESH_ON_LOGON[] = "RefreshOnLogon";
  120. const char MILLISECONDS_IN_TIMESTAMP[] = "MillisecondsInTimeStamp";
  121. const char HTTP_ACCEPT_PORT[] = "HttpAcceptPort";
  122. const char PERSIST_MESSAGES[] = "PersistMessages";
  123. /// Container for setting dictionaries mapped to sessions.
  124. class SessionSettings
  125. {
  126. public:
  127. SessionSettings() {}
  128. SessionSettings( std::istream& stream ) throw( ConfigError );
  129. SessionSettings( const std::string& file ) throw( ConfigError );
  130. /// Check if session setings are present
  131. const bool has( const SessionID& ) const;
  132. /// Get a dictionary for a session.
  133. const Dictionary& get( const SessionID& ) const throw( ConfigError );
  134. /// Set a dictionary for a session
  135. void set( const SessionID&, Dictionary ) throw( ConfigError );
  136. /// Get global default settings
  137. const Dictionary& get() const { return m_defaults; }
  138. /// Set global default settings
  139. void set( const Dictionary& defaults ) throw( ConfigError );
  140. /// Number of session settings
  141. int size() const { return m_settings.size(); }
  142. typedef std::map < SessionID, Dictionary > Dictionaries;
  143. std::set < SessionID > getSessions() const;
  144. private:
  145. void validate( const Dictionary& ) const throw( ConfigError );
  146. Dictionaries m_settings;
  147. Dictionary m_defaults;
  148. friend std::ostream& operator<<( std::ostream&, const SessionSettings& );
  149. };
  150. /*! @} */
  151. std::istream& operator>>( std::istream&, SessionSettings& )
  152. throw( ConfigError );
  153. std::ostream& operator<<( std::ostream&, const SessionSettings& );
  154. }
  155. #endif //FIX_SESSIONSETTINGS_H