Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef WEIGHTEDSAMPLE_H
00033 #define WEIGHTEDSAMPLE_H
00034
00035 #include "sample.h"
00036 #include <assert.h>
00037
00038
00039 namespace BFL
00040 {
00041
00048 template <typename T> class WeightedSample: virtual public Sample<T>
00049 {
00050 protected:
00052 double Weight;
00053
00054 public:
00056
00060 WeightedSample (int dimension = 0 );
00062 virtual ~WeightedSample();
00064 WeightedSample ( const WeightedSample<T> & my_weighted_sample );
00065
00067
00069 double WeightGet ( ) const;
00070
00072
00075 void WeightSet ( double weight );
00076
00078
00082 template <typename S> friend ostream & operator<< (ostream & stream,
00083 WeightedSample<S> & mws);
00084
00086 WeightedSample<T> & operator= (const WeightedSample<T> & my_sample);
00087
00089 WeightedSample<T> & operator= (const Sample<T> & my_sample);
00090 };
00091
00092
00093 template <typename T> WeightedSample<T>::WeightedSample(int dimension)
00094 : Sample<T>(dimension){}
00095
00096 template <typename T> WeightedSample<T>::~WeightedSample(){}
00097
00098 template <typename T> WeightedSample<T>::WeightedSample (const WeightedSample<T> & mws)
00099 : Sample<T>(mws)
00100 {
00101 Weight = mws.Weight;
00102 }
00103
00104 template <typename T> double WeightedSample<T>::WeightGet ( ) const
00105 {
00106 return Weight;
00107 }
00108
00109 template <typename T> void WeightedSample<T>::WeightSet ( double weight )
00110 {
00111 assert(weight >= 0);
00112
00113 Weight = weight;
00114 }
00115
00116 template <typename S> ostream & operator<< (ostream & stream,
00117 WeightedSample<S> & mws)
00118 {
00119 stream << "WeightedSample Value = " << (Sample<S> &) mws
00120 << "Weight = " << mws.Weight << endl;
00121 return stream;
00122 }
00123
00124 template <typename T> WeightedSample<T> & WeightedSample<T>::operator= (const WeightedSample<T> & my_sample)
00125 {
00126
00127
00128 Sample<T> * op1; const Sample<T> * op2;
00129 op1 = this; op2 = & my_sample;
00130 *op1 = *op2;
00131 this->Weight = my_sample.WeightGet();
00132 return *this;
00133 }
00134
00135
00136 template <typename T> WeightedSample<T> & WeightedSample<T>::operator= (const Sample<T> & my_sample)
00137 {
00138
00139 Sample<T> * op1; const Sample<T> * op2;
00140 op1 = this; op2 = & my_sample;
00141 *op1 = *op2;
00142 this->Weight = 1;
00143 return *this;
00144 }
00145
00146 }
00147
00148 #endif
bfl
Author(s): Klaas Gadeyne, Wim Meeussen, Tinne Delaet and many others. See web page for a full contributor list. ROS package maintained by Wim Meeussen.
autogenerated on Mon Feb 11 2019 03:45:12