OnixS C++ CME MDP Premium Market Data Handler 5.9.0
API Documentation
Loading...
Searching...
No Matches
MemoryPoolSettings.h
Go to the documentation of this file.
1// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2//
3// This software owned by Onix Solutions Limited [OnixS] and is
4// protected by copyright law and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable
7// OnixS Software Services Agreement (the Agreement) and Customer end user license
8// agreements granting a non-assignable, non-transferable and non-exclusive license
9// to use the software for it's own data processing purposes under the terms defined
10// in the Agreement.
11//
12// Except as otherwise granted within the terms of the Agreement, copying or
13// reproduction of any part of this source code or associated reference material
14// to any other location for further reproduction or redistribution, and any
15// amendments to this copyright notice, are expressly prohibited.
16//
17// Any reproduction or redistribution for sale or hiring of the Software not in
18// accordance with the terms of the Agreement is a violation of copyright law.
19//
20
21#pragma once
22
23#include <string>
24#include <stdexcept>
25
27
29
31inline void throwZeroParameter(const Char* parameter)
32{
33 std::string reason;
34
35 reason += "Non-zero value is expected for '";
36 reason += parameter ? parameter : "<unknown>";
37 reason += "' parameter. ";
38
39 throw std::out_of_range(reason);
40}
41
47{
48public:
51 : blockIncrease_(48)
52 , increaseQty_(32)
53 , chunkSize_(20)
54 , chunkScaling_(2)
55 {
56 }
57
60 : blockIncrease_(other.blockIncrease_)
61 , increaseQty_(other.increaseQty_)
62 , chunkSize_(other.chunkSize_)
63 , chunkScaling_(other.chunkScaling_)
64 {
65 }
66
69
74 size_t blockIncrease() const
75 {
76 return blockIncrease_;
77 }
78
83 void blockIncrease(size_t increase)
84 {
85 const Char* const name = "BlockIncrease";
86
87 if (0 < increase)
88 {
89 blockIncrease_ = increase;
90 }
91 else
92 {
94 }
95 }
96
105 size_t increaseQty() const
106 {
107 return increaseQty_;
108 }
109
118 void increaseQty(size_t qty)
119 {
120 const Char* const name = "IncreaseQty";
121
122 if (0 < qty)
123 {
124 increaseQty_ = qty;
125 }
126 else
127 {
128 throwZeroParameter(name);
129 }
130 }
131
139 size_t chunkSize() const
140 {
141 return chunkSize_;
142 }
143
151 void chunkSize(size_t size)
152 {
153 const Char* const name = "ChunkSize";
154
155 if (0 < size)
156 {
157 chunkSize_ = size;
158 }
159 else
160 {
161 throwZeroParameter(name);
162 }
163 }
164
169 size_t chunkScaling() const
170 {
171 return chunkScaling_;
172 }
173
178 void chunkScaling(size_t factor)
179 {
180 const Char* const name = "ChunkScaling";
181
182 if (0 < factor)
183 {
184 chunkScaling_ = factor;
185 }
186 else
187 {
188 throwZeroParameter(name);
189 }
190 }
191
194 {
195 blockIncrease_ = other.blockIncrease_;
196
197 increaseQty_ = other.increaseQty_;
198
199 chunkSize_ = other.chunkSize_;
200
201 chunkScaling_ = other.chunkScaling_;
202
203 return *this;
204 }
205
206private:
207 size_t blockIncrease_;
208
209 size_t increaseQty_;
210
211 size_t chunkSize_;
212
213 size_t chunkScaling_;
214};
215
218void toStr(std::string&, const MemoryPoolSettings&);
219
221inline std::string toStr(const MemoryPoolSettings& settings)
222{
223 std::string str;
224
225 toStr(str, settings);
226
227 return str;
228}
229
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:67
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:46
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:68
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:171
size_t chunkScaling() const
Defines chunk scale factor.
MemoryPoolSettings()
Initializes parameters with default values.
void increaseQty(size_t qty)
Limits number of increases memory pool does.
~MemoryPoolSettings()
Finalizes the instance.
size_t increaseQty() const
Limits number of increases memory pool does.
MemoryPoolSettings(const MemoryPoolSettings &other)
Initializes as a copy.
size_t blockIncrease() const
Memory block increase value.
void chunkSize(size_t size)
Number of blocks per chunk.
void chunkScaling(size_t factor)
Defines chunk scale factor.
size_t chunkSize() const
Number of blocks per chunk.
MemoryPoolSettings & operator=(const MemoryPoolSettings &other)
Initializes as a copy.
void blockIncrease(size_t increase)
Updates memory block increase value.
void throwZeroParameter(const Char *parameter)
Raises exception on zero parameter value.
char Char
Character type alias.
Definition String.h:36
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.