STK++ 0.9.13
STK_IPage.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::DManager
27 * created on: 22 avr. 2010
28 * Purpose: Public interface of the IPage class.
29 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
30 *
31 **/
32
35#ifndef STK_IPAGE_H
36#define STK_IPAGE_H
37
38#include <vector>
39#include "STK_Option.h"
40
41namespace STK
42{
93class IPage
94{
95 public:
97 typedef std::vector<Option> ContOption;
98
107 IPage( String const& name, int const& level, bool isOptional);
108
112 IPage( IPage const& page);
113
115 virtual ~IPage();
116
120 inline String const& name() const { return name_;}
124 inline bool isOptional() const { return isOptional_;}
128 inline ContOption const& options() const { return options_;};
132 inline String const& msg_error() const { return msg_error_;}
133
138 Option& option( String const& name);
139
144 Option const& option( String const& name) const;
145
150 inline Option const& option(int const& pos) const
151 { return options_.at(ContOption::size_type(pos));}
152
157 inline Option& option(int const& pos)
158 { return options_.at(ContOption::size_type(pos));}
159
164 inline Option const& operator[](int const& pos) const
165 { return options_.at(ContOption::size_type(pos));}
166
171 inline Option& operator[](int const& pos)
172 { return options_.at(ContOption::size_type(pos));}
173
177 inline void addOption(Option const& opt)
178 { return options_.push_back(opt);}
179
183 void addPage(IPage const& page);
187 void read( istream& is);
191 void write( ostream& os) const;
193 inline virtual bool validate() { return true; }
195 inline virtual IPage* clone() const { return new IPage(*this); }
196
197 protected:
202
205
206 private:
212 mutable int level_;
223 bool findKeyword( istream& is) const;
228 bool processLine( String const& line);
229};
230
231} // namespace STK
232
233#endif /* STK_IPAGE_H */
In this file we define the Option class.
A IPage is an interface base class for reading and/or writing a page of option in a file.
Definition STK_IPage.h:94
void write(ostream &os) const
write out options in a stream
String const & name() const
name of the IPage.
Definition STK_IPage.h:120
virtual bool validate()
validate the page.
Definition STK_IPage.h:193
Option const & option(int const &pos) const
get the ith constant option of the IPage
Definition STK_IPage.h:150
String keyword_
keyword of the page of options.
Definition STK_IPage.h:218
void addPage(IPage const &page)
add a sub-page as an option to the page
String msg_error_
Contain the last error message.
Definition STK_IPage.h:204
Option const & operator[](int const &pos) const
get the ith constant option of the IPage
Definition STK_IPage.h:164
bool findKeyword(istream &is) const
process the input stream until the keyword is encountered.
ContOption options_
array of the options
Definition STK_IPage.h:201
Option & option(int const &pos)
get the ith option of the IPage
Definition STK_IPage.h:157
Option & option(String const &name)
bookkeeping function.
Option & operator[](int const &pos)
get the ith option of the IPage
Definition STK_IPage.h:171
void addOption(Option const &opt)
add an option to the page
Definition STK_IPage.h:177
virtual ~IPage()
Destructor.
Definition STK_IPage.cpp:84
int level_
level of the Page.
Definition STK_IPage.h:212
virtual IPage * clone() const
Definition STK_IPage.h:195
bool processLine(String const &line)
process the input line and set the value of the option.
ContOption const & options() const
get the options of the IPage
Definition STK_IPage.h:128
String const & msg_error() const
name of the IPage.
Definition STK_IPage.h:132
bool isOptional() const
is this Option optional ?.
Definition STK_IPage.h:124
String name_
name of the page of options
Definition STK_IPage.h:208
void read(istream &is)
read in options from an input steam stream
std::vector< Option > ContOption
Container for the options.
Definition STK_IPage.h:97
bool isOptional_
true if the Page is optinal, false otherwise
Definition STK_IPage.h:199
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
the Option class allow to store the value of an option from a IPage.
Definition STK_Option.h:56
std::basic_string< Char > String
STK fundamental type of a String.
std::basic_ostream< Char > ostream
ostream for Char
Definition STK_Stream.h:57
std::basic_istream< Char > istream
istream for Char
Definition STK_Stream.h:55
The namespace STK is the main domain space of the Statistical ToolKit project.