30 #ifndef LVR2_TYPES_VARIANTCHANNELMAP 31 #define LVR2_TYPES_VARIANTCHANNELMAP 33 #include <unordered_map> 42 template<
typename... T>
44 :
public std::unordered_map<std::string, VariantChannel<T...> >
49 using elem_type = std::pair<const key_type, val_type>;
65 template <std::
size_t N>
74 using pointer = std::shared_ptr<resolved_elem_type>;
79 typename base::iterator base_it,
80 typename base::iterator end_it)
94 m_base_it->second.template extract<U>()
103 m_base_it->second.template extract<U>()
129 inline bool operator==(
const typename base::iterator& rhs) noexcept
131 return m_base_it == rhs;
134 inline bool operator!=(
const typename base::iterator& rhs) noexcept
136 return m_base_it != rhs;
153 using pointer = std::shared_ptr<resolved_elem_type>;
158 typename base::const_iterator base_it,
159 typename base::const_iterator end_it)
173 m_base_it->second.template extract<U>()
182 m_base_it->second.template extract<U>()
208 inline bool operator==(
const typename base::const_iterator& rhs) noexcept
210 return m_base_it == rhs;
213 inline bool operator!=(
const typename base::const_iterator& rhs) noexcept
215 return m_base_it != rhs;
244 void add(
const std::string& name);
254 void add(
const std::string& name,
size_t numElements,
size_t width);
271 const Channel<U>&
get(
const std::string& name)
const;
286 int type(
const std::string& name)
const;
298 bool is_type(
const std::string& name)
const;
308 std::vector<std::string>
keys();
324 typename base::iterator it_base = this->begin();
325 typename base::iterator it_end = this->end();
332 typename base::const_iterator it_base = this->begin();
333 typename base::const_iterator it_end = this->end();
342 typename base::iterator it_base =
erase(it());
343 typename base::iterator it_end = this->end();
351 for(
auto vchannel: *
this)
353 cm.insert({vchannel.first, boost::apply_visitor(visitor, vchannel.second)});
366 std::cout <<
"[ VariantChannelMap ]\n";
369 std::cout << it.first <<
": " << it.second <<
"\n";
377 #include "VariantChannelMap.tcc" 379 #endif // LVR2_TYPES_VARIANTCHANNELMAP const_iterator(typename base::const_iterator base_it, typename base::const_iterator end_it)
int type(const std::string &name) const
Gets type index of a map entry.
iterator(typename base::iterator base_it, typename base::iterator end_it)
static constexpr std::size_t num_types
Access type index by type.
pointer operator->() const noexcept
bool operator!=(const typename base::iterator &rhs) noexcept
std::pair< const key_type &, const Channel< U > &> resolved_elem_type
std::unordered_map< std::string, VariantChannel< T... > > base
typename val_type::template type_of_index< N > type_of_index
base::iterator operator()() const noexcept
std::pair< const key_type, val_type > elem_type
pointer operator->() const noexcept
iterator< U > typedBegin()
Channel< U >::Optional getOptional(const std::string &name)
resolved_elem_type operator*() const noexcept
friend std::ostream & operator<<(std::ostream &os, const VariantChannelMap< T... > &cm)
Output cout.
base::const_iterator m_base_it
iterator< U > operator++(int) noexcept
const_iterator< U > typedBegin() const
void add(const std::string &name, Channel< U > channel)
Adds an Key + AttributeChannel to the map.
std::shared_ptr< resolved_elem_type > pointer
iterator< U > & operator++() noexcept
iterator< U > erase(iterator< U > it)
base::const_iterator m_end_it
const_iterator< U > & operator++() noexcept
base::iterator operator()() const noexcept
boost::optional< Channel< T > > Optional
resolved_elem_type operator*() const noexcept
std::pair< const key_type &, Channel< U > &> resolved_elem_type
bool is_type(const std::string &name) const
Checks if key has specific type U.
VariantChannelMap< T... > manipulate(V visitor)
std::shared_ptr< resolved_elem_type > pointer
std::vector< std::string > keys()
Gets the available keys by a specific type.
bool operator==(const typename base::iterator &rhs) noexcept
bool operator==(const typename base::const_iterator &rhs) noexcept
VariantChannelMap< T... > clone() const
static constexpr std::size_t num_types
const_iterator< U > operator++(int) noexcept
size_t numChannels()
Counts the number of channels by a specific type. For total number of channels use "size()"...
static constexpr std::size_t value
bool operator!=(const typename base::const_iterator &rhs) noexcept