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 #ifndef MFILE_H
00028 #define MFILE_H
00029 
00030 #include <vector>
00031 #include <string>
00032 #include "kalman/ktypes.hpp"
00033 #include "kalman/kvector.hpp"
00034 #include "kalman/kmatrix.hpp"
00035 
00036 namespace Kalman {
00037 
00038 #define LINE_MAX_LENGTH 65536
00039 #define ROW_VECTOR 0
00040 #define COLUMN_VECTOR 1
00041 
00042 struct MFileElement
00043 {
00044   unsigned int Index;
00045   unsigned int Rows;
00046   unsigned int Cols;
00047   std::string Name;
00048   MFileElement();
00049   MFileElement(const MFileElement& tmp);
00050   ~MFileElement();
00051   MFileElement& operator=(const MFileElement& tmp);
00052 };
00053 
00054 
00055 class MFile {
00056  public:
00057 
00058   MFile();
00059   ~MFile();
00060 
00061   int read(char *filename);
00062   int save(char *filename);
00063   void print();
00064 
00065 template<typename T, K_UINT_32 BEG, bool DBG>
00066 inline int get(std::string name, Kalman::KVector<T,BEG,DBG>& tmpvector);
00067 
00068 template<typename T, K_UINT_32 BEG, bool DBG>
00069   inline int get(std::string name, Kalman::KMatrix<T,BEG,DBG>& tmpmatrix);
00070 
00071 template<typename T, K_UINT_32 BEG, bool DBG>
00072   inline int add(std::string name, Kalman::KVector<T,BEG,DBG>& tmpvector, int type=ROW_VECTOR);
00073 
00074 template<typename T, K_UINT_32 BEG, bool DBG>
00075   inline int add(std::string name, Kalman::KMatrix<T,BEG,DBG>& tmpmatrix);
00076 
00077  private:
00078 
00079   bool add_double(std::string &tmpstr);
00080 
00081   std::vector<MFileElement> VectorMFileElement;
00082   std::vector<double> Data;
00083 };
00084 
00085 }
00086 
00087 #include "MFile_impl.hpp"
00088 
00089 #endif