libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
|
This container is an associative collection of types. The domain is a bit-map of the mapped_types that are selected in the range. More...
#include <bitfield_map.hpp>
Public Types | |
enum | : std::size_t |
enum | : bool |
using | key_type = uint64_t |
using | size_type = std::size_t |
using | mapped_types = BFSM |
The range of mapped-types that may be selected by the domain. This range is a collection that is indexed by the unique enum-tag of the range. More... | |
using | bitfields_tags_type = typename boost::mpl::deref< typename boost::mpl::begin< mapped_types >::type >::type::first::value_type |
The range of enum-tags used to indicate the requested element in the mapped_types range. More... | |
using | underlying_key_type = typename std::underlying_type< bitfields_tags_type >::type |
The underlying type of the domain enum. More... | |
using | raw_mapped_data_t = std::array< uint8_t, range_mapped_types_size > |
Public Member Functions | |
BOOST_MPL_ASSERT ((std::is_pod< bitfields_tags_type >)) | |
BOOST_MPL_ASSERT ((std::is_integral< typename std::underlying_type< bitfields_tags_type >::type >)) | |
BOOST_MPL_ASSERT_RELATION (sizeof(bitfields_tags_type),<=, sizeof(key_type)) | |
BOOST_MPL_ASSERT_RELATION (sizeof(underlying_key_type),==, sizeof(bitfields_tags_type)) | |
BOOST_MPL_ASSERT_RELATION (range_mapped_types_size, >, 0) | |
BOOST_MPL_ASSERT_RELATION (boost::mpl::empty< mapped_types >::value, !=, true) | |
constexpr | bitfield_map () noexcept(true) FORCE_INLINE |
Default-construct an empty container. More... | |
constexpr | bitfield_map (bitfield_map const &) noexcept(true) FORCE_INLINE |
Bit-wise copy the contents of the argument into the constructed container, out of the argument. More... | |
constexpr | bitfield_map (bitfield_map &&) noexcept(true) FORCE_INLINE |
~bitfield_map () noexcept(true) FORCE_INLINE | |
constexpr bitfield_map & | operator= (bitfield_map &&) noexcept(true) FORCE_INLINE |
Bit-wise swap the contents of the container with that of the argument. More... | |
constexpr bool | empty () const noexcept(true) FORCE_INLINE |
Indicate if there are any elements selected in the mapped_types. More... | |
constexpr size_type | size () const noexcept(true) FORCE_INLINE |
Indicate the total size of any elements selected in the mapped_types, including the size of the domain bitfield. More... | |
constexpr void | clear () noexcept(true) FORCE_INLINE |
Erase each enabled mapped_types selected in the key_type. More... | |
template<bitfields_tags_type SelectedField, class AsType = typename std::integral_constant<bitfields_tags_type, SelectedField>::type, class Ret = typename boost::mpl::at<mapped_types, AsType>::type> | |
constexpr const Ret & | at () const noexcept(false) FORCE_INLINE |
Perform a range-checked selection of the requested element. More... | |
template<bitfields_tags_type SelectedField, class AsType = typename std::integral_constant<bitfields_tags_type, SelectedField>::type, class Ret = typename boost::mpl::at<mapped_types, AsType>::type> | |
constexpr Ret & | at () noexcept(false) FORCE_INLINE |
Perform a range-checked selection of the requested element. More... | |
template<bitfields_tags_type SelectedField, class AsType = typename std::integral_constant<bitfields_tags_type, SelectedField>::type, class Ret = typename boost::mpl::at<mapped_types, AsType>::type> | |
void | erase () noexcept(true) FORCE_INLINE |
Remove and delete the SelectedField element, if enabled, from the mapped_types range. More... | |
template<bitfields_tags_type SelectedField> | |
bool | find () const noexcept(true) FORCE_INLINE |
Find if the SelectedField is enabled in the key_type,. More... | |
template<bitfields_tags_type SelectedField, class AsType = typename std::integral_constant<bitfields_tags_type, SelectedField>::type, class Arg = typename boost::mpl::at<mapped_types, AsType>::type> | |
void | push_back (Arg const &) noexcept(false) FORCE_INLINE |
Enable the SelectedField in the key_type, and initialise the appropriate element in the mapped_types, if necessary,. More... | |
constexpr void | swap (bitfield_map &) noexcept(true) FORCE_INLINE |
Bit-wise swap the contents of the container with that of the argument. More... | |
Static Public Member Functions | |
static constexpr size_type | max_size () noexcept(true) FORCE_INLINE |
Indicate the maximum size of all elements that can be selected in the mapped_types, including the size of the domain bitfield. More... | |
Public Attributes | |
enum jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map:: { ... } | __attribute__ |
This container is an associative collection of types. The domain is a bit-map of the mapped_types that are selected in the range.
This container packs a selection of objects of the types that are given in mapped_types into an internal buffer of contiguous memory. If few types are selected, then the size() returns much less than the size of the object (which must be large enough to holds all of the mapped_types). It could be useful for passing assorted large mapped_types along a slow network link, when, usually, not all are needed. Note that the types placed in mapped_types must be able to support arbitrary alignment - no guarantee of correct alignment is made by this class. These types are packed into the internal buffer such that there is no padding used, hence no guarantee of correct alignment. This restriction implies that only PODs are likely to be supported, in general.
Definition at line 60 of file bitfield_map.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::bitfields_tags_type = typename boost::mpl::deref<typename boost::mpl::begin<mapped_types>::type>::type::first::value_type |
The range of enum-tags used to indicate the requested element in the mapped_types range.
Definition at line 65 of file bitfield_map.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::key_type = uint64_t |
Definition at line 62 of file bitfield_map.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::mapped_types = BFSM |
The range of mapped-types that may be selected by the domain. This range is a collection that is indexed by the unique enum-tag of the range.
Definition at line 64 of file bitfield_map.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::raw_mapped_data_t = std::array<uint8_t, range_mapped_types_size> |
Definition at line 87 of file bitfield_map.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::size_type = std::size_t |
Definition at line 63 of file bitfield_map.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::underlying_key_type = typename std::underlying_type<bitfields_tags_type>::type |
The underlying type of the domain enum.
Definition at line 66 of file bitfield_map.hpp.
anonymous enum : std::size_t |
Definition at line 77 of file bitfield_map.hpp.
anonymous enum : bool |
Definition at line 93 of file bitfield_map.hpp.
|
inlineconstexprnoexcept |
Default-construct an empty container.
Algorithmic complexity: O(1) Post-condition: empty()==true.
Definition at line 295 of file bitfield_map_impl.hpp.
|
inlineconstexprnoexcept |
Bit-wise copy the contents of the argument into the constructed container, out of the argument.
Algorithmic complexity: O(sizeof(range of mapped_types)) Post-condition: bm.empty()==true.
Definition at line 323 of file bitfield_map_impl.hpp.
|
inlineconstexprnoexcept |
Algorithmic complexity: O(sizeof(range of mapped_types)) Post-condition: bm.empty()==true.
Definition at line 331 of file bitfield_map_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::swap().
|
inlinenoexcept |
Algorithmic complexity: POD: O(1) otherwise O(sizeof(key_type)^2)
Definition at line 350 of file bitfield_map_impl.hpp.
|
inlineconstexprnoexcept |
Perform a range-checked selection of the requested element.
Algorithmic complexity: O(sizeof(key_type)) Pre-condition: empty()==false.
Definition at line 387 of file bitfield_map_impl.hpp.
|
inlineconstexprnoexcept |
Perform a range-checked selection of the requested element.
Algorithmic complexity: O(sizeof(key_type)) Pre-condition: empty()==false.
Definition at line 394 of file bitfield_map_impl.hpp.
jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::BOOST_MPL_ASSERT | ( | (std::is_integral< typename std::underlying_type< bitfields_tags_type >::type >) | ) |
Make sure the funky mpl actually finds something that is integral so could be an enumeration...
jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::BOOST_MPL_ASSERT | ( | (std::is_pod< bitfields_tags_type >) | ) |
Make sure the funky mpl actually finds something that is POD-like so could be an enumeration...
jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::BOOST_MPL_ASSERT_RELATION | ( | boost::mpl::empty< mapped_types >::value | , |
! | , | ||
true | |||
) |
jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::BOOST_MPL_ASSERT_RELATION | ( | range_mapped_types_size | , |
0 | |||
) |
jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::BOOST_MPL_ASSERT_RELATION | ( | sizeof(bitfields_tags_type) | , |
<= | , | ||
sizeof(key_type) | |||
) |
jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::BOOST_MPL_ASSERT_RELATION | ( | sizeof(underlying_key_type) | , |
sizeof(bitfields_tags_type) | |||
) |
|
inlineconstexprnoexcept |
Erase each enabled mapped_types selected in the key_type.
Algorithmic complexity: POD: O(1) otherwise O(sizeof(key_type)^2) Post-condition: empty()==true.
Definition at line 339 of file bitfield_map_impl.hpp.
|
inlineconstexprnoexcept |
Indicate if there are any elements selected in the mapped_types.
Algorithmic complexity: O(1) Invariant: emply() iff size()==0
Definition at line 363 of file bitfield_map_impl.hpp.
|
inlinenoexcept |
Remove and delete the SelectedField element, if enabled, from the mapped_types range.
Note: this is not a generic erase, items should only be erased from the end of the collection, otherwise undefined behaviour will result. This should really be considered a pop_back() operation, where the end iterator is manually specified. Not ideal. No compaction of the mapped_types is performed after an erase, so if holes were left, this would cause the at() operations to behave incorrectly. Algorithmic complexity: POD: O(1) otherwise O(sizeof(key_type)) Pre-condition: SelectedField is the last enabled bit in the key_type.
Definition at line 401 of file bitfield_map_impl.hpp.
|
inlinenoexcept |
Find if the SelectedField is enabled in the key_type,.
Algorithmic complexity: O(1)
Definition at line 413 of file bitfield_map_impl.hpp.
|
inlinestaticconstexprnoexcept |
Indicate the maximum size of all elements that can be selected in the mapped_types, including the size of the domain bitfield.
Algorithmic complexity: O(1) Invariant: size()<=max_size()
Definition at line 380 of file bitfield_map_impl.hpp.
|
inlineconstexprnoexcept |
Bit-wise swap the contents of the container with that of the argument.
Algorithmic complexity: O(sizeof(range of mapped_types))
Definition at line 356 of file bitfield_map_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::swap().
|
inlinenoexcept |
Enable the SelectedField in the key_type, and initialise the appropriate element in the mapped_types, if necessary,.
Note: This only works going from smaller to larger tags in the key_type, one must not insert in the middle, otherwise this may result in undefined behaviour. This is because of the internally-computed offsets into the range of mapped_types. Hence one must not insert randomly: it is likely that existing contents will be incorrectly overwritten, also leading to undefined behaviour. Algorithmic complexity: O(sizeof(key_type)) Post-condition: empty()==false.
Definition at line 424 of file bitfield_map_impl.hpp.
|
inlineconstexprnoexcept |
Indicate the total size of any elements selected in the mapped_types, including the size of the domain bitfield.
Algorithmic complexity: O(sizeof(key_type)) Invariant: size()<=max_size()
Definition at line 369 of file bitfield_map_impl.hpp.
|
inlineconstexprnoexcept |
Bit-wise swap the contents of the container with that of the argument.
Algorithmic complexity: O(sizeof(range of mapped_types))
Definition at line 314 of file bitfield_map_impl.hpp.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::bitfield_map(), and jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::operator=().
jmmcg::LIBJMMCG_VER_NAMESPACE::bitfield_map< BFSM, BFSz >::__attribute__ { ... } enum |