From 16905976c82c57fdc98a8988392354597f166a12 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Wed, 20 Dec 2017 13:12:19 +0000 Subject: improving compilation speed --- yage/core/camera2d.cpp | 1 + yage/core/camera2d.h | 4 ++-- yage/core/imageloader.cpp | 4 +--- yage/core/imageloader.h | 4 ++-- yage/core/inputmanager.h | 2 ++ yage/core/logger.cpp | 2 ++ yage/core/logger.h | 3 +-- yage/core/logsink.h | 3 +++ yage/core/spritesheet.cpp | 33 ++++++++++++++++----------------- yage/core/spritesheet.h | 7 +++++-- 10 files changed, 35 insertions(+), 28 deletions(-) (limited to 'yage/core') diff --git a/yage/core/camera2d.cpp b/yage/core/camera2d.cpp index d5640c3f..a2d40a78 100644 --- a/yage/core/camera2d.cpp +++ b/yage/core/camera2d.cpp @@ -7,6 +7,7 @@ */ #include "camera2d.h" +#include "glslprogram.h" #include diff --git a/yage/core/camera2d.h b/yage/core/camera2d.h index 333f907d..5d2fc8a2 100644 --- a/yage/core/camera2d.h +++ b/yage/core/camera2d.h @@ -17,14 +17,14 @@ #ifndef YAGE_CAMERA2D_H #define YAGE_CAMERA2D_H -#include "glslprogram.h" - #include #include namespace yage { +class GlslProgram; + class Camera2D { private: diff --git a/yage/core/imageloader.cpp b/yage/core/imageloader.cpp index ae67a94a..45424799 100644 --- a/yage/core/imageloader.cpp +++ b/yage/core/imageloader.cpp @@ -7,11 +7,9 @@ */ #include "imageloader.h" +#include "texture.h" -#ifndef UNIT_TESTS #include -#endif - #include #include diff --git a/yage/core/imageloader.h b/yage/core/imageloader.h index ab9f9e4d..ca68bd58 100644 --- a/yage/core/imageloader.h +++ b/yage/core/imageloader.h @@ -9,13 +9,13 @@ #ifndef IMAGE_LOADER_H #define IMAGE_LOADER_H -#include "texture.h" - #include namespace yage { +class Texture; + class ImageLoader { public: diff --git a/yage/core/inputmanager.h b/yage/core/inputmanager.h index 9fabd997..4b74ed90 100644 --- a/yage/core/inputmanager.h +++ b/yage/core/inputmanager.h @@ -24,5 +24,7 @@ public: void keyReleased(unsigned key); bool isKeyPressed(unsigned key) const; }; + } // namespace yage + #endif diff --git a/yage/core/logger.cpp b/yage/core/logger.cpp index 7a58efb6..355de5bc 100644 --- a/yage/core/logger.cpp +++ b/yage/core/logger.cpp @@ -10,6 +10,8 @@ #include "logmessage.h" #include "logsink.h" +#include + #include #include #include diff --git a/yage/core/logger.h b/yage/core/logger.h index 76f38641..44c35227 100644 --- a/yage/core/logger.h +++ b/yage/core/logger.h @@ -9,8 +9,6 @@ #ifndef YAGE_CORE_LOGGER_H #define YAGE_CORE_LOGGER_H -#include - #include #include #include @@ -18,6 +16,7 @@ namespace yage { +class Active; class LogMessage; class LogSink; diff --git a/yage/core/logsink.h b/yage/core/logsink.h index 064abc63..b597fc24 100644 --- a/yage/core/logsink.h +++ b/yage/core/logsink.h @@ -6,9 +6,12 @@ * ---------------------------------------------------------------------------- */ +/// @file + #ifndef YAGE_CORE_LOGSINK_H #define YAGE_CORE_LOGSINK_H +/// @todo remove the include to make compilation faster #include "logmessage.h" #include diff --git a/yage/core/spritesheet.cpp b/yage/core/spritesheet.cpp index e18d7fe8..f61b668a 100644 --- a/yage/core/spritesheet.cpp +++ b/yage/core/spritesheet.cpp @@ -6,27 +6,26 @@ * ---------------------------------------------------------------------------- */ -/** @file - */ +/// @file #include "spritesheet.h" +#include +#include + #include #include #include #include -#include -#include - -using namespace std; -using namespace rapidjson; -using namespace yage::details; +using rapidjson::Document; +using yage::details::Coordinate; +using yage::details::SpriteMap; namespace yage { -SpriteSheet::SpriteSheet(string pngFileName, string jsonFileName) +SpriteSheet::SpriteSheet(std::string pngFileName, std::string jsonFileName) { int jsonWidth, jsonHeight; fileLocations_ = @@ -34,23 +33,23 @@ SpriteSheet::SpriteSheet(string pngFileName, string jsonFileName) texture_ = ImageLoader::loadPng(pngFileName); if (texture_.width != jsonWidth) - throw runtime_error("JSON width does not match texture width"); + throw std::runtime_error("JSON width does not match texture width"); if (texture_.height != jsonHeight) - throw runtime_error("JSON height does not match texture height"); + throw std::runtime_error("JSON height does not match texture height"); } -string SpriteSheet::fileContent(string jsonFileName) const +std::string SpriteSheet::fileContent(std::string jsonFileName) const { - ifstream inputFile(jsonFileName); + std::ifstream inputFile(jsonFileName); - stringstream stream; + std::stringstream stream; stream << inputFile.rdbuf(); return stream.str(); } SpriteMap SpriteSheet::parseJson(int &width, int &height, - string jsonContent) const + std::string jsonContent) const { SpriteMap spriteMap; Document jsonAtlas; @@ -62,7 +61,7 @@ SpriteMap SpriteSheet::parseJson(int &width, int &height, for (auto &texture : jsonAtlas["sprites"].GetObject()) { Coordinate coord; for (auto &value : texture.value.GetObject()) { - string keyName{value.value.GetString()}; + std::string keyName{value.value.GetString()}; int keyValue{value.value.GetInt()}; if (keyName == "x") { coord.x = keyValue; @@ -73,7 +72,7 @@ SpriteMap SpriteSheet::parseJson(int &width, int &height, } else if (keyName == "height") { coord.height = keyValue; } else { - throw runtime_error("JSON key incorrect: " + keyName); + throw std::runtime_error("JSON key incorrect: " + keyName); } } spriteMap[texture.name.GetString()] = coord; diff --git a/yage/core/spritesheet.h b/yage/core/spritesheet.h index 2ead0ba1..6ae8d266 100644 --- a/yage/core/spritesheet.h +++ b/yage/core/spritesheet.h @@ -6,12 +6,15 @@ * ---------------------------------------------------------------------------- */ -/** @file - */ +/// @file #ifndef YAGE_SPRITESHEET_H #define YAGE_SPRITESHEET_H +/** @todo think of removing this, by, for example, using a pointer + * This could be more efficient when copying the texture out of the + * spritesheet. + */ #include "texture.h" #include -- cgit