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
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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 };
00127
00128 typedef ConfDataSection ConfDataItemSet;
00129
00130 }
00131
00132
00133 #endif //GPSTK_CONFDATAITEMSET_HPP
00134