diff --git a/src/display_context.hpp b/src/display_context.hpp new file mode 100644 index 000000000000..b25079d46094 --- /dev/null +++ b/src/display_context.hpp @@ -0,0 +1,40 @@ +/* + Copyright (C) 2014 by Chris Beck + Part of the Battle for Wesnoth Project http://www.wesnoth.org/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY. + + See the COPYING file for more details. +*/ + +/** + * + * This class is an abstract base class designed to simplify the use + * of the display object. + * + **/ + +#ifndef DISPLAY_CONTEXT_HPP_INCLUDED +#define DISPLAY_CONTEXT_HPP_INCLUDED + +#include + +class team; +class gamemap; +class unit_map; + +class display_context { +public: + virtual const std::vector & teams() const = 0; + virtual const gamemap & map() const = 0; + virtual const unit_map & units() const = 0; + + virtual ~display_context() {} +}; + +#endif diff --git a/src/game_board.hpp b/src/game_board.hpp index 4bdf4e771729..fc3278301e5c 100644 --- a/src/game_board.hpp +++ b/src/game_board.hpp @@ -17,6 +17,7 @@ #include "global.hpp" +#include "display_context.hpp" #include "map.hpp" #include "team.hpp" #include "unit_map.hpp" @@ -46,7 +47,7 @@ namespace events { * **/ -class game_board { +class game_board : public display_context { std::vector teams_; @@ -82,13 +83,14 @@ class game_board { public: - // Constructors and const accessors + // Constructors, trivial dtor, and const accessors game_board(const config & game_config, const config & level) : teams_(), map_(game_config, level), units_() {} + virtual ~game_board() {} - const std::vector & teams() const { return teams_; } - const gamemap & map() const { return map_; } - const unit_map & units() const { return units_; } + virtual const std::vector & teams() const { return teams_; } + virtual const gamemap & map() const { return map_; } + virtual const unit_map & units() const { return units_; } // Saving