00001 #ifndef _theplu_yat_utility_data_weight_proxy_ 00002 #define _theplu_yat_utility_data_weight_proxy_ 00003 00004 // $Id: DataWeightProxy.h 2198 2010-02-18 05:13:20Z peter $ 00005 00006 /* 00007 Copyright (C) 2008 Jari Häkkinen, Peter Johansson 00008 Copyright (C) 2009, 2010 Peter Johansson 00009 00010 This file is part of the yat library, http://dev.thep.lu.se/yat 00011 00012 The yat library is free software; you can redistribute it and/or 00013 modify it under the terms of the GNU General Public License as 00014 published by the Free Software Foundation; either version 3 of the 00015 License, or (at your option) any later version. 00016 00017 The yat library is distributed in the hope that it will be useful, 00018 but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 General Public License for more details. 00021 00022 You should have received a copy of the GNU General Public License 00023 along with yat. If not, see <http://www.gnu.org/licenses/>. 00024 */ 00025 00026 #include "DataWeight.h" 00027 00028 namespace theplu { 00029 namespace yat { 00030 namespace utility { 00031 00039 template<typename DataIterator, typename WeightIterator> 00040 class DataWeightProxy 00041 { 00042 public: 00049 DataWeightProxy(DataIterator data, WeightIterator weight) 00050 : data_(data), weight_(weight) {} 00051 00055 //typename std::iterator_traits<DataWeight>::reference data(void) const 00056 double& data(void) { return *data_; } 00057 00061 const double& data(void) const { return *data_ ; } 00062 00066 double& weight(void) { return *weight_; } 00067 00071 const double& weight(void) const { return *weight_; } 00072 00076 DataWeightProxy& operator=(const DataWeightProxy& rhs) 00077 { 00078 data() = rhs.data(); 00079 weight() = rhs.weight(); 00080 return *this; 00081 } 00082 00086 DataWeightProxy& operator=(const DataWeight& rhs) 00087 { 00088 data() = rhs.data(); 00089 weight() = rhs.weight(); 00090 return *this; 00091 } 00092 00096 operator DataWeight() const 00097 { return DataWeight(this->data(), this->weight()); } 00098 00099 private: 00100 DataIterator data_; 00101 WeightIterator weight_; 00102 00103 // using compiler generated copy and assignment 00104 //DataWeightProxy& operator=(const DataWeightProxy&); 00105 //DataWeightProxy(const DataWeightProxy&); 00106 }; 00107 00108 }}} // of namespace utility, yat, and theplu 00109 00110 #endif