KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pt_recorder.h
Go to the documentation of this file.
1 /* =========================================================================== *
2 |
3 | Copyright (c) 1994-2008 by Kobus Barnard (author).
4 |
5 | Personal and educational use of this code is granted, provided that this
6 | header is kept intact, and that the authorship is not misrepresented, that
7 | its use is acknowledged in publications, and relevant papers are cited.
8 |
9 | For other use contact the author (kobus AT cs DOT arizona DOT edu).
10 |
11 | Please note that the code in this file has not necessarily been adequately
12 | tested. Naturally, there is no guarantee of performance, support, or fitness
13 | for any particular task. Nonetheless, I am interested in hearing about
14 | problems that you encounter.
15 |
16 | Authors:
17 | Ernesto Brau, Jinyan Guan
18 |
19 * =========================================================================== */
20 
21 /* $Id$ */
22 
23 #ifndef PT_RECORDER_H
24 #define PT_RECORDER_H
25 
28 #include <string>
29 #include <sstream>
30 
31 namespace kjb {
32 namespace pt {
33 
38 template <class OutputIterator>
40 {
41 public:
42  typedef std::string record_type;
43 
45  Posterior_detail_recorder(OutputIterator it, const Scene_posterior& post) :
46  it_(it), post_(post), increment_(true)
47  {}
48 
51  {
52  increment_ = false;
53  return *this;
54  }
55 
57  template <class Step>
58  void operator()(const Step& step, const Scene&, double)
59  {
60  std::stringstream ss;
61  write_posterior_details(post_, *step.proposed_model(), 0.0, ss);
62  *it_ = ss.str();
63  if(increment_) it_++;
64  }
65 
66 private:
67  OutputIterator it_;
68  const Scene_posterior& post_;
69  bool increment_;
70 };
71 
73 template <class OutputIterator>
74 inline
75 Posterior_detail_recorder<OutputIterator> make_pd_recorder
76 (
77  OutputIterator it,
78  const Scene_posterior& post
79 )
80 {
82 }
83 
84 }} // namespace kjb::pt
85 
86 #endif /* PT_RECORDER_H */
87 
void operator()(const Step &step, const Scene &, double)
Records a step.
Definition: pt_recorder.h:58
Class that represents a full scene in the PT universe.
Definition: pt_scene.h:40
Posterior_detail_recorder< OutputIterator > make_pd_recorder(OutputIterator it, const Scene_posterior &post)
Convenience function to create a Posterior_detail_recorder.
Definition: pt_recorder.h:76
std::string record_type
Definition: pt_recorder.h:42
function straight edges straight lines(nlines,[x1 x2 y1 y2 theta r])%%To display result ss
Definition: APPgetLargeConnectedEdges.m:20
Posterior_detail_recorder(OutputIterator it, const Scene_posterior &post)
Constructs a recorder.
Definition: pt_recorder.h:45
Posterior_detail_recorder & replace()
Force replacing of recorded value every time.
Definition: pt_recorder.h:50
Posterior distribution of a scene.
Definition: pt_scene_posterior.h:53
void write_posterior_details(const Scene_posterior &post, const Scene &scene, double mlh, std::ostream &ost)
Write the details of the posterior in a table format.
Definition: pt_scene_posterior.cpp:263
Records the details about the posterior.
Definition: pt_recorder.h:39