Fast RTPS  Version 2.9.0
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 
29 #define dummy_avoid_winmax
30 
36 {
37 
39  size_t ini = 0,
40  size_t max = std::numeric_limits<size_t>::max dummy_avoid_winmax (),
41  size_t inc = 1u)
42  : initial(ini)
43  , maximum(max)
44  , increment(inc)
45  {
46  }
47 
49  size_t initial = 0;
51  size_t maximum = std::numeric_limits<size_t>::max dummy_avoid_winmax ();
53  size_t increment = 1u;
54 
61  size_t size)
62  {
63  return ResourceLimitedContainerConfig(size, size, 0u);
64  }
65 
72  size_t increment = 1u)
73  {
75  std::numeric_limits<size_t>::max dummy_avoid_winmax (), increment ? increment : 1u);
76  }
77 
78 };
79 
80 inline bool operator == (
83 {
84  return
85  lhs.maximum == rhs.maximum &&
86  lhs.initial == rhs.initial &&
87  lhs.increment == rhs.increment;
88 }
89 
90 } // namespace fastrtps
91 } // namespace eprosima
92 
93 #endif /* FASTRTPS_UTILS_COLLECTIONS_RESOURCELIMITEDCONTAINERCONFIG_HPP_ */
bool operator==(const ResourceLimitedContainerConfig &lhs, const ResourceLimitedContainerConfig &rhs)
Definition: ResourceLimitedContainerConfig.hpp:80
eProsima namespace.
Definition: LibrarySettingsAttributes.h:23
Specifies the configuration of a resource limited collection.
Definition: ResourceLimitedContainerConfig.hpp:36
static ResourceLimitedContainerConfig dynamic_allocation_configuration(size_t increment=1u)
Return a resource limits configuration for a linearly growing, dynamically allocated collection.
Definition: ResourceLimitedContainerConfig.hpp:71
size_t increment
Number of items to add when capacity limit is reached.
Definition: ResourceLimitedContainerConfig.hpp:53
static ResourceLimitedContainerConfig fixed_size_configuration(size_t size)
Return a resource limits configuration for a fixed size collection.
Definition: ResourceLimitedContainerConfig.hpp:60
size_t maximum
Maximum number of elements allowed in the collection.
Definition: ResourceLimitedContainerConfig.hpp:51
size_t initial
Number of elements to be preallocated in the collection.
Definition: ResourceLimitedContainerConfig.hpp:49
ResourceLimitedContainerConfig(size_t ini=0, size_t max=std::numeric_limits< size_t >::max dummy_avoid_winmax(), size_t inc=1u)
Definition: ResourceLimitedContainerConfig.hpp:38