forqs module reference
Forward simulation of Recombination, Quantitative traits, and Selection
 All Classes Groups Pages
Reporter.hpp
1 //
2 // Reporter.hpp
3 //
4 // Created by Darren Kessner with John Novembre
5 //
6 // Copyright (c) 2013 Regents of the University of California
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // * Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // * Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // * Neither UCLA nor the names of its contributors may be used to endorse or
20 // promote products derived from this software without specific prior
21 // written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
27 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 //
34 
35 
36 #ifndef _REPORTER_HPP_
37 #define _REPORTER_HPP_
38 
39 
40 #include "PopulationData.hpp"
41 #include "Configurable.hpp"
42 #include "boost/filesystem.hpp"
43 #include "boost/filesystem/fstream.hpp"
44 #include <ctime>
45 
46 
47 namespace bfs = boost::filesystem;
48 
49 
50 //
51 // Reporter
52 //
53 
57 
58 class Reporter : public virtual Configurable
59 {
60  public:
61 
62  virtual void update(size_t generation_index,
63  const PopulationPtrs& populations,
64  const PopulationDatas& population_datas,
65  bool is_final_generation) {}
66 
67  virtual Loci loci(size_t generation_index,
68  bool is_final_generation) const {return Loci();}
69 
70  // Configurable interface default implementation
71 
72  virtual std::string class_name() const;
73  virtual Parameters parameters() const;
74  virtual void initialize(const SimulatorConfig& config);
75  virtual void configure(const Parameters& parameters, const Registry& registry);
76 
77  virtual ~Reporter(){}
78 
79  protected:
80 
81  bfs::path output_directory_;
82 
83  // Note: the compiler needs this because Configurable has no default
84  // constructor (by design). However, this call to Configurable(id) never
85  // actually happens. Configurable is a virtual base, so derived classes
86  // must call Configurable(id) directly in their constructors, and this
87  // call is ignored by compiler.
88  Reporter() : Configurable("dummy_id_reporter") {}
89 };
90 
91 
92 typedef shared_ptr<Reporter> ReporterPtr;
93 typedef std::vector<ReporterPtr> ReporterPtrs;
94 
95 
96 #endif // _REPORTER_HPP_
97