Go to the documentation of this file.
33 #if __GNUC__ < 5 && !defined(__clang__)
37 align(
size_t alignment,
size_t bytes,
void*& bufferPlace,
size_t& bufferSpace) noexcept
39 const auto uiptr =
reinterpret_cast<uintptr_t
>(bufferPlace);
40 const auto alignedPlace = (uiptr - 1u + alignment) & -alignment;
41 const auto spaceRequired = alignedPlace - uiptr;
42 if ((bytes + spaceRequired) > bufferSpace)
48 bufferSpace -= spaceRequired;
49 return bufferPlace =
reinterpret_cast<void*
>(alignedPlace);
64 return begin_ == current_;
70 return storage_ !=
nullptr;
76 return static_cast<const std::uint8_t*
>(end_) -
77 static_cast<const std::uint8_t*
>(current_);
83 return static_cast<const std::uint8_t*
>(end_) -
84 static_cast<const std::uint8_t*
>(begin_);
90 return static_cast<const std::uint8_t*
>(current_) -
91 static_cast<const std::uint8_t*
>(begin_);
116 storage_.reset(
new std::uint8_t[sz]);
117 begin_ =
static_cast<void*
>(storage_.get());
119 end_ =
static_cast<void*
>(storage_.get() + sz);
123 template <
class Derived>
129 "HeterogenousContinuousContainerBase::pushBack: Derived must derive Base");
132 void* ptr =
std::align(d->_alignof(), d->_sizeof(), current_, space_);
138 current_ =
static_cast<void*
>(
static_cast<std::uint8_t*
>(ptr) + d->_sizeof());
139 return d->_placementCopyConstruct(ptr);
149 std::unique_ptr<std::uint8_t[]> storage_{
nullptr};
150 void* begin_{
nullptr};
151 void* current_{
nullptr};
158 template <
class Base,
bool UsePropagateConst = true>
165 typename std::conditional<UsePropagateConst, PropagateConst<Base*>, Base*>::type;
171 bool compressElems =
false)
206 return elements_.size();
212 return elements_.capacity();
225 if (elements_.capacity() > cnt)
228 elements_ = std::vector<ElementType>{};
230 elements_.reserve(cnt);
233 template <
class Derived>
239 "HeterogenousContinuousContainerBase::pushBack: Derived must derive Base");
248 elements_.emplace_back(ptr);
253 template <
class Derived>
260 template <
class Derived>
267 std::vector<ElementType>&
273 const std::vector<ElementType>&
282 for (
auto& e : elements_)
291 std::vector<ElementType> elements_;
294 template <
class Base,
bool UsePropagateConst = true>
302 typename std::conditional<UsePropagateConst, PropagateConst<Base*>, Base*>::type;
308 bool compressElems =
false)
312 std::vector<std::size_t> elemCaps;
313 elemCaps.reserve(other.
elements().size());
314 for (
const auto& d1 : other.
elements())
316 elemCaps.emplace_back(compressElems ? d1.size() : d1.capacity());
319 for (std::size_t i = 0; i < other.
elements().size(); ++i)
321 for (
auto& e : other.
elements().at(i))
335 std::vector<std::size_t> elemCaps;
336 elemCaps.reserve(other.
elements().size());
337 for (
const auto& d1 : other.
elements())
339 elemCaps.emplace_back(d1.capacity());
342 for (std::size_t i = 0; i < other.
elements().size(); ++i)
344 for (
auto& e : other.
elements().at(i))
360 return elements_.at(d0).size();
366 return elements_.at(d0).capacity();
379 elements_.resize(cnt.size());
380 for (std::size_t i = 0; i < cnt.size(); ++i)
382 if (elements_.at(i).capacity() > cnt)
385 elements_.at(i) = std::vector<ElementType>{};
387 elements_.at(i).reserve(cnt.at(i));
391 template <
class Derived>
397 "HeterogenousContinuousContainerBase::pushBack: Derived must derive Base");
406 elements_.at(d0).emplace_back(ptr);
411 template <
class Derived>
418 template <
class Derived>
425 std::vector<std::vector<ElementType>>&
431 const std::vector<std::vector<ElementType>>&
440 for (
auto& d1 : elements_)
452 std::vector<std::vector<ElementType>> elements_;
const std::vector< ElementType > & elements() const
HeterogenousContinuousContainer()=default
std::size_t getElementCount() const
HeterogenousContinuousContainer & operator=(const HeterogenousContinuousContainer &other)
std::size_t getStorageCapacity() const
HeterogenousContinuousContainer & operator=(HeterogenousContinuousContainer &&)=default
void assignStorage(void *begin, void *end)
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
HeterogenousContinuous2DContainer & operator=(HeterogenousContinuous2DContainer &&)=default
HeterogenousContinuous2DContainer()=default
typename std::conditional< UsePropagateConst, PropagateConst< Base * >, Base * >::type ElementType
~HeterogenousContinuous2DContainer()
void * align(size_t alignment, size_t bytes, void *&bufferPlace, size_t &bufferSpace) noexcept
const std::vector< std::vector< ElementType > > & elements() const
Base * pushBack(std::size_t d0, const Derived &d)
~HeterogenousContinuousContainer()
Base * pushBack(std::size_t d0, const Derived *d)
std::size_t getElementCount(std::size_t d0) const
HeterogenousContinuous2DContainer(const HeterogenousContinuous2DContainer &other, bool compressElems=false)
std::shared_ptr< Value > value()
std::size_t getRemainingElementCapacity(std::size_t d0) const
Base * pushBack(const Derived *d)
HeterogenousContinuous2DContainer & operator=(const HeterogenousContinuous2DContainer &other)
std::vector< ElementType > & elements()
std::size_t getRemainingElementCapacity() const
Base * pushBack(const Derived *d)
Base * pushBack(std::size_t d0, const PropagateConst< Derived * > &d)
#define ARMARX_CHECK_LESS_EQUAL(lhs, rhs)
This macro evaluates whether lhs is less or equal (<=) rhs and if it turns out to be false it will th...
std::size_t getUsedStorageCapacity() const
std::size_t getElementCapacity() const
Base * pushBack(const Derived &d)
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
void setStorageCapacity(std::size_t sz)
HeterogenousContinuousContainer(const HeterogenousContinuousContainer &other, bool compressElems=false)
Base * pushBack(const PropagateConst< Derived * > &d)
std::vector< std::vector< ElementType > > & elements()
void setElementCapacity(const std::vector< std::size_t > &cnt)
typename std::conditional< UsePropagateConst, PropagateConst< Base * >, Base * >::type ElementType
std::size_t getRemainingStorageCapacity() const
std::size_t getElementCapacity(std::size_t d0) const
void setElementCapacity(std::size_t cnt)
This file offers overloads of toIce() and fromIce() functions for STL container types.
Wrapper for a pointer to propagate const to the pointed to value.