trsl logo
weight_accessor.hpp
Go to the documentation of this file.
1 // (C) Copyright Renaud Detry 2007-2011.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 
8 #ifndef TRSL_WEIGHT_ACCESSOR_HPP
9 #define TRSL_WEIGHT_ACCESSOR_HPP
10 
11 namespace trsl {
12 
22  template<typename WeightType, typename ElementType>
24  {
30  WeightType operator()(ElementType const& e) const
31  {
32  return 1;
33  // You can create your own accessor by copying this class
34  // and returning something like
35  // return e.getWeight();
36  }
37  };
38 
60  template<typename WeightType, typename ElementType>
62  {
63  public:
65  typedef WeightType (ElementType::*WeightAccessorMethodPointer)() const;
66 
71  wptr_(NULL) {}
72 
81  wptr_(wptr) {}
82 
88  WeightType operator()(ElementType const& e) const
89  {
90  if (wptr_ == NULL)
91  return 1;
92  return (e.*wptr_)();
93  }
94  private:
96  };
97 
98 }
99 
100 #endif // include guard
trsl::weight_accessor::operator()
WeightType operator()(ElementType const &e) const
Functor implementation.
Definition: weight_accessor.hpp:30
trsl
Public namespace.
Definition: common.hpp:29
trsl::mp_weight_accessor
Method Pointer weight accessor.
Definition: weight_accessor.hpp:61
trsl::mp_weight_accessor::mp_weight_accessor
mp_weight_accessor(WeightAccessorMethodPointer wptr)
Constructor from a WeightAccessorMethodPointer.
Definition: weight_accessor.hpp:80
trsl::mp_weight_accessor::mp_weight_accessor
mp_weight_accessor()
Default constructor, accessor will return 1 all the time.
Definition: weight_accessor.hpp:70
trsl::weight_accessor
Weight accessor that always returns 1.
Definition: weight_accessor.hpp:23
trsl::mp_weight_accessor::WeightAccessorMethodPointer
WeightType(ElementType::* WeightAccessorMethodPointer)() const
Pointer to a const method of ElementType that returns double.
Definition: weight_accessor.hpp:65
trsl::mp_weight_accessor::operator()
WeightType operator()(ElementType const &e) const
Functor implementation.
Definition: weight_accessor.hpp:88
© Copyright 2007-2011 Renaud Detry.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt.)
Revised Wed Jan 8 2020 14:43:31.