visudatainfo.h

Go to the documentation of this file.
00001 #ifndef __visudatainfo_h
00002 #define __visudatainfo_h
00003 
00004 #include  "fixarray.h"
00005 #include  "visudata.h"
00006 
00007 #include  <map>
00008 #include  <string>
00009 
00010 /*-------------------------------------------------------------------------*/
00011 
00012 namespace Gascoigne
00013 {
00014 class VisuDataInfo
00015 {
00016  protected:
00017 
00018   std::map<std::string,int>              scalars;
00019   std::map<std::string,fixarray<3,int> > vectors;
00020   std::map<std::string,int>              scalar_order;
00021   std::map<std::string,int>              vector_order;
00022 
00023  public:
00024 
00025   typedef std::map<std::string,int>::const_iterator                siterator;
00026   typedef std::map<std::string,fixarray<3,int> >::const_iterator   viterator;
00027 
00028   VisuDataInfo() {}
00029   VisuDataInfo(int ncomp) { AddScalars(ncomp);}
00030   VisuDataInfo(const VisuData& V, std::string def="U");
00031   VisuDataInfo(const VisuDataInfo& V) : scalars(V.Scalars()), vectors(V.Vectors()) {}
00032   VisuDataInfo& operator=(const VisuDataInfo& V);
00033 
00034   bool operator!=(const VisuDataInfo& V) const;
00035 
00036   void Clear() {
00037     scalar_order.clear();
00038     vector_order.clear();
00039     scalars.clear();
00040     vectors.clear();
00041   }
00042 
00043   siterator GetSIterator(int i) { 
00044     for(siterator p = sbegin() ; p!= send() ; p++){
00045       std::string s = p->first;
00046       if ( scalar_order[s]==i ) return p;
00047     }
00048     assert(0);
00049   }
00050   viterator GetVIterator(int i) {
00051     for(viterator p = vbegin() ; p!= vend() ; p++){
00052       std::string s = p->first;
00053       if ( vector_order[s]==i ) return p;
00054     }
00055     assert(0);
00056   }
00057 
00058   void AddScalar(int index,const std::string& name, int i)                    {scalar_order[name]=index;scalars[name]=i;}
00059   void AddVector(int index,const std::string& name, const fixarray<3,int>& i) {vector_order[name]=index;vectors[name]=i;}
00060 
00061   void AddScalars(int ncomp, std::string def="U");
00062 
00063   int nscalars() const {return scalars.size();}
00064   int nvectors() const {return vectors.size();}
00065 
00066   const std::map<std::string,int>&              Scalars() const {return scalars;}
00067   const std::map<std::string,fixarray<3,int> >& Vectors() const {return vectors;}
00068 
00069   siterator sbegin() const {return scalars.begin();}
00070   siterator send  () const {return scalars.end();}
00071   viterator vbegin() const {return vectors.begin();}
00072   viterator vend  () const {return vectors.end();}
00073 };
00074 }
00075 
00076 #endif

Generated on Thu Sep 14 10:34:36 2006 for Gascoigne by  doxygen 1.4.7