Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
messages.hpp
Go to the documentation of this file.
1 #ifndef STAN__COMMON__RECORDER__MESSAGES_HPP
2 #define STAN__COMMON__RECORDER__MESSAGES_HPP
3 
4 #include <ostream>
5 #include <string>
6 #include <vector>
7 
8 namespace stan {
9  namespace common {
10  namespace recorder {
11  class messages {
12  private:
13  std::ostream *o_;
14  const bool has_stream_;
15  const std::string prefix_;
16 
17  public:
18  messages(std::ostream *o, std::string prefix)
19  : o_(o), has_stream_(o != 0), prefix_(prefix) { }
20 
21  messages(std::ostream *o)
22  : o_(o), has_stream_(o != 0), prefix_("") { }
23 
24  template <class T>
25  void operator()(const std::vector<T>& x) {
26  // no op
27  }
28 
29  void operator()(const std::string x) {
30  if (!has_stream_)
31  return;
32  *o_ << prefix_ << x << std::endl;
33  }
34 
35  void operator()() {
36  if (!has_stream_)
37  return;
38  *o_ << std::endl;
39  }
40 
41  bool is_recording() const {
42  return has_stream_;
43  }
44 
45  };
46  }
47  }
48 }
49 
50 #endif
void operator()(const std::string x)
Definition: messages.hpp:29
void operator()(const std::vector< T > &x)
Definition: messages.hpp:25
messages(std::ostream *o, std::string prefix)
Definition: messages.hpp:18

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