STK++ 1.0
STK_IPage.h
Go to the documentation of this file.
00001 /*--------------------------------------------------------------------*/
00002 /*     Copyright (C) 2004-2007  Serge Iovleff
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU Lesser General Public License as
00006     published by the Free Software Foundation; either version 2 of the
00007     License, or (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU Lesser General Public License for more details.
00013 
00014     You should have received a copy of the GNU Lesser General Public
00015     License along with this program; if not, write to the
00016     Free Software Foundation, Inc.,
00017     59 Temple Place,
00018     Suite 330,
00019     Boston, MA 02111-1307
00020     USA
00021 
00022     Contact : Serge.Iovleff@stkpp.org
00023 */
00024 
00025 /*
00026  * Project:  stkpp::DManager
00027  * created on: 22 avr. 2010
00028  * Purpose:  Public interface of the IPage class.
00029  * Author:   iovleff, serge.iovleff@stkpp.org
00030  *
00031  **/
00032 
00035 #ifndef STK_IPAGE_H
00036 #define STK_IPAGE_H
00037 
00038 // C++ headers
00039 #include <vector>
00040 #include <string>
00041 
00042 // STK+ headers
00043 #include "../../STKernel/include/STK_Integer.h"
00044 #include "../../STKernel/include/STK_Real.h"
00045 #include "../../STKernel/include/STK_String.h"
00046 #include "../../STKernel/include/STK_Stream.h"
00047 
00048 #include "STK_Option.h"
00049 
00050 namespace STK
00051 {
00102 class IPage
00103 {
00104   public:
00106     typedef std::vector<Option> ContOption;
00107 
00116     IPage( String const& name, Integer const& level, bool isOptional);
00117 
00121     IPage( IPage const& page);
00122 
00124     virtual ~IPage();
00125 
00129     inline String const& name() const { return name_;}
00133     inline bool isOptional() const { return isOptional_;}
00137     inline ContOption const& options() const { return options_;};
00138 
00143     Option& option( String const& name);
00144 
00149     Option const& option( String const& name) const;
00150 
00155     inline Option const& option(Integer const& pos) const
00156     { return options_.at(ContOption::size_type(pos));}
00157 
00162     inline Option& option(Integer const& pos)
00163     { return options_.at(ContOption::size_type(pos));}
00164 
00169     inline Option const& operator[](Integer const& pos) const
00170     { return options_.at(ContOption::size_type(pos));}
00171 
00176     inline Option& operator[](Integer const& pos)
00177     { return options_.at(ContOption::size_type(pos));}
00178 
00182     inline void addOption(Option const& opt)
00183     { return options_.push_back(opt);}
00184 
00188     void addPage(IPage const& page);
00189 
00193     void read( istream& is);
00194 
00198     void write( ostream& os) const;
00199 
00201     inline virtual bool validate()
00202     { return true; }
00203 
00205     inline virtual IPage* clone() const
00206     { return new IPage(*this); }
00207 
00208   protected:
00210     bool isOptional_;
00212     ContOption options_;
00213 
00215     mutable String msg_error_;
00216 
00217   private:
00219     String name_;
00223     mutable Integer level_;
00229     mutable String keyword_;
00234     bool findKeyword( istream& is) const;
00239     bool processLine( String const& line);
00240 };
00241 
00242 } // namespace STK
00243 
00244 #endif /* STK_IPAGE_H */