Changeset 1537 for trunk/yat/utility/DataWeightProxy.h
- Timestamp:
- Sep 27, 2008, 12:37:33 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/DataWeightProxy.h
r1535 r1537 33 33 34 34 \brief Proxy class for DataWeight 35 36 DataIterator and WeightIterator should be a TrivialIterator 35 37 */ 38 template<typename DataIterator, typename WeightIterator> 36 39 class DataWeightProxy 37 40 { … … 40 43 \brief Default constructor 41 44 42 \param data data valueto hold43 \param weight weight valueto hold45 \param data iterator pointing to data to hold 46 \param weight iterator pointing to weight to hold 44 47 */ 45 DataWeightProxy(double& data, double& weight); 48 DataWeightProxy(DataIterator data, WeightIterator weight) 49 : data_(data), weight_(weight) {} 46 50 47 51 /** 48 52 \return reference to data 49 53 */ 50 double& data(void) ;54 double& data(void) { return *data_; } 51 55 52 56 /** 53 57 \return const reference to data 54 58 */ 55 const double& data(void) const ;59 const double& data(void) const { return *data_ ; } 56 60 57 61 /** 58 62 \return reference to weight 59 63 */ 60 double& weight(void) ;64 double& weight(void) { return *weight_; } 61 65 62 66 /** 63 67 \return const reference to weight 64 68 */ 65 const double& weight(void) const ;69 const double& weight(void) const { return *weight_; } 66 70 67 71 /** 68 72 \brief assignment operator 69 73 */ 70 DataWeightProxy& operator=(const DataWeight& rhs); 74 DataWeightProxy& operator=(const DataWeight& rhs) 75 { 76 data() = rhs.data(); 77 weight() = rhs.weight(); 78 return *this; 79 } 71 80 72 81 /** 73 82 \brief Conversion to DataWeight 74 83 */ 75 operator DataWeight() const ;84 operator DataWeight() const { return DataWeight(data(), weight()); } 76 85 77 86 private: 78 double&data_;79 double&weight_;87 DataIterator data_; 88 WeightIterator weight_; 80 89 81 // no copying82 DataWeightProxy(const DataWeightProxy&);83 DataWeightProxy& operator=(const DataWeightProxy&);90 // using compiler generated copy and assignment 91 //DataWeightProxy& operator=(const DataWeightProxy&); 92 //DataWeightProxy(const DataWeightProxy&); 84 93 }; 94 95 96 /** 97 \brief equality operator 98 */ 99 template<typename DataIterator, typename WeightIterator> 100 bool operator==(const DataWeightProxy<DataIterator, WeightIterator>& lhs, 101 const DataWeightProxy<DataIterator, WeightIterator>& rhs) 102 { 103 return lhs.data()==rhs.data() && lhs.weight()==rhs.weight(); 104 } 85 105 86 106 }}} // of namespace utility, yat, and theplu
Note: See TracChangeset
for help on using the changeset viewer.