00001
00002 #ifndef DDF_MEASUREITEM_HPP
00003 #define DDF_MEASUREITEM_HPP
00004
00005 #include <iostream>
00006 #include "ddf/definitions.hpp"
00007 #include "ddf/ctime.hpp"
00008 #include "ddf/debugging.hpp"
00009
00010 namespace jafar
00011 {
00012 namespace ddfsimu
00013 {
00014 using namespace jafar::ddf;
00015
00020 class MeasureItem{
00021
00022 VEC m_data;
00023 time m_sensed;
00024 time m_available;
00025
00026 public:
00027
00028 MeasureItem(unsigned short size);
00029 MeasureItem(MeasureItem const& item);
00030 ~MeasureItem();
00031
00032 void ClearAll() { m_sensed = time::null(); m_available = time::null(); m_data.clear(); }
00033 unsigned short GetSize() const { return m_data.size(); }
00034
00035 void SetMeasure(time sens, time avail, VEC &data) {
00036 JFR_PRECOND(data.size() == m_data.size(), "bad sizes");
00037 m_sensed = sens;
00038 m_available = avail;
00039 m_data = data;
00040 }
00041 void GetMeasure(time *sens, time *avail, VEC *data) {
00042 JFR_PRECOND(data->size() == m_data.size(), "bad sizes");
00043 *sens = m_sensed;
00044 *avail = m_available;
00045 *data = m_data;
00046 }
00047
00048 void GetMeasure(double *sens, double *avail, VEC *data) {
00049 JFR_PRECOND(data->size() == m_data.size(), "bad sizes");
00050 *sens = m_sensed.to_double();
00051 *avail = m_available.to_double();
00052 *data = m_data;
00053 }
00054
00056 time const& GetSensedTime() const { return m_sensed; }
00057 double GetSensedTimeSec() const { return m_sensed.to_double(); }
00058 time const& GetAvailableTime() const { return m_available; }
00059 VEC const& GetDataOnly() const { return m_data; }
00060 MeasureItem & operator =(MeasureItem const &item) {
00061 JFR_PRECOND(m_data.size() == item.m_data.size(), "bad sizes");
00062 if (&item == this) return *this;
00063 m_data = item.m_data;
00064 m_sensed = item.m_sensed;
00065 m_available = item.m_available;
00066 return *this;
00067 }
00068
00069 int compare_sensed(MeasureItem const& other) const;
00070 int compare_available(MeasureItem const& other) const;
00071 bool equal_sensed(MeasureItem const& other) const { return !compare_sensed(other); }
00072 bool equal_available(MeasureItem const& other) const { return !compare_available(other); }
00073 bool operator == (const MeasureItem& other) const;
00074
00075 friend std::ostream& operator << (std::ostream &stream, MeasureItem const& other);
00076 };
00077
00078 std::ostream& operator << (std::ostream &stream, MeasureItem const& other);
00079
00080 }
00081 }
00082 #endif