diff --git a/doc/compilation-speedup.dox b/doc/compilation-speedup.dox index b14647277..5fb7d33da 100644 --- a/doc/compilation-speedup.dox +++ b/doc/compilation-speedup.dox @@ -14,6 +14,11 @@ floating-point vectors and matrices like @ref Vector3 and @ref Matrix4, but to actually use any of them, you have to include the respective header, e.g. Math/Vector3.h. +You are encouraged to use forward declarations also in your code. However, for +some types it can be too cumbersome -- e.g. too many template parameters, +typedefs etc. In this case a header with forward declarations is usually +available: see SceneGraph/SceneGraph.h for example. + @section compilation-speedup-templates Templates Many things in %Magnum are templated to allow handling of various types and diff --git a/src/SceneGraph/AbstractCamera.h b/src/SceneGraph/AbstractCamera.h index 48c7890d2..64707a78e 100644 --- a/src/SceneGraph/AbstractCamera.h +++ b/src/SceneGraph/AbstractCamera.h @@ -27,14 +27,6 @@ namespace Magnum { namespace SceneGraph { -template class Drawable; -template class FeatureGroup; -#ifndef MAGNUM_GCC46_COMPATIBILITY -template using DrawableGroup = FeatureGroup, T>; -#else -template class DrawableGroup; -#endif - /** @relates AbstractCamera @brief Camera aspect ratio policy @@ -72,7 +64,12 @@ file to avoid linker errors. See also relevant sections in @see Drawable, DrawableGroup, AbstractCamera2D, AbstractCamera3D */ -template class SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature { public: /** * @brief Constructor @@ -200,12 +197,6 @@ template using AbstractCamera3D = AbstractCamera<3, T>; typedef AbstractCamera<3, T = GLfloat> AbstractCamera3D; #endif -/* Make implementers' life easier */ -#ifndef MAGNUM_GCC46_COMPATIBILITY -template using DrawableGroup2D = DrawableGroup<2, T>; -template using DrawableGroup3D = DrawableGroup<3, T>; -#endif - }} #endif diff --git a/src/SceneGraph/AbstractFeature.h b/src/SceneGraph/AbstractFeature.h index 34e3feffd..f88aa09f1 100644 --- a/src/SceneGraph/AbstractFeature.h +++ b/src/SceneGraph/AbstractFeature.h @@ -114,10 +114,11 @@ which is automatically extracted from the pointer in our constructor. @see AbstractFeature2D, AbstractFeature3D */ +#ifndef DOXYGEN_GENERATING_OUTPUT +template class AbstractFeature: private Corrade::Containers::LinkedListItem, AbstractObject> +#else template class AbstractFeature - #ifndef DOXYGEN_GENERATING_OUTPUT - : private Corrade::Containers::LinkedListItem, AbstractObject> - #endif +#endif { friend class Corrade::Containers::LinkedList>; friend class Corrade::Containers::LinkedListItem, AbstractObject>; diff --git a/src/SceneGraph/AbstractGroupedFeature.h b/src/SceneGraph/AbstractGroupedFeature.h index 8e17a39d2..c88379183 100644 --- a/src/SceneGraph/AbstractGroupedFeature.h +++ b/src/SceneGraph/AbstractGroupedFeature.h @@ -47,7 +47,12 @@ typedef SceneGraph::FeatureGroup3D DrawableGroup; @see AbstractGroupedFeature2D, AbstractGroupedFeature3D, FeatureGroup, FeatureGroup2D, FeatureGroup3D */ -template class AbstractGroupedFeature: public AbstractFeature { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class AbstractGroupedFeature: public AbstractFeature { friend class FeatureGroup; public: @@ -123,12 +128,6 @@ template using AbstractGroupedFeature3D = Abst typedef AbstractGroupedFeature<3, Derived, T = GLfloat> AbstractGroupedFeature3D; #endif -/* Make implementers' life easier */ -#ifndef MAGNUM_GCC46_COMPATIBILITY -template using FeatureGroup2D = FeatureGroup<2, Feature, T>; -template using FeatureGroup3D = FeatureGroup<3, Feature, T>; -#endif - }} #endif diff --git a/src/SceneGraph/AbstractObject.h b/src/SceneGraph/AbstractObject.h index 63d962981..9213d01bc 100644 --- a/src/SceneGraph/AbstractObject.h +++ b/src/SceneGraph/AbstractObject.h @@ -22,14 +22,12 @@ #include #include "DimensionTraits.h" -#include "Magnum.h" +#include "SceneGraph.h" #include "magnumCompatibility.h" namespace Magnum { namespace SceneGraph { -template class AbstractFeature; - /** @brief Base for objects @@ -39,10 +37,11 @@ instead. See also @ref scenegraph for more information. @see AbstractObject2D, AbstractObject3D */ +#ifndef DOXYGEN_GENERATING_OUTPUT +template class AbstractObject: private Corrade::Containers::LinkedList> +#else template class AbstractObject - #ifndef DOXYGEN_GENERATING_OUTPUT - : private Corrade::Containers::LinkedList> - #endif +#endif { friend class Corrade::Containers::LinkedList>; friend class Corrade::Containers::LinkedListItem, AbstractObject>; diff --git a/src/SceneGraph/AbstractTransformation.h b/src/SceneGraph/AbstractTransformation.h index a2c73d818..8b9849ffa 100644 --- a/src/SceneGraph/AbstractTransformation.h +++ b/src/SceneGraph/AbstractTransformation.h @@ -21,13 +21,11 @@ #include -#include "Magnum.h" #include "DimensionTraits.h" +#include "SceneGraph.h" namespace Magnum { namespace SceneGraph { -template class Object; - /** @brief Base for transformations @@ -43,7 +41,12 @@ When sublassing, you have to: @see AbstractTransformation2D, AbstractTransformation3D */ -template class AbstractTransformation { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class AbstractTransformation { public: /** @brief Underlying floating-point type */ typedef T Type; diff --git a/src/SceneGraph/AbstractTranslationRotation2D.h b/src/SceneGraph/AbstractTranslationRotation2D.h index 22d407b14..e06566397 100644 --- a/src/SceneGraph/AbstractTranslationRotation2D.h +++ b/src/SceneGraph/AbstractTranslationRotation2D.h @@ -28,7 +28,12 @@ namespace Magnum { namespace SceneGraph { @see AbstractTranslationRotation3D */ -template class AbstractTranslationRotation2D: public AbstractTransformation<2, T> { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class AbstractTranslationRotation2D: public AbstractTransformation<2, T> { public: /** * @brief Translate object diff --git a/src/SceneGraph/AbstractTranslationRotation3D.h b/src/SceneGraph/AbstractTranslationRotation3D.h index 4bc174a59..1175b8af2 100644 --- a/src/SceneGraph/AbstractTranslationRotation3D.h +++ b/src/SceneGraph/AbstractTranslationRotation3D.h @@ -29,7 +29,12 @@ namespace Magnum { namespace SceneGraph { @see AbstractTranslationRotation2D */ -template class AbstractTranslationRotation3D: public AbstractTransformation<3, T> { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class AbstractTranslationRotation3D: public AbstractTransformation<3, T> { public: /** * @brief Translate object diff --git a/src/SceneGraph/AbstractTranslationRotationScaling2D.h b/src/SceneGraph/AbstractTranslationRotationScaling2D.h index 6d5d3f66d..26da23b36 100644 --- a/src/SceneGraph/AbstractTranslationRotationScaling2D.h +++ b/src/SceneGraph/AbstractTranslationRotationScaling2D.h @@ -28,7 +28,12 @@ namespace Magnum { namespace SceneGraph { @see AbstractTranslationRotationScaling2D */ -template class AbstractTranslationRotationScaling2D: public AbstractTranslationRotation2D { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class AbstractTranslationRotationScaling2D: public AbstractTranslationRotation2D { public: /** * @brief Scale object diff --git a/src/SceneGraph/AbstractTranslationRotationScaling3D.h b/src/SceneGraph/AbstractTranslationRotationScaling3D.h index c4c880ae5..ab4ffd4f6 100644 --- a/src/SceneGraph/AbstractTranslationRotationScaling3D.h +++ b/src/SceneGraph/AbstractTranslationRotationScaling3D.h @@ -28,7 +28,12 @@ namespace Magnum { namespace SceneGraph { @see AbstractTranslationRotationScaling2D */ -template class AbstractTranslationRotationScaling3D: public AbstractTranslationRotation3D { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class AbstractTranslationRotationScaling3D: public AbstractTranslationRotation3D { public: /** * @brief Scale object diff --git a/src/SceneGraph/CMakeLists.txt b/src/SceneGraph/CMakeLists.txt index 753944943..1cd0780fd 100644 --- a/src/SceneGraph/CMakeLists.txt +++ b/src/SceneGraph/CMakeLists.txt @@ -22,6 +22,7 @@ set(MagnumSceneGraph_HEADERS Object.h Object.hpp Scene.h + SceneGraph.h magnumSceneGraphVisibility.h) add_library(MagnumSceneGraphObjects OBJECT ${MagnumSceneGraph_SRCS}) diff --git a/src/SceneGraph/Camera2D.h b/src/SceneGraph/Camera2D.h index 9f9845797..c38e9d052 100644 --- a/src/SceneGraph/Camera2D.h +++ b/src/SceneGraph/Camera2D.h @@ -38,7 +38,12 @@ avoid linker errors. See @ref compilation-speedup-hpp for more information. @see Camera3D, Drawable, DrawableGroup */ -template class SCENEGRAPH_EXPORT Camera2D: public AbstractCamera<2, T> { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class SCENEGRAPH_EXPORT Camera2D: public AbstractCamera<2, T> { public: /** * @brief Constructor diff --git a/src/SceneGraph/Camera3D.h b/src/SceneGraph/Camera3D.h index c34e8ecb2..4c6056fc5 100644 --- a/src/SceneGraph/Camera3D.h +++ b/src/SceneGraph/Camera3D.h @@ -43,7 +43,12 @@ avoid linker errors. See @ref compilation-speedup-hpp for more information. @see Camera2D, Drawable, DrawableGroup */ -template class SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { public: /** * @brief Constructor diff --git a/src/SceneGraph/Drawable.h b/src/SceneGraph/Drawable.h index 5493fe819..983d48716 100644 --- a/src/SceneGraph/Drawable.h +++ b/src/SceneGraph/Drawable.h @@ -23,14 +23,6 @@ namespace Magnum { namespace SceneGraph { -template class AbstractCamera; -template class Drawable; -#ifndef MAGNUM_GCC46_COMPATIBILITY -template using DrawableGroup = FeatureGroup, T>; -#else -template class DrawableGroup; -#endif - /** @brief %Drawable @@ -85,7 +77,12 @@ void MyApplication::drawEvent() { @see Drawable2D, Drawable3D, DrawableGroup2D, DrawableGroup3D */ -template class Drawable: public AbstractGroupedFeature, T> { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class Drawable: public AbstractGroupedFeature, T> { public: /** @copydoc AbstractGroupedFeature::AbstractGroupedFeature() */ inline Drawable(AbstractObject* object, DrawableGroup* group = nullptr): AbstractGroupedFeature, T>(object, group) {} @@ -145,7 +142,12 @@ See Drawable for more information. #if !defined(MAGNUM_GCC46_COMPATIBILITY) && !defined(DOXYGEN_GENERATING_OUTPUT) template using DrawableGroup = FeatureGroup, T>; #else -template class DrawableGroup: public FeatureGroup, T> {}; +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class DrawableGroup: public FeatureGroup, T> {}; #endif /** @@ -182,12 +184,6 @@ template using DrawableGroup3D = DrawableGroup<3, T>; typedef DrawableGroup<3, T = GLfloat> DrawableGroup3D; #endif -/* Make implementers' life easier */ -#ifndef MAGNUM_GCC46_COMPATIBILITY -template using AbstractCamera2D = AbstractCamera<2, T>; -template using AbstractCamera3D = AbstractCamera<3, T>; -#endif - }} #endif diff --git a/src/SceneGraph/FeatureGroup.h b/src/SceneGraph/FeatureGroup.h index b18b6220b..a6c32c703 100644 --- a/src/SceneGraph/FeatureGroup.h +++ b/src/SceneGraph/FeatureGroup.h @@ -19,24 +19,26 @@ * @brief Class Magnum::SceneGraph::FeatureGroup, alias Magnum::SceneGraph::FeatureGroup2D, Magnum::SceneGraph::FeatureGroup3D */ -#include #include #include #include -#include "Magnum.h" +#include "SceneGraph.h" namespace Magnum { namespace SceneGraph { -template class AbstractGroupedFeature; - /** @brief Group of features See AbstractGroupedFeature for more information. @see FeatureGroup2D, FeatureGroup3D */ -template class FeatureGroup { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class FeatureGroup { friend class AbstractGroupedFeature; public: diff --git a/src/SceneGraph/MatrixTransformation2D.h b/src/SceneGraph/MatrixTransformation2D.h index b25ea2e1f..31f1e3145 100644 --- a/src/SceneGraph/MatrixTransformation2D.h +++ b/src/SceneGraph/MatrixTransformation2D.h @@ -30,7 +30,12 @@ namespace Magnum { namespace SceneGraph { @see MatrixTransformation3D */ -template class MatrixTransformation2D: public AbstractTranslationRotationScaling2D { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class MatrixTransformation2D: public AbstractTranslationRotationScaling2D { public: /** @brief Transformation matrix type */ typedef typename DimensionTraits<2, T>::MatrixType DataType; diff --git a/src/SceneGraph/MatrixTransformation3D.h b/src/SceneGraph/MatrixTransformation3D.h index dff09d723..13a3a8574 100644 --- a/src/SceneGraph/MatrixTransformation3D.h +++ b/src/SceneGraph/MatrixTransformation3D.h @@ -30,7 +30,12 @@ namespace Magnum { namespace SceneGraph { @see MatrixTransformation2D */ -template class MatrixTransformation3D: public AbstractTranslationRotationScaling3D { +#ifndef DOXYGEN_GENERATING_OUTPUT +template +#else +template +#endif +class MatrixTransformation3D: public AbstractTranslationRotationScaling3D { public: /** @brief Transformation matrix type */ typedef typename DimensionTraits<3, T>::MatrixType DataType; diff --git a/src/SceneGraph/Object.h b/src/SceneGraph/Object.h index 94ac66e63..e4c4c75d1 100644 --- a/src/SceneGraph/Object.h +++ b/src/SceneGraph/Object.h @@ -28,8 +28,6 @@ namespace Magnum { namespace SceneGraph { -template class Scene; - #ifndef DOXYGEN_GENERATING_OUTPUT namespace Implementation { enum class ObjectFlag: std::uint8_t { diff --git a/src/SceneGraph/SceneGraph.h b/src/SceneGraph/SceneGraph.h new file mode 100644 index 000000000..1f0845df0 --- /dev/null +++ b/src/SceneGraph/SceneGraph.h @@ -0,0 +1,94 @@ +#ifndef Magnum_SceneGraph_SceneGraph_h +#define Magnum_SceneGraph_SceneGraph_h +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +/** @file + * @brief Forward declarations for Magnum::SceneGraph namespace + */ + +#include + +#include "Magnum.h" + +namespace Magnum { namespace SceneGraph { + +template class AbstractCamera; +#ifndef MAGNUM_GCC46_COMPATIBILITY +template using AbstractCamera2D = AbstractCamera<2, T>; +template using AbstractCamera3D = AbstractCamera<3, T>; +#endif + +template class AbstractFeature; +#ifndef MAGNUM_GCC46_COMPATIBILITY +template using AbstractFeature2D = AbstractFeature<2, T>; +template using AbstractFeature3D = AbstractFeature<3, T>; +#endif + +template class AbstractGroupedFeature; +#ifndef MAGNUM_GCC46_COMPATIBILITY +template using AbstractGroupedFeature2D = AbstractGroupedFeature<2, Derived, T>; +template using AbstractGroupedFeature3D = AbstractGroupedFeature<3, Derived, T>; +#endif + +template class AbstractObject; +#ifndef MAGNUM_GCC46_COMPATIBILITY +template using AbstractObject2D = AbstractObject<2, T>; +template using AbstractObject3D = AbstractObject<3, T>; +#endif + +template class AbstractTransformation; +#ifndef MAGNUM_GCC46_COMPATIBILITY +template using AbstractTransformation2D = AbstractTransformation<2, T>; +template using AbstractTransformation3D = AbstractTransformation<3, T>; +#endif + +template class AbstractTranslationRotation2D; +template class AbstractTranslationRotation3D; +template class AbstractTranslationRotationScaling2D; +template class AbstractTranslationRotationScaling3D; + +template class Camera2D; +template class Camera3D; + +template class Drawable; +#ifndef MAGNUM_GCC46_COMPATIBILITY +template using Drawable2D = Drawable<2, T>; +template using Drawable3D = Drawable<3, T>; +#endif + +template class FeatureGroup; +#ifndef MAGNUM_GCC46_COMPATIBILITY +template using FeatureGroup2D = FeatureGroup<2, Feature, T>; +template using FeatureGroup3D = FeatureGroup<3, Feature, T>; +#endif + +#ifndef MAGNUM_GCC46_COMPATIBILITY +template using DrawableGroup = FeatureGroup, T>; +template using DrawableGroup2D = DrawableGroup<2, T>; +template using DrawableGroup3D = DrawableGroup<3, T>; +#else +template class DrawableGroup; +#endif + +template class MatrixTransformation2D; +template class MatrixTransformation3D; + +template class Object; +template class Scene; + +}} + +#endif