PetaVision  Alpha
Arguments.cpp
1 /*
2  * Arguments.cpp
3  *
4  * Created on: Sep 21, 2015
5  * Author: pschultz
6  */
7 
8 #include <cstdlib>
9 #ifdef PV_USE_OPENMP_THREADS
10 #include <omp.h>
11 #endif
12 #include "Arguments.hpp"
13 #include "io/io.hpp"
14 #include "utils/PVAssert.hpp"
15 #include "utils/PVLog.hpp"
16 #include <istream>
17 
18 namespace PV {
19 
20 Arguments::Arguments(std::istream &configStream, bool allowUnrecognizedArguments) {
22  initialize(configStream, allowUnrecognizedArguments);
23 }
24 
25 int Arguments::initialize_base() { return PV_SUCCESS; }
26 
27 int Arguments::initialize(std::istream &configStream, bool allowUnrecognizedArguments) {
28  resetState(configStream, allowUnrecognizedArguments);
29  return PV_SUCCESS;
30 }
31 
32 void Arguments::resetState(std::istream &configStream, bool allowUnrecognizedArguments) {
33  delete mConfigFromStream;
34  mConfigFromStream = new ConfigParser(configStream, allowUnrecognizedArguments);
35  resetState();
36 }
37 
38 void Arguments::resetState() { mCurrentConfig = mConfigFromStream->getConfig(); }
39 
40 int Arguments::printState() const {
41  InfoLog() << mCurrentConfig.printConfig();
42  return PV_SUCCESS;
43 }
44 
45 Arguments::~Arguments() { delete mConfigFromStream; }
46 
47 } /* namespace PV */
virtual ~Arguments()
Definition: Arguments.cpp:45
void resetState()
Definition: Arguments.cpp:38
int initialize_base()
Definition: Arguments.cpp:25
Configuration const & getConfig() const
int printState() const
Definition: Arguments.cpp:40
int initialize(std::istream &configStream, bool allowUnrecognizedArguments)
Definition: Arguments.cpp:27