minRecorder.h

00001 
00015 #ifndef DLR_NUMERIC_MINRECORDER_H
00016 #define DLR_NUMERIC_MINRECORDER_H
00017 
00018 #include <limits>
00019 
00020 namespace dlr {
00021 
00022   namespace numeric {
00023     
00029     template<class Type, class Payload>
00030     class MinRecorder {
00031     public:
00032 
00038       MinRecorder() : m_min(), m_payload() {this->reset();}
00039 
00040 
00045       MinRecorder(Type const& minValue, Payload const& payload)
00046         : m_min(minValue), m_payload(payload) {}
00047 
00048 
00064       bool
00065       test(const Type& value, const Payload& payload) {
00066         if(value < m_min) {
00067           m_min = value;
00068           m_payload = payload;
00069           return true;
00070         }
00071         return false;
00072       }
00073 
00074 
00082       const Type&
00083       getMin() {return m_min;}
00084 
00085 
00094       const Payload&
00095       getPayload() {return m_payload;}
00096 
00097 
00102       void
00103       reset() {
00104         m_min = std::numeric_limits<Type>::max();
00105       }
00106 
00107     private:
00108 
00109       Type m_min;
00110       Payload m_payload;
00111 
00112     };
00113     
00114   } // namespace numeric
00115 
00116 } // namespace dlr
00117 
00118 #endif // #ifdef DLR_NUMERIC_MINRECORDER_H

Generated on Wed Nov 25 00:42:42 2009 for dlrUtilities Utility Library by  doxygen 1.5.8