AttributeMap.hpp
Go to the documentation of this file.
1 
28 /*
29  * AttributeMap.hpp
30  *
31  * @date 26.07.2017
32  */
33 
34 #ifndef LVR2_ATTRMAPS_ATTRIBUTEMAP_H_
35 #define LVR2_ATTRMAPS_ATTRIBUTEMAP_H_
36 
37 #include <boost/optional.hpp>
38 #include <memory>
39 
41 
42 namespace lvr2
43 {
44 
45 // Forward declarations
46 template<typename> class AttributeMapHandleIteratorPtr;
47 
74 template<typename HandleT, typename ValueT>
76 {
77  static_assert(
78  std::is_base_of<BaseHandle<Index>, HandleT>::value,
79  "HandleT must inherit from BaseHandle!"
80  );
81 
82 public:
84  typedef HandleT HandleType;
85 
87  typedef ValueT ValueType;
88 
93  virtual bool containsKey(HandleT key) const = 0;
94 
102  virtual boost::optional<ValueT> insert(HandleT key, const ValueT& value) = 0;
103 
110  virtual boost::optional<ValueT> erase(HandleT key) = 0;
111 
115  virtual void clear() = 0;
116 
124  virtual boost::optional<ValueT&> get(HandleT key) = 0;
125 
133  virtual boost::optional<const ValueT&> get(HandleT key) const = 0;
134 
138  virtual size_t numValues() const = 0;
139 
151  virtual AttributeMapHandleIteratorPtr<HandleT> begin() const = 0;
152 
156  virtual AttributeMapHandleIteratorPtr<HandleT> end() const = 0;
157 
166  ValueT& operator[](HandleT key);
167 
176  const ValueT& operator[](HandleT key) const;
177 };
178 
179 
186 template<typename HandleT>
188 {
189  static_assert(
190  std::is_base_of<BaseHandle<Index>, HandleT>::value,
191  "HandleT must inherit from BaseHandle!"
192  );
193 
194 public:
197  virtual AttributeMapHandleIterator& operator++() = 0;
198  virtual bool operator==(const AttributeMapHandleIterator& other) const = 0;
199  virtual bool operator!=(const AttributeMapHandleIterator& other) const = 0;
200 
202  virtual HandleT operator*() const = 0;
203  virtual std::unique_ptr<AttributeMapHandleIterator> clone() const = 0;
204 
205  virtual ~AttributeMapHandleIterator() = default;
206 };
207 
214 template<typename HandleT>
216 {
217  static_assert(
218  std::is_base_of<BaseHandle<Index>, HandleT>::value,
219  "HandleT must inherit from BaseHandle!"
220  );
221 
222 public:
224  : m_iter(std::move(iter)) {}
226  : m_iter(iteratorPtr.m_iter->clone()) {}
227 
229  bool operator==(const AttributeMapHandleIteratorPtr& other) const;
230  bool operator!=(const AttributeMapHandleIteratorPtr& other) const;
231  HandleT operator*() const;
232 
233  virtual ~AttributeMapHandleIteratorPtr() = default;
234 
235 private:
236  std::unique_ptr<AttributeMapHandleIterator<HandleT>> m_iter;
237 };
238 
239 } // namespace lvr2
240 
241 #include "lvr2/attrmaps/AttributeMap.tcc"
242 
243 #endif /* LVR2_ATTRMAPS_ATTRIBUTEMAP_H_ */
Handles.hpp
lvr2::AttributeMap::containsKey
virtual bool containsKey(HandleT key) const =0
Returns true iff the map contains a value associated with the given key.
lvr2::AttributeMap
Interface for attribute maps.
Definition: AttributeMap.hpp:75
lvr2::AttributeMapHandleIterator::operator==
virtual bool operator==(const AttributeMapHandleIterator &other) const =0
lvr2::BaseHandle< Index >
lvr2::AttributeMap::HandleType
HandleT HandleType
The type of the handle used as key in this map.
Definition: AttributeMap.hpp:80
lvr2::AttributeMapHandleIterator::operator++
virtual AttributeMapHandleIterator & operator++()=0
lvr2::AttributeMap::insert
virtual boost::optional< ValueT > insert(HandleT key, const ValueT &value)=0
Inserts the given value at the given key position.
lvr2::AttributeMapHandleIteratorPtr::AttributeMapHandleIteratorPtr
AttributeMapHandleIteratorPtr(std::unique_ptr< AttributeMapHandleIterator< HandleT >> iter)
Definition: AttributeMap.hpp:223
lvr2::AttributeMap::ValueType
ValueT ValueType
The type of the value stored in this map.
Definition: AttributeMap.hpp:87
lvr2::AttributeMapHandleIteratorPtr::operator==
bool operator==(const AttributeMapHandleIteratorPtr &other) const
lvr2::AttributeMapHandleIterator
Iterator over keys of an attribute map.
Definition: AttributeMap.hpp:187
lvr2::AttributeMapHandleIteratorPtr::operator*
HandleT operator*() const
lvr2::AttributeMap::begin
virtual AttributeMapHandleIteratorPtr< HandleT > begin() const =0
Returns an iterator over all keys of this map. The order of iteration is unspecified.
lvr2::AttributeMapHandleIteratorPtr::~AttributeMapHandleIteratorPtr
virtual ~AttributeMapHandleIteratorPtr()=default
lvr2::AttributeMapHandleIteratorPtr::operator!=
bool operator!=(const AttributeMapHandleIteratorPtr &other) const
lvr2::AttributeMap::numValues
virtual size_t numValues() const =0
Returns the number of values in this map.
lvr2::AttributeMapHandleIterator::~AttributeMapHandleIterator
virtual ~AttributeMapHandleIterator()=default
lvr2::AttributeMapHandleIterator::operator!=
virtual bool operator!=(const AttributeMapHandleIterator &other) const =0
lvr2::AttributeMapHandleIterator::clone
virtual std::unique_ptr< AttributeMapHandleIterator > clone() const =0
lvr2::AttributeMapHandleIteratorPtr::AttributeMapHandleIteratorPtr
AttributeMapHandleIteratorPtr(const AttributeMapHandleIteratorPtr &iteratorPtr)
Definition: AttributeMap.hpp:225
lvr2::AttributeMapHandleIteratorPtr::m_iter
std::unique_ptr< AttributeMapHandleIterator< HandleT > > m_iter
Definition: AttributeMap.hpp:236
std
Definition: HalfEdge.hpp:124
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::AttributeMapHandleIteratorPtr::operator++
AttributeMapHandleIteratorPtr & operator++()
lvr2::AttributeMap::erase
virtual boost::optional< ValueT > erase(HandleT key)=0
Removes the value associated with the given key.
lvr2::AttributeMap::get
virtual boost::optional< ValueT & > get(HandleT key)=0
Returns the value associated with the given key or None if there is no associated value.
lvr2::AttributeMapHandleIterator::operator*
virtual HandleT operator*() const =0
Returns the current handle.
lvr2::AttributeMap::end
virtual AttributeMapHandleIteratorPtr< HandleT > end() const =0
Returns an iterator to the end of all keys.
lvr2::AttributeMapHandleIteratorPtr
Simple convinience wrapper for unique_ptr<AttributeMapHandleIterator>
Definition: AttributeMap.hpp:46
lvr2::AttributeMap::clear
virtual void clear()=0
Removes all values from the map.
lvr2::AttributeMap::operator[]
ValueT & operator[](HandleT key)
Returns the value associated with the given key or panics if there is no associated value.


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:22