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 
228  AttributeMapHandleIteratorPtr& operator++();
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_ */
virtual void clear()=0
Removes all values from the map.
AttributeMapHandleIteratorPtr(const AttributeMapHandleIteratorPtr &iteratorPtr)
virtual AttributeMapHandleIteratorPtr< HandleT > begin() const =0
Returns an iterator over all keys of this map. The order of iteration is unspecified.
virtual size_t numValues() const =0
Returns the number of values in this map.
Simple convinience wrapper for unique_ptr<AttributeMapHandleIterator>
Iterator over keys of an attribute map.
AttributeMapHandleIteratorPtr(std::unique_ptr< AttributeMapHandleIterator< HandleT >> iter)
ValueT ValueType
The type of the value stored in this map.
std::unique_ptr< AttributeMapHandleIterator< HandleT > > m_iter
virtual boost::optional< ValueT > insert(HandleT key, const ValueT &value)=0
Inserts the given value at the given key position.
virtual boost::optional< ValueT > erase(HandleT key)=0
Removes the value associated with the given key.
Interface for attribute maps.
virtual AttributeMapHandleIteratorPtr< HandleT > end() const =0
Returns an iterator to the end of all keys.
ValueT & operator[](HandleT key)
Returns the value associated with the given key or panics if there is no associated value...
virtual bool containsKey(HandleT key) const =0
Returns true iff the map contains a value associated with the given key.
BaseVector< CoordType > operator*(const Eigen::Matrix< Scalar, 4, 4 > &mat, const BaseVector< CoordType > &normal)
Multiplication operator to support transformation with Eigen matrices. Rotates the normal...
Definition: BaseVector.hpp:249
HandleT HandleType
The type of the handle used as key in this map.


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 Mon Feb 28 2022 22:46:06