The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
reports.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef REPORTS_HPP_INCLUDED
16 #define REPORTS_HPP_INCLUDED
17 
18 #include "display_context.hpp"
19 
20 #include <vector>
21 
22 #include <boost/optional.hpp>
23 #include <boost/shared_ptr.hpp>
24 
25 //this module is responsible for outputting textual reports of
26 //various game and unit statistics
27 
28 class gamemap;
29 class team;
30 class tod_manager;
31 class unit_map;
32 
33 class display;
34 
35 namespace wb {
36  class manager;
37 }
38 
39 namespace events {
40  class mouse_handler;
41 }
42 
43 class reports
44 {
45 public:
46 
47  class context
48  {
49  public:
50  context(const display_context & dc, display & disp, const tod_manager & tod, boost::shared_ptr<wb::manager> wb, boost::optional<events::mouse_handler &> mhb) : dc_(dc), disp_(disp), tod_(tod), wb_(wb), mhb_(mhb) {}
51 
52  const std::vector<team> & teams() { return dc_.teams(); }
53  const unit_map & units() { return dc_.units(); }
54  const gamemap & map() { return dc_.map(); }
55 
56  const display_context & dc() { return dc_; }
57  display & screen() { return disp_; }
58  const tod_manager & tod() { return tod_; }
60  boost::optional<events::mouse_handler&> mhb() { return mhb_; }
61 
62  private:
65  const tod_manager & tod_;
67  boost::optional<events::mouse_handler&> mhb_;
68  };
69 
70  struct generator
71  {
72  virtual config generate(context & ct) = 0;
73  virtual ~generator() {}
74  };
75 
77 
78  config generate_report(const std::string &name, context & ct, bool only_static = false);
79 
80  const std::set<std::string> &report_list();
81 
82 
84  typedef std::map<std::string, boost::shared_ptr<reports::generator> > dynamic_report_generators;
85 
86 private:
87 
88  std::set<std::string> all_reports_;
89 
90  dynamic_report_generators dynamic_generators_;
91 
92 };
93 
94 #endif
boost::optional< events::mouse_handler & > mhb_
Definition: reports.hpp:67
config(* generator_function)(reports::context &)
Definition: reports.hpp:83
const unit_map & units()
Definition: reports.hpp:53
const tod_manager & tod_
Definition: reports.hpp:65
rng * generator
This generator is automatically synced during synced context.
Definition: random_new.cpp:52
const std::set< std::string > & report_list()
Definition: reports.cpp:1582
display & screen()
Definition: reports.hpp:57
virtual const gamemap & map() const =0
Unit and team statistics.
display & disp_
Definition: reports.hpp:64
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:50
context(const display_context &dc, display &disp, const tod_manager &tod, boost::shared_ptr< wb::manager > wb, boost::optional< events::mouse_handler & > mhb)
Definition: reports.hpp:50
void register_generator(const std::string &name, generator *)
Definition: reports.cpp:1564
std::set< std::string > all_reports_
Definition: reports.hpp:88
config generate_report(const std::string &name, context &ct, bool only_static=false)
Definition: reports.cpp:1569
Encapsulates the map of the game.
Definition: map.hpp:37
const display_context & dc_
Definition: reports.hpp:63
virtual const unit_map & units() const =0
const tod_manager & tod()
Definition: reports.hpp:58
dynamic_report_generators dynamic_generators_
Definition: reports.hpp:90
virtual const std::vector< team > & teams() const =0
virtual ~generator()
Definition: reports.hpp:73
const std::vector< team > & teams()
Definition: reports.hpp:52
const display_context & dc()
Definition: reports.hpp:56
std::map< std::string, boost::shared_ptr< reports::generator > > dynamic_report_generators
Definition: reports.hpp:84
Handling of system events.
Definition: manager.hpp:42
GLuint const GLchar * name
Definition: glew.h:1782
boost::optional< events::mouse_handler & > mhb()
Definition: reports.hpp:60
Container associating units to locations.
Definition: map.hpp:90
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
boost::shared_ptr< wb::manager > wb()
Definition: reports.hpp:59
GLsizei const GLcharARB ** string
Definition: glew.h:4503
Definition: display.hpp:47
const gamemap & map()
Definition: reports.hpp:54
boost::shared_ptr< wb::manager > wb_
Definition: reports.hpp:66
virtual config generate(context &ct)=0