| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
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
19
20#ifndef FASTDDS_UTILS_COLLECTIONS__RESOURCELIMITEDCONTAINERCONFIG_HPP
21#define FASTDDS_UTILS_COLLECTIONS__RESOURCELIMITEDCONTAINERCONFIG_HPP
22
23#include <cstddef>
24#include <limits>
25
26 namespace eprosima {
27 namespace fastdds {
28
29#define dummy_avoid_winmax
30
35 struct ResourceLimitedContainerConfig
36{
37
38 ResourceLimitedContainerConfig(
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
60 inline static ResourceLimitedContainerConfig fixed_size_configuration(
61 size_t size)
62 {
63 return ResourceLimitedContainerConfig(size, size, 0u);
64 }
65
71 inline static ResourceLimitedContainerConfig dynamic_allocation_configuration(
72 size_t increment = 1u)
73 {
74 return ResourceLimitedContainerConfig(0u,
75 std::numeric_limits<size_t>::max dummy_avoid_winmax (), increment ? increment : 1u);
76 }
77
78};
79
80 inline bool operator == (
81 const ResourceLimitedContainerConfig& lhs,
82 const ResourceLimitedContainerConfig& rhs)
83{
84 return
85 lhs.maximum == rhs.maximum &&
86 lhs.initial == rhs.initial &&
87 lhs.increment == rhs.increment;
88}
89
90} // namespace fastdds
91} // namespace eprosima
92
93#endif // FASTDDS_UTILS_COLLECTIONS__RESOURCELIMITEDCONTAINERCONFIG_HPP
eprosima::fastdds
eprosima::fastdds::operator==
bool operator==(const ResourceLimitedContainerConfig &lhs, const ResourceLimitedContainerConfig &rhs)
Definition ResourceLimitedContainerConfig.hpp:80
eprosima
eProsima namespace.
eprosima::fastdds::ResourceLimitedContainerConfig
Specifies the configuration of a resource limited collection.
Definition ResourceLimitedContainerConfig.hpp:36
eprosima::fastdds::ResourceLimitedContainerConfig::dynamic_allocation_configuration
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
eprosima::fastdds::ResourceLimitedContainerConfig::increment
size_t increment
Number of items to add when capacity limit is reached.
Definition ResourceLimitedContainerConfig.hpp:53
eprosima::fastdds::ResourceLimitedContainerConfig::fixed_size_configuration
static ResourceLimitedContainerConfig fixed_size_configuration(size_t size)
Return a resource limits configuration for a fixed size collection.
Definition ResourceLimitedContainerConfig.hpp:60
eprosima::fastdds::ResourceLimitedContainerConfig::maximum
size_t maximum
Maximum number of elements allowed in the collection.
Definition ResourceLimitedContainerConfig.hpp:51
eprosima::fastdds::ResourceLimitedContainerConfig::initial
size_t initial
Number of elements to be preallocated in the collection.
Definition ResourceLimitedContainerConfig.hpp:49
eprosima::fastdds::ResourceLimitedContainerConfig::ResourceLimitedContainerConfig
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