PetaVision  Alpha
Arguments.hpp
1 /*
2  * Arguments.hpp
3  *
4  * Created on: Sep 21, 2015
5  * Author: pschultz
6  */
7 
8 #ifndef ARGUMENTS_HPP_
9 #define ARGUMENTS_HPP_
10 
11 #include "io/ConfigParser.hpp"
12 #include "io/Configuration.hpp"
13 #include <string>
14 
15 namespace PV {
16 
37 class Arguments {
38  public:
42  Arguments(std::istream &configStream, bool allowUnrecognizedArguments);
43 
47  virtual ~Arguments();
48 
53  Configuration::ConfigurationType getType(std::string const &name) const {
54  return mCurrentConfig.getType(name);
55  }
56 
62  bool const &getBooleanArgument(std::string const &name) const {
63  return mCurrentConfig.getBooleanArgument(name);
64  }
65 
71  int const &getIntegerArgument(std::string const &name) const {
72  return mCurrentConfig.getIntegerArgument(name);
73  }
74 
80  unsigned int const &getUnsignedIntArgument(std::string const &name) const {
81  return mCurrentConfig.getUnsignedIntArgument(name);
82  }
83 
89  std::string const &getStringArgument(std::string const &name) const {
90  return mCurrentConfig.getStringArgument(name);
91  }
92 
98  Configuration::IntOptional const &getIntOptionalArgument(std::string const &name) const {
99  return mCurrentConfig.getIntOptionalArgument(name);
100  }
101 
107  bool setBooleanArgument(std::string const &name, bool const &value) {
108  return mCurrentConfig.setBooleanArgument(name, value);
109  }
110 
116  bool setIntegerArgument(std::string const &name, int const &value) {
117  return mCurrentConfig.setIntegerArgument(name, value);
118  }
119 
125  bool setUnsignedIntArgument(std::string const &name, unsigned int const &value) {
126  return mCurrentConfig.setUnsignedIntArgument(name, value);
127  }
128 
134  bool setStringArgument(std::string const &name, std::string const &value) {
135  return mCurrentConfig.setStringArgument(name, value);
136  }
137 
143  bool setIntOptionalArgument(std::string const &name, Configuration::IntOptional const &value) {
144  return mCurrentConfig.setIntOptionalArgument(name, value);
145  }
146 
157  void resetState(std::istream &configStream, bool allowUnrecognizedArguments);
158 
166  void resetState();
167 
172  int printState() const;
173 
174  protected:
181 
186  int initialize(std::istream &configStream, bool allowUnrecognizedArguments);
187 
188  private:
194  int initialize_base();
195 
196  // Member variables
197  private:
198  ConfigParser *mConfigFromStream = nullptr;
199  Configuration mCurrentConfig;
200 };
201 
202 } /* namespace PV */
203 
204 #endif /* ARGUMENTS_HPP_ */
virtual ~Arguments()
Definition: Arguments.cpp:45
bool setBooleanArgument(std::string const &name, bool const &value)
Definition: Arguments.hpp:107
bool setStringArgument(std::string const &name, std::string const &value)
Definition: Arguments.hpp:134
Configuration::ConfigurationType getType(std::string const &name) const
Definition: Arguments.hpp:53
void resetState()
Definition: Arguments.cpp:38
std::string const & getStringArgument(std::string const &name) const
Definition: Arguments.hpp:89
bool setUnsignedIntArgument(std::string const &name, unsigned int const &value)
Definition: Arguments.hpp:125
bool const & getBooleanArgument(std::string const &name) const
Definition: Arguments.hpp:62
Configuration::IntOptional const & getIntOptionalArgument(std::string const &name) const
Definition: Arguments.hpp:98
bool setIntOptionalArgument(std::string const &name, Configuration::IntOptional const &value)
Definition: Arguments.hpp:143
unsigned int const & getUnsignedIntArgument(std::string const &name) const
Definition: Arguments.hpp:80
int initialize_base()
Definition: Arguments.cpp:25
bool setIntegerArgument(std::string const &name, int const &value)
Definition: Arguments.hpp:116
ConfigurationType getType(std::string const &name) const
int const & getIntegerArgument(std::string const &name) const
Definition: Arguments.hpp:71
int printState() const
Definition: Arguments.cpp:40
int initialize(std::istream &configStream, bool allowUnrecognizedArguments)
Definition: Arguments.cpp:27