OnixS C++ ICE Binary Order Entry Handler 1.1.1
API Documentation
Loading...
Searching...
No Matches
Settings.h
Go to the documentation of this file.
1/*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19
20#pragma once
21
24
26#include "../Common/Options.h"
27
28namespace Samples {
29using ONIXS_ICEBOE_NAMESPACE::SessionSettings;
30
31inline
33 const LogonConfiguration& logonCfg, const ConnectivityConfiguration& connCfg, const SettingsConfiguration& settingsCfg)
34{
35 SessionSettings settings;
36
37 const auto settingsFilename = settingsCfg.settingsFile();
38
39 if (ONIXS_ICEBOE_NAMESPACE::Filesystem::exist(settingsFilename))
40 {
41 settings.load(settingsFilename);
42 }
43 else
44 {
45 settings
46 .licenseStore("../../license")
47 .userId(logonCfg.userId())
48 .clientId(logonCfg.clientId())
49 .rawData(logonCfg.password());
50 }
51
52 if(connCfg.useEmulator())
53 settings.keepAliveInterval(5).reconnectAttempts(0);
54
55 settings.useTLS(connCfg.useTLS());
56
57 if(settings.useTLS())
58 std::cerr << "TLS connection is selected." << std::endl;
59
60 return settings;
61}
62
63inline
65{
66 const auto storageType = cfg.storage();
67
68 if(storageType == SessionStorageType::AsyncFileBased)
70}
71
72template <typename Config>
73void fillStorageSettings(SessionSettings& settings, const Config& cfg, typename std::enable_if<std::is_base_of<StorageConfigurationBase, Config>::value, void*>::type=nullptr)
74{
75 fillSettings(settings, cfg);
76}
77
78template <typename Config>
79void fillStorageSettings(SessionSettings&, const Config&, typename std::enable_if<!std::is_base_of<StorageConfigurationBase, Config>::value, void*>::type=nullptr){}
80
81
82template <typename Config>
83void fillBenchmarkSettings(SessionSettings& settings, const Config&, typename std::enable_if<std::is_base_of<BenchmarkConfiguration, Config>::value, void*>::type=nullptr)
84{
85 if(settings.useTLS())
86 {
87 std::cerr << "Please disable TLS for benchmarking." << std::endl;
88 exit(1);
89 }
90
91 settings.logLevel(LogLevel::Error);
93}
94
95template <typename Config>
96void fillBenchmarkSettings(SessionSettings& settings, const Config&, typename std::enable_if<!std::is_base_of<BenchmarkConfiguration, Config>::value, void*>::type=nullptr)
97{
98 settings.logLevel(LogLevel::Debug);
99}
100
101template <typename AppCfg>
103{
104 auto settings = fillSettings(cfg, cfg, cfg);
105 fillStorageSettings(settings, cfg);
106 fillBenchmarkSettings(settings, cfg);
107 return settings;
108}
109
110}
LogLevel::Enum logLevel() const noexcept
The default value is LogLevel::Info.
const std::string & userId() const noexcept
const CpuIndexes & asyncFileBasedStorageThreadAffinity() const noexcept
unsigned short keepAliveInterval() const noexcept
SessionSettings & load(const std::string &configFile)
Loads the settings from the given configuration file.
SessionSettings & licenseStore(const std::string &value)
Sets the path to the folder that contains license file(s).
LogSettings::Enum loggerOptions() const noexcept
std::string password() const
Definition Options.h:543
std::string userId() const
Definition Options.h:538
std::string settingsFile() const
Definition Options.h:489
OnixS::ICE::BOE::CpuIndex storageAffinity() const
Definition Options.h:583
OnixS::ICE::BOE::SessionStorageType::Enum storage() const
Definition Options.h:578
void fillStorageSettings(SessionSettings &settings, const Config &cfg, typename std::enable_if< std::is_base_of< StorageConfigurationBase, Config >::value, void * >::type=nullptr)
Definition Settings.h:73
void fillBenchmarkSettings(SessionSettings &settings, const Config &, typename std::enable_if< std::is_base_of< BenchmarkConfiguration, Config >::value, void * >::type=nullptr)
Definition Settings.h:83
SessionSettings fillSettings(const LogonConfiguration &logonCfg, const ConnectivityConfiguration &connCfg, const SettingsConfiguration &settingsCfg)
Definition Settings.h:32
@ Error
A serious error that prevents normal execution.
Definition LogSettings.h:33
@ Debug
Detailed diagnostic information useful during development and testing.
Definition LogSettings.h:45
@ TraceToFile
Trace to the log file.
Definition LogSettings.h:65
@ AsyncFileBased
Asynchronous File-Based Session Storage.