From 2b4d52ea3ceda91483757d29435aadffbd1b38ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 9 Jan 2014 14:51:55 +0100 Subject: [PATCH] SceneGraph: template implementation file for Drawable class. The class has virtual member, so it's good to have it in one place and not in thousand five ones. --- src/SceneGraph/CMakeLists.txt | 1 + src/SceneGraph/Drawable.h | 12 +++++++++- src/SceneGraph/Drawable.hpp | 39 ++++++++++++++++++++++++++++++++ src/SceneGraph/instantiation.cpp | 4 ++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/SceneGraph/Drawable.hpp diff --git a/src/SceneGraph/CMakeLists.txt b/src/SceneGraph/CMakeLists.txt index 32b018ceb..72822a81a 100644 --- a/src/SceneGraph/CMakeLists.txt +++ b/src/SceneGraph/CMakeLists.txt @@ -51,6 +51,7 @@ set(MagnumSceneGraph_HEADERS Camera3D.h Camera3D.hpp Drawable.h + Drawable.hpp DualComplexTransformation.h DualQuaternionTransformation.h RigidMatrixTransformation2D.h diff --git a/src/SceneGraph/Drawable.h b/src/SceneGraph/Drawable.h index 305251c8d..292907f57 100644 --- a/src/SceneGraph/Drawable.h +++ b/src/SceneGraph/Drawable.h @@ -114,6 +114,16 @@ void MyApplication::drawEvent() { } @endcode +@section Drawable-explicit-specializations Explicit template specializations + +The following specializations are explicitly compiled into @ref SceneGraph +library. For other specializations (e.g. using @ref Double type) you have to +use @ref Drawable.hpp implementation file to avoid linker errors. See also +@ref compilation-speedup-hpp for more information. + +- @ref Drawable2D +- @ref Drawable3D + @see @ref scenegraph, @ref BasicDrawable2D, @ref BasicDrawable3D, @ref Drawable2D, @ref Drawable3D, @ref DrawableGroup */ @@ -127,7 +137,7 @@ template class Drawable: public AbstractGrouped * Adds the feature to the object and also to the group, if specified. * Otherwise you can use DrawableGroup::add(). */ - explicit Drawable(AbstractObject& object, DrawableGroup* drawables = nullptr): AbstractGroupedFeature, T>(object, drawables) {} + explicit Drawable(AbstractObject& object, DrawableGroup* drawables = nullptr); /** * @brief Group containing this drawable diff --git a/src/SceneGraph/Drawable.hpp b/src/SceneGraph/Drawable.hpp new file mode 100644 index 000000000..222b790ea --- /dev/null +++ b/src/SceneGraph/Drawable.hpp @@ -0,0 +1,39 @@ +#ifndef Magnum_SceneGraph_Drawable_hpp +#define Magnum_SceneGraph_Drawable_hpp +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief @ref compilation-speedup-hpp "Template implementation" for @ref Drawable.h + */ + +#include "Drawable.h" + +namespace Magnum { namespace SceneGraph { + +template Drawable::Drawable(AbstractObject& object, DrawableGroup* drawables): AbstractGroupedFeature, T>(object, drawables) {} + +}} + +#endif diff --git a/src/SceneGraph/instantiation.cpp b/src/SceneGraph/instantiation.cpp index 079199ddc..4530719d4 100644 --- a/src/SceneGraph/instantiation.cpp +++ b/src/SceneGraph/instantiation.cpp @@ -26,6 +26,7 @@ #include "SceneGraph/Animable.hpp" #include "SceneGraph/Camera2D.hpp" #include "SceneGraph/Camera3D.hpp" +#include "SceneGraph/Drawable.hpp" #include "SceneGraph/DualComplexTransformation.h" #include "SceneGraph/DualQuaternionTransformation.h" #include "SceneGraph/FeatureGroup.hpp" @@ -66,6 +67,9 @@ template class MAGNUM_SCENEGRAPH_EXPORT_HPP AbstractCamera<3, Float>; template class MAGNUM_SCENEGRAPH_EXPORT_HPP BasicCamera2D; template class MAGNUM_SCENEGRAPH_EXPORT_HPP BasicCamera3D; +template class MAGNUM_SCENEGRAPH_EXPORT_HPP Drawable<2, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT_HPP Drawable<3, Float>; + template class MAGNUM_SCENEGRAPH_EXPORT_HPP Object>; template class MAGNUM_SCENEGRAPH_EXPORT_HPP Object>; template class MAGNUM_SCENEGRAPH_EXPORT_HPP Object>;