Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
context_factory.hpp
Go to the documentation of this file.
1 #ifndef STAN__COMMON__CONTEXT_FACTORY_HPP
2 #define STAN__COMMON__CONTEXT_FACTORY_HPP
3 
4 #include <fstream>
5 #include <stan/io/dump.hpp>
6 
7 namespace stan {
8  namespace common {
9 
10  template <typename VARCON>
12  public:
14  virtual VARCON operator()(const std::string source) = 0;
15  typedef VARCON var_context_t;
16  };
17 
18  // FIXME: Move to CmdStan
19  class dump_factory: public var_context_factory<stan::io::dump> {
20  public:
21  stan::io::dump operator()(const std::string source) {
22  std::fstream source_stream(source.c_str(),
23  std::fstream::in);
24 
25  if (source_stream.fail()) {
26  std::string message("dump_factory Error: the file " + source + " does not exist.");
27  throw std::runtime_error(message);
28  }
29 
30  stan::io::dump dump(source_stream);
31  source_stream.close();
32 
33  return dump;
34  }
35  };
36 
37  }
38 }
39 
40 #endif
stan::io::dump operator()(const std::string source)
virtual VARCON operator()(const std::string source)=0
Represents named arrays with dimensions.
Definition: dump.hpp:902

     [ Stan Home Page ] © 2011–2014, Stan Development Team.