Skip to content

Commit

Permalink
Don't include config.hpp when possible
Browse files Browse the repository at this point in the history
Instead, try to forward-declare it only.
  • Loading branch information
CelticMinstrel committed Feb 23, 2016
1 parent 0484fdd commit baed863
Show file tree
Hide file tree
Showing 27 changed files with 40 additions and 28 deletions.
1 change: 1 addition & 0 deletions src/addon/info.cpp
Expand Up @@ -16,6 +16,7 @@

#include "addon/manager.hpp"
#include "game_config.hpp"
#include "config.hpp"
#include "gettext.hpp"
#include "image.hpp"
#include "log.hpp"
Expand Down
3 changes: 2 additions & 1 deletion src/addon/info.hpp
Expand Up @@ -15,14 +15,15 @@
#ifndef ADDON_INFO_HPP_INCLUDED
#define ADDON_INFO_HPP_INCLUDED

#include "config.hpp"
#include "version.hpp"

#include "addon/validation.hpp"

#include <set>
#include <map>

struct addon_info;
class config;
typedef std::map<std::string, addon_info> addons_list;

struct addon_info
Expand Down
1 change: 1 addition & 0 deletions src/addon/state.cpp
Expand Up @@ -13,6 +13,7 @@
*/

#include "addon/state.hpp"
#include "config.hpp"

#include "addon/manager.hpp"
#include "font.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/addon/state.hpp
Expand Up @@ -16,6 +16,7 @@
#define ADDON_STATE_HPP_INCLUDED

#include "addon/info.hpp"
#include <map>

/** Defines various add-on installation statuses. */
enum ADDON_STATUS {
Expand Down
2 changes: 1 addition & 1 deletion src/editor/palette/common_palette.hpp
Expand Up @@ -16,10 +16,10 @@
#define COMMON_PALETTES_H_INCLUDED

#include "display.hpp"
#include "config.hpp"
#include "gui/widgets/widget.hpp"

struct SDL_Rect;
class config;

namespace editor {

Expand Down
3 changes: 2 additions & 1 deletion src/editor/toolkit/editor_toolkit.hpp
Expand Up @@ -16,14 +16,15 @@
#define EDITOR_TOOLKIT_H_INCLUDED


#include "config.hpp"
#include "editor/map/context_manager.hpp"
#include "editor/palette/palette_manager.hpp"
#include "editor/toolkit/brush.hpp"
#include "hotkey/hotkey_command.hpp"

#include <boost/scoped_ptr.hpp>

class config;

namespace editor {


Expand Down
1 change: 1 addition & 0 deletions src/game_classification.cpp
Expand Up @@ -15,6 +15,7 @@
#include "global.hpp"
#include "game_classification.hpp"
#include "game_config.hpp"
#include "config.hpp"
#include "util.hpp"
#include "serialization/string_utils.hpp"
#include "log.hpp"
Expand Down
4 changes: 3 additions & 1 deletion src/game_classification.hpp
Expand Up @@ -15,9 +15,11 @@
#ifndef GAME_CLASSIFICATION_HPP_INCLUDED
#define GAME_CLASSIFICATION_HPP_INCLUDED

#include "config.hpp"
#include "make_enum.hpp"
#include "savegame_config.hpp"
#include <vector>

class config;

/// The default difficulty setting for campaigns.
extern const std::string DEFAULT_DIFFICULTY;
Expand Down
7 changes: 7 additions & 0 deletions src/game_end_exceptions.cpp
Expand Up @@ -49,3 +49,10 @@ void end_level_data::read(const config& cfg)
proceed_to_next_level = cfg["proceed_to_next_level"].to_bool(true);
is_victory = cfg["is_victory"].to_bool(true);
}

config end_level_data::to_config() const
{
config r;
write(r);
return r;
}
10 changes: 3 additions & 7 deletions src/game_end_exceptions.hpp
Expand Up @@ -24,13 +24,14 @@

#include "lua_jailbreak_exception.hpp"

#include "config.hpp"
#include "make_enum.hpp"

#include <string>
#include <exception>
#include <boost/optional.hpp>

class config;

MAKE_ENUM(LEVEL_RESULT,
(VICTORY, "victory")
(DEFEAT, "defeat")
Expand Down Expand Up @@ -103,12 +104,7 @@ struct end_level_data

void read(const config& cfg);

config to_config() const
{
config r;
write(r);
return r;
}
config to_config() const;
};
inline void throw_quit_game_exception()
{
Expand Down
1 change: 0 additions & 1 deletion src/gui/dialogs/addon_list.hpp
Expand Up @@ -19,7 +19,6 @@
#include "../widgets/generator.hpp"
#include "gui/widgets/pane.hpp"

class config;
#include "config.hpp" // needed for config::const_child_itors

namespace gui2
Expand Down
1 change: 0 additions & 1 deletion src/gui/dialogs/campaign_selection.hpp
Expand Up @@ -17,7 +17,6 @@

#include "gui/dialogs/dialog.hpp"

#include "config.hpp"
#include "game_initialization/create_engine.hpp"

namespace gui2
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/core_selection.hpp
Expand Up @@ -17,7 +17,7 @@

#include "gui/dialogs/dialog.hpp"

#include "config.hpp"
class config;

namespace gui2
{
Expand Down
1 change: 0 additions & 1 deletion src/gui/dialogs/editor/editor_edit_scenario.hpp
Expand Up @@ -16,7 +16,6 @@
#define GUI_DIALOGS_EDITOR_EDIT_SCENARIO_HPP_INCLUDED

#include "gui/dialogs/dialog.hpp"
#include "config.hpp"

namespace gui2
{
Expand Down
1 change: 0 additions & 1 deletion src/gui/dialogs/editor/editor_edit_side.hpp
Expand Up @@ -16,7 +16,6 @@
#define GUI_DIALOGS_EDITOR_EDIT_SIDE_HPP_INCLUDED

#include "gui/dialogs/dialog.hpp"
#include "config.hpp"
#include "team.hpp"

namespace gui2
Expand Down
1 change: 0 additions & 1 deletion src/gui/dialogs/lobby_player_info.hpp
Expand Up @@ -16,7 +16,6 @@
#define GUI_DIALOGS_LOBBY_PLAYER_INFO_HPP_INCLUDED

#include "gui/dialogs/dialog.hpp"
#include "config.hpp"
#include "chat_events.hpp"
#include "gui/dialogs/lobby/lobby_info.hpp"

Expand Down
2 changes: 2 additions & 0 deletions src/help/help.cpp
Expand Up @@ -90,6 +90,8 @@ void show_unit_description(CVideo& video, const unit_type &t)
help::show_unit_help(video, t.id(), t.show_variations_in_help(), hide_help);
}

extern config dummy_cfg;

help_manager::help_manager(const config *cfg) //, gamemap *_map)
{
game_cfg = cfg == NULL ? &dummy_cfg : cfg;
Expand Down
3 changes: 1 addition & 2 deletions src/help/help_impl.hpp
Expand Up @@ -32,7 +32,6 @@
#ifndef HELP_IMPL_INCLUDED
#define HELP_IMPL_INCLUDED

#include "config.hpp" // for config
#include "exceptions.hpp" // for error
#include "font.hpp" // for line_width, relative_size

Expand All @@ -44,6 +43,7 @@
#include <boost/shared_ptr.hpp>
#include <SDL.h> // for SDL_Color, SDL_Surface

class config;
class unit_type;
class terrain_type_data;
typedef boost::shared_ptr<terrain_type_data> tdata_cache;
Expand Down Expand Up @@ -322,7 +322,6 @@ extern int last_num_encountered_units;
extern int last_num_encountered_terrains;
extern bool last_debug_state;

extern config dummy_cfg;
extern std::vector<std::string> empty_string_vector;
extern const int max_section_level;
extern const int title_size;
Expand Down
1 change: 1 addition & 0 deletions src/hotkey/hotkey_item.cpp
Expand Up @@ -16,6 +16,7 @@
#include "log.hpp"
#include "hotkey_item.hpp"
#include "hotkey_command.hpp"
#include "config.hpp"

#define GETTEXT_DOMAIN "wesnoth-lib"

Expand Down
3 changes: 2 additions & 1 deletion src/hotkey/hotkey_item.hpp
Expand Up @@ -16,7 +16,6 @@
#ifndef HOTKEY_ITEM_HPP_INCLUDED
#define HOTKEY_ITEM_HPP_INCLUDED

#include "config.hpp"
#include "SDL_events.h"
#include "SDL.h"
#include <boost/shared_ptr.hpp>
Expand All @@ -26,6 +25,8 @@
#include "sdl/keyboard.hpp"
#endif

class config;

namespace hotkey {

/* forward declarations */
Expand Down
3 changes: 2 additions & 1 deletion src/network_asio.hpp
Expand Up @@ -31,7 +31,8 @@
#include <boost/asio.hpp>
#include <boost/optional.hpp>
#include "exceptions.hpp"
#include "config.hpp"

class config;

namespace network_asio {

Expand Down
2 changes: 1 addition & 1 deletion src/replay.hpp
Expand Up @@ -20,7 +20,6 @@
#ifndef REPLAY_H_INCLUDED
#define REPLAY_H_INCLUDED

#include "config.hpp"
#include "map_location.hpp"

#include <deque>
Expand All @@ -31,6 +30,7 @@ class game_display;
class terrain_label;
class unit_map;
class play_controller;
class config;
struct time_of_day;

class chat_msg {
Expand Down
4 changes: 2 additions & 2 deletions src/replay_helper.hpp
Expand Up @@ -14,9 +14,9 @@
#ifndef REPLAY_HELPER_H_INCLUDED
#define REPLAY_HELPER_H_INCLUDED


#include "config.hpp"
#include <vector>
#include <string>
class config;
struct map_location;
struct time_of_day;

Expand Down
1 change: 0 additions & 1 deletion src/scripting/lua_api.hpp
Expand Up @@ -17,7 +17,6 @@

#include <cstddef>
#include <string>
#include "config.hpp" // forward declaration of the nested type config::attribute_value is not possible
#include "lua_types.hpp" // the luatype typedef
#include "unit_ptr.hpp"

Expand Down
3 changes: 2 additions & 1 deletion src/serialization/schema_validator.hpp
Expand Up @@ -18,7 +18,6 @@
#include "serialization/validator.hpp"
#include "tools/schema/tag.hpp"

#include "config.hpp"
#include "config_cache.hpp"
#include "serialization/parser.hpp"

Expand All @@ -31,6 +30,8 @@
#include <string>
#include <stack>

class config;

/** @file
* One of the realizations of serialization/validator.hpp abstract validator.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/synced_checkup.hpp
Expand Up @@ -15,7 +15,7 @@
#ifndef SYNCED_CHECKUP_H_INCLUDED
#define SYNCED_CHECKUP_H_INCLUDED

#include "config.hpp"
class config;
struct map_location;
/**
A class to check whether the results that were calculated in the replay match the results calculated during the original game.
Expand Down
4 changes: 3 additions & 1 deletion src/synced_commands.hpp
Expand Up @@ -16,9 +16,11 @@

#include <map>
#include <exception>
#include "config.hpp"

#include "utils/boost_function_guarded.hpp"

class config;

class synced_command {
public:
/*
Expand Down

0 comments on commit baed863

Please sign in to comment.