Fast RTPS  Version 2.4.1
Fast RTPS
ResourceLimitedContainerConfig.hpp
1 // Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
20 #ifndef FASTRTPS_UTILS_COLLECTIONS_RESOURCELIMITEDCONTAINERCONFIG_HPP_
21 #define FASTRTPS_UTILS_COLLECTIONS_RESOURCELIMITEDCONTAINERCONFIG_HPP_
22 
23 #include <cstddef>
24 #include <limits>
25 
26 namespace eprosima {
27 namespace fastrtps {
28 
34 {
35 
37  size_t ini = 0,
38  size_t max = (std::numeric_limits<size_t>::max)(),
39  size_t inc = 1u)
40  : initial(ini)
41  , maximum(max)
42  , increment(inc)
43  {
44  }
45 
47  size_t initial = 0;
49  size_t maximum = (std::numeric_limits<size_t>::max)();
51  size_t increment = 1u;
52 
59  size_t size)
60  {
61  return ResourceLimitedContainerConfig(size, size, 0u);
62  }
63 
70  size_t increment = 1u)
71  {
72  return ResourceLimitedContainerConfig(0u, (std::numeric_limits<size_t>::max)(), increment ? increment : 1u);
73  }
74 
75 };
76 
77 inline bool operator == (
80 {
81  return
82  lhs.maximum == rhs.maximum &&
83  lhs.initial == rhs.initial &&
84  lhs.increment == rhs.increment;
85 }
86 
87 } // namespace fastrtps
88 } // namespace eprosima
89 
90 #endif /* FASTRTPS_UTILS_COLLECTIONS_RESOURCELIMITEDCONTAINERCONFIG_HPP_ */
bool operator==(const ResourceLimitedContainerConfig &lhs, const ResourceLimitedContainerConfig &rhs)
Definition: ResourceLimitedContainerConfig.hpp:77
eProsima namespace.
Definition: LibrarySettingsAttributes.h:23
Specifies the configuration of a resource limited collection.
Definition: ResourceLimitedContainerConfig.hpp:34
static ResourceLimitedContainerConfig dynamic_allocation_configuration(size_t increment=1u)
Return a resource limits configuration for a linearly growing, dynamically allocated collection.
Definition: ResourceLimitedContainerConfig.hpp:69
size_t increment
Number of items to add when capacity limit is reached.
Definition: ResourceLimitedContainerConfig.hpp:51
static ResourceLimitedContainerConfig fixed_size_configuration(size_t size)
Return a resource limits configuration for a fixed size collection.
Definition: ResourceLimitedContainerConfig.hpp:58
size_t maximum
Maximum number of elements allowed in the collection.
Definition: ResourceLimitedContainerConfig.hpp:49
ResourceLimitedContainerConfig(size_t ini=0, size_t max=(std::numeric_limits< size_t >::max)(), size_t inc=1u)
Definition: ResourceLimitedContainerConfig.hpp:36
size_t initial
Number of elements to be preallocated in the collection.
Definition: ResourceLimitedContainerConfig.hpp:47