Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
infocontainer.hpp
00001 
00002 #ifndef DDF_INFOCONTAINER_HPP
00003 #define DDF_INFOCONTAINER_HPP
00004 
00005 #include <iostream>
00006 #include "ctime.hpp"
00007 #include "definitions.hpp"
00008 
00009 namespace jafar
00010 {
00011   namespace ddf
00012   {
00013 
00020     class InfoContainer
00021     {
00022       unsigned int m_ser_size;     // size, in bytes, of the serialized buffer
00023 
00024     public:
00025       // these members are public, this makes the code utilizing the class more readable
00026       VEC      m_info;
00027       MSYM     m_InfoMat;
00028       time     m_time;
00029    
00030     public:
00031    
00032       InfoContainer(unsigned short sv_size);
00033       InfoContainer(InfoContainer const& other);
00034       InfoContainer(VEC const& y, MSYM const& Y, time const& t);
00035       ~InfoContainer();
00036 
00037       // Set/Get functions
00038       void SetAll(VEC const& y, MSYM const& Y, time const& t);
00039       void ClearAll();
00040       void SetTime(time const& t) { m_time = t; }
00041       MSYM const& GetInfoMat() const { return m_InfoMat; }
00042       VEC const& Getinfo() const { return m_info; }
00043       time const& GetTime() const { return m_time; }
00044       unsigned short GetSize() const { return m_info.size(); }
00045 
00046       // Conversion
00047       unsigned int GetSerialSize() const { return m_ser_size; }
00048    
00052       unsigned int ComputeSerialSize(unsigned short dim) const {
00053         return (dim + SumArithmeticSerie<int>(dim, 0, 1)) * sizeof(double) + 2 * sizeof(long);
00054       }
00055       
00062       unsigned int Serialize(unsigned char *buf) const;
00063 
00066       unsigned int UnSerialize(unsigned char *buf);
00067 
00068       // Operators
00069       void operator = (InfoContainer const& other);
00070       InfoContainer operator - (InfoContainer const& other) const;
00071       InfoContainer operator + (InfoContainer const& other) const;
00072       bool operator < (InfoContainer const& other) const;
00073       bool operator > (InfoContainer const& other) const;
00074       bool CompareInfo(InfoContainer const& other) const;
00075       bool CompareAll(InfoContainer const& other) const;
00076       friend std::ostream& operator << (std::ostream &stream, InfoContainer const& other);
00077 
00078     private:
00079       void Resize(unsigned short new_size);
00080 
00081       // Computes the sum of an arithemtic serie
00082       template<typename T>
00083       T SumArithmeticSerie(int n, T Uo, T r) const
00084       {
00085         T tn = (T) n;
00086         T Un = Uo + r * tn;
00087         return (tn+1)*(Uo+Un)/2;
00088       }
00089     };
00090 
00091     std::ostream& operator << (std::ostream &stream, InfoContainer const& other);
00092 
00093   } // namespace ddf
00094 } // namespace jafar
00095 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:17 for Jafar by doxygen 1.7.6.1
LAAS-CNRS