aimstil  5.0.5
accessors.h
Go to the documentation of this file.
1 #ifndef TIL_ACCESSORS_H_
2 #define TIL_ACCESSORS_H_
3 
12 
13 
14 namespace til {
16 namespace xsr
17 {
18 
19  //-------------------------------------------------------------------------------------
20 
21  //------------------//
22  // Integer_access //
23  //------------------//
24 
26  // TODO: add requirement that TCollection is random-access.
27  template < typename TCollection, typename TIndex = std::size_t >
29  {
30  public: // typedefs
31  typedef TIndex index_type;
32  typedef typename TCollection::value_type value_type;
33  typedef typename TCollection::reference reference;
34  typedef typename TCollection::const_reference const_reference;
35 
36  public: // constructors
37 
38  // NB: Actually, it can be quite comfortable to have it non explicit. We can pass collections rather
39  // than constructing explicitely an accessor.
40  Integer_access(TCollection & data) : m_data(data) {}
41 
42  public: // operators
43  reference operator()(index_type i) { return m_data[i]; }
44  const_reference operator()(index_type i) const { return m_data[i]; }
45  private: // data
46  TCollection & m_data;
47  };
48 
49  //-------------------------------------------------------------------------------------
50 
51  /*
52  template < typename TReference, typename TValueType = naked_type<TReference>::type >
53  struct GetVertexField
54  {
55  typedef TValueType value_type;
56  typedef TReference reference;
57  template < typename TIterator >
58  static TResult get(TIterator i) { return i->vertex(); }
59  };
60  */
61 
62 
63  //-------------------------------------------------------------------------------------
64 
65  //-------------------//
66  // Iterator_access //
67  //-------------------//
68 
70  template < typename TIterator > //, typename Getter >
72  {
73  public: // typedefs
74  typedef typename TIterator::value_type value_type;
75  typedef TIterator index_type;
76  public: // static accessors
77  value_type & operator()(index_type i) const
78  { return *i; }
79  };
80 
81 
82 }} // namespace til::xsr
83 
84 #endif /*ACCESSORS_H_*/
Integer_access(TCollection &data)
Definition: accessors.h:40
const_reference operator()(index_type i) const
Definition: accessors.h:44
TIterator::value_type value_type
Definition: accessors.h:74
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
Integer access over a random-access container.
Definition: accessors.h:28
Return value pointed at by an iterator.
Definition: accessors.h:71
TCollection::reference reference
Definition: accessors.h:33
TCollection::const_reference const_reference
Definition: accessors.h:34
TCollection::value_type value_type
Definition: accessors.h:32
reference operator()(index_type i)
Definition: accessors.h:43
value_type & operator()(index_type i) const
Definition: accessors.h:77