ConfDataSection.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ConfDataSection.hpp 2956 2011-10-30 09:48:24Z yanweignss $"
00002 
00008 #ifndef GPSTK_CONFDATASECTION_HPP
00009 #define GPSTK_CONFDATASECTION_HPP
00010 
00011 //============================================================================
00012 //
00013 //  This file is part of GPSTk, the GPS Toolkit.
00014 //
00015 //  The GPSTk is free software; you can redistribute it and/or modify
00016 //  it under the terms of the GNU Lesser General Public License as published
00017 //  by the Free Software Foundation; either version 2.1 of the License, or
00018 //  any later version.
00019 //
00020 //  The GPSTk is distributed in the hope that it will be useful,
00021 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 //  GNU Lesser General Public License for more details.
00024 //
00025 //  You should have received a copy of the GNU Lesser General Public
00026 //  License along with GPSTk; if not, write to the Free Software Foundation,
00027 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 //
00029 //  Wei Yan - Chinese Academy of Sciences . 2011
00030 //
00031 //============================================================================
00032 
00033 #include <string>
00034 #include <vector>
00035 #include "ConfDataItem.hpp"
00036 
00037 namespace gpstk
00038 {
00042    class ConfDataSection
00043    {
00044    public:
00045       typedef std::vector< ConfDataItemAbstract* > ItemSet;
00046       typedef ItemSet::iterator Iterator;
00047 
00048    public:
00049       ConfDataSection(const std::string& desc="")
00050          : comment(desc){}
00051    
00052       virtual ~ConfDataSection(){}
00053 
00054       Iterator begin(){return dataSet.begin();}
00055 
00056       Iterator end(){return dataSet.end();}
00057 
00058       ConfDataSection& clear()
00059       { dataSet.clear(); return (*this); }
00060 
00061       ConfDataSection& insert(ConfDataItemAbstract* di)
00062       { dataSet.push_back(di); return (*this); }
00063 
00064       ConfDataSection& insert(const ConfDataSection& s2)
00065       {
00066          ConfDataSection ts(s2);
00067          for(Iterator it = ts.begin(); it!=ts.end(); it++)
00068          {
00069             insert(*it);
00070          }
00071 
00072          return (*this);
00073       }
00074       
00075       ConfDataSection& remove(const std::string& var)
00076       {
00077          ConfDataSection s2;
00078          for(Iterator it = begin(); it!=end(); it++)
00079          {
00080             if((*it)->get_var()!=var) s2.insert(*it);
00081          }
00082 
00083          clear().insert(s2);
00084 
00085          return (*this);
00086       }
00087       
00088 
00089       bool exists(const std::string& var)
00090       {
00091          bool found(false);
00092 
00093          for(Iterator it = begin(); it!=end(); it++)
00094          {
00095             if( (*it)->get_var()==var)
00096             {
00097                found = true;
00098                break;
00099             }
00100          }
00101       
00102          return found;
00103       }
00104       
00105       ConfDataItemAbstract* item(const std::string& var)
00106       {
00107          bool found(false);
00108 
00109          for(Iterator it = begin(); it!=end(); it++)
00110          {
00111             if((*it)->get_var()==var)
00112             {
00113                return (*it);
00114             }
00115          }
00116 
00117          return 0;
00118       }
00119 
00120    public:
00121       std::string  comment;
00122 
00123    protected:
00124       ItemSet dataSet;
00125          
00126    };   // End of class 'ConfDataSection'
00127    
00128    typedef ConfDataSection ConfDataItemSet;
00129 
00130 }   // End of namespace gpstk
00131 
00132 
00133 #endif  //GPSTK_CONFDATAITEMSET_HPP
00134 

Generated on Tue May 22 03:30:57 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1