Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

hyp.file.formatstd.h

00001 /*
00002 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
00003  Ephydryne Components.
00004  Ephydryne is a part of the Hyperion Project.
00005 ----------------------------------------------------------
00006  Copyright (c) 2001 Pierre Rebours.
00007 
00008  This library is free software; you can redistribute it and/or
00009  modify it under the terms of the GNU Lesser General Public
00010  License as published by the Free Software Foundation; either
00011  version 2.1 of the License, or (at your option) any later version.
00012 
00013  This library is distributed in the hope that it will be useful,
00014  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  
00017  See hyp.license.txt file for more information about the license.
00018  
00019  Web: http://lagrandeporte.multimania.com/hyperion
00020  Email: pierre_rebours@yahoo.com
00021 ----------------------------------------------------------
00022  CVS
00023  $Log$
00024  
00025  Creation 02/05/01 Pierre Rebours
00026 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
00027 */
00028 
00029 #ifndef _hyp_file_formatstd_h_
00030 #define _hyp_file_formatstd_h_
00031 
00032 class CValue
00033 {
00034 protected:
00035         std::string m_Value;    
00036         template<class T> std::string ConvertValue(const T& value) {
00037                 std::stringstream buff;
00038                 buff<<value;
00039                 return buff.str();
00040         }
00041         
00042 public:
00043         template<class T> 
00044         CValue(const T& value) {
00045                 SetValue(value);
00046         }
00047         CValue() {}
00048         CValue(const CValue& value) { m_Value=value.m_Value; }
00049 
00050         template<class T> void SetValue(const T& value) {
00051                 m_Value.erase();
00052                 m_Value=ConvertValue(value);
00053         }
00054 
00055         template<class T> void InsertNewValue(const T& value) {
00056                 if(!m_Value.empty()) m_Value+="-";
00057                 m_Value+=ConvertValue(value);
00058         }
00059 
00060         inline std::string& Value(void) { return m_Value; }
00061         inline const std::string& Value(void) const { return m_Value; }
00062 };
00063 
00064 
00065 class CDataToShow
00066 {
00067 protected:
00068         int m_Size;
00069 public:
00070         CDataToShow(const int& size) : m_Size(size) {}
00071         CDataToShow() : m_Size(0) {}
00072         CDataToShow(const CDataToShow& data) { m_Size=data.Size(); }
00073         inline int& Size(void) { return m_Size; }
00074         inline const int& Size(void) const { return m_Size; }
00075         virtual void write(std::ostream&) const =0;
00076 };
00077 
00078 class CBox :
00079 public CValue,
00080 public CDataToShow
00081 {
00082 public:
00083         template<class T> 
00084         CBox(const T& value,int size) : CValue(value), CDataToShow(size) {}
00085         CBox(const CBox& box) {
00086                 Value()=box.Value();
00087                 Size()=box.Size();
00088         }
00089         
00090         virtual void write(std::ostream& stream) const;
00091 
00092         static const int ms_ColumnSize_Bool;
00093         static const int ms_ColumnSize_Label;
00094         static const int ms_ColumnSize_Real;
00095         static const int ms_ColumnSize_List;
00096 };
00097 
00098 class CColumn :
00099 public CDataToShow
00100 {
00101 public:
00102         static const int ms_PosColumn;
00103         std::vector<CBox> m_BoxEnum;
00104         CColumn() : CDataToShow(ms_PosColumn) {}
00105         CColumn(const CColumn& col) { Size()=col.Size(); }
00106 
00107         virtual void write(std::ostream& stream) const;
00108 };
00109 
00110 class CColumnHead :
00111 public CColumn
00112 {
00113 public:
00114         virtual void write(std::ostream& stream) const;
00115 };
00116 
00117 class CTable :
00118 public CDataToShow,
00119 public CValue
00120 {
00121 public:
00122         static const int ms_JumpAfterXLines;
00123         static const int ms_PosTable;
00124 
00125         std::vector<CColumn> m_ColumnEnum;
00126         CColumnHead m_ColumnHead;
00127 
00128         template<class T>
00129         CTable(const T& value,const int& nb_row) :
00130         CValue(value),CDataToShow(ms_PosTable),m_ColumnEnum(nb_row) { }
00131                 
00132         virtual void write(std::ostream& stream) const;
00133 
00134         template<class T> void ShowBases(const T& bases_enum) {
00135                 InsertNewValue(bases_enum.size());
00136                 m_ColumnHead.m_BoxEnum.push_back(CBox("LABEL",CBox::ms_ColumnSize_Label));
00137                 m_ColumnHead.m_BoxEnum.push_back(CBox("G_L",CBox::ms_ColumnSize_List));
00138                 m_ColumnHead.m_BoxEnum.push_back(CBox("L_L",CBox::ms_ColumnSize_List));
00139 
00140                 for(int i=0;i<bases_enum.size();i++) {
00141                         m_ColumnEnum[i].m_BoxEnum.push_back(CBox(bases_enum[i].label,CBox::ms_ColumnSize_Label));
00142 
00143                         CBox global_labels("",CBox::ms_ColumnSize_List);
00144                         for(int j=0;j<bases_enum[i].vertices_global.size();j++) {                       
00145                                 global_labels.InsertNewValue(bases_enum[i].vertices_global[j]);
00146                         }
00147                         m_ColumnEnum[i].m_BoxEnum.push_back(global_labels);
00148                 
00149                         CBox local_labels("",CBox::ms_ColumnSize_List);
00150                         for(j=0;j<bases_enum[i].vertices_local.size();j++) {                    
00151                                 local_labels.InsertNewValue(bases_enum[i].vertices_local[j]);
00152                         }
00153                         m_ColumnEnum[i].m_BoxEnum.push_back(local_labels);
00154                 }
00155         }
00156 };
00157 
00158 #endif

Top of Page
written by Pierre Rebours © 2000-2001. Terms of Use.