-
Notifications
You must be signed in to change notification settings - Fork 6
/
CollectionConfig.hpp
140 lines (123 loc) · 3.84 KB
/
CollectionConfig.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */
#ifndef FIFTYONE_DEGREES_COLLECTION_CONFIG_HPP
#define FIFTYONE_DEGREES_COLLECTION_CONFIG_HPP
#include "Exceptions.hpp"
#include "collection.h"
namespace FiftyoneDegrees {
namespace Common {
/**
* C++ class wrapper for the #fiftyoneDegreesCollectionConfig structure.
* See collection.h.
*
* Configuration options are set using setter methods and fetched using
* corresponding getter methods. The names are self explanatory.
*
* ## Usage Example
*
* ```
* FiftyoneDegrees::Common::CollectionConfig *config;
*
* // Configure a collection with a capacity of 100, with 20 preloaded
* // items, which can be used by 4 threads concurrently
* config->setCapacity(100);
* config->setLoaded(20);
* config->setConcurrency(4);
* ```
*/
class CollectionConfig {
public:
/**
* @name Constructors
* @{
*/
/**
* Construct a new instance of CollectionConfig with the default
* configuration. This method does not set the internal config
* structure, so an extending class must do this if calling this
* constructor.
*/
CollectionConfig();
/**
* Construct a new instance of CollectionConfig which references an
* existing instance of the C structure.
* @param config pointer to existing collection configuration
* structure
*/
CollectionConfig(fiftyoneDegreesCollectionConfig *config);
/**
* @}
* @name Setters
* @{
*/
/**
* Set the number of items the cache should store, 0 for no cache.
* @param capacity to set
*/
void setCapacity(uint32_t capacity);
/**
* Set the expected number of concurrent requests.
* @param concurrency to set
*/
void setConcurrency(uint16_t concurrency);
/**
* Set the number of items to load into memory from the start of
* the collection.
* @param loaded to set
*/
void setLoaded(uint32_t loaded);
/**
* @}
* @name Getters
* @{
*/
/**
* Get the number of items the cache should store, 0 for no cache.
* @return capacity value
*/
uint32_t getCapacity() const;
/**
* Get the expected number of concurrent requests.
* @return concurrency value
*/
uint16_t getConcurrency() const;
/**
* Get the number of items to load into memory from the start of
* the collection.
* @return loaded value
*/
uint32_t getLoaded() const;
/**
* Get a pointer to the underlying configuration structure.
* @return C structure pointer
*/
fiftyoneDegreesCollectionConfig* getConfig() const;
/**
* @}
*/
private:
/** Pointer to the underlying C configuration structure. */
fiftyoneDegreesCollectionConfig *config;
};
}
}
#endif