From: ThorstenB Date: Fri, 4 May 2012 22:07:07 +0000 (+0200) Subject: Move vector property templates to separate header file. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=44db6d9e44aaae1568182b1db6e7a892427f2133;p=simgear.git Move vector property templates to separate header file. Fixes the "weirdness" with MSVC complaining about incomplete class specs, since forward declarations (SGMathFwd.hxx) are used in props.hxx only. Only the few extended (vector) property templates require including the full SGMath.hxx (with MSVC) - and these are used in few places. --- diff --git a/simgear/props/CMakeLists.txt b/simgear/props/CMakeLists.txt index f0dcbed8..a11e703e 100644 --- a/simgear/props/CMakeLists.txt +++ b/simgear/props/CMakeLists.txt @@ -10,6 +10,7 @@ set(HEADERS props_io.hxx propsfwd.hxx tiedpropertylist.hxx + vectorPropTemplates.hxx ) set(SOURCES diff --git a/simgear/props/propertyObject_test.cxx b/simgear/props/propertyObject_test.cxx index c09292e7..7021395a 100644 --- a/simgear/props/propertyObject_test.cxx +++ b/simgear/props/propertyObject_test.cxx @@ -15,9 +15,6 @@ #include #include -// working around MSVC weirdness with props.hxx and SGMathFwd -#include - #include "propertyObject.hxx" #include diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index 95b85c77..3aeaaf17 100644 --- a/simgear/props/props.cxx +++ b/simgear/props/props.cxx @@ -11,6 +11,7 @@ #endif #include "props.hxx" +#include "vectorPropTemplates.hxx" #include diff --git a/simgear/props/props.hxx b/simgear/props/props.hxx index 38c9c0a2..ff174c39 100644 --- a/simgear/props/props.hxx +++ b/simgear/props/props.hxx @@ -63,13 +63,6 @@ inline T parseString(const std::string& str) return result; } -// Extended properties -template<> -std::istream& readFrom(std::istream& stream, SGVec3d& result); -template<> -std::istream& readFrom(std::istream& stream, SGVec4d& result); - - /** * Property value types. */ @@ -164,19 +157,6 @@ DEFINTERNALPROP(const char *, STRING); DEFINTERNALPROP(const char[], STRING); #undef DEFINTERNALPROP -template<> -struct PropertyTraits -{ - static const Type type_tag = VEC3D; - enum { Internal = 0 }; -}; - -template<> -struct PropertyTraits -{ - static const Type type_tag = VEC4D; - enum { Internal = 0 }; -}; } } @@ -689,11 +669,6 @@ std::istream& SGRawBase::readFrom(std::istream& stream) return stream; } -template<> -std::ostream& SGRawBase::printOn(std::ostream& stream) const; -template<> -std::ostream& SGRawBase::printOn(std::ostream& stream) const; - /** * The smart pointer that manage reference counting diff --git a/simgear/props/props_io.cxx b/simgear/props/props_io.cxx index 8fae12f8..297cad87 100644 --- a/simgear/props/props_io.cxx +++ b/simgear/props/props_io.cxx @@ -14,7 +14,7 @@ #include -#include // atof() atoi() +#include // atof() atoi() #include #include @@ -25,11 +25,12 @@ #include "props.hxx" #include "props_io.hxx" +#include "vectorPropTemplates.hxx" #include #include #include -#include // strcmp() +#include // strcmp() #include #include diff --git a/simgear/props/props_test.cxx b/simgear/props/props_test.cxx index f8299263..14f52348 100644 --- a/simgear/props/props_test.cxx +++ b/simgear/props/props_test.cxx @@ -11,9 +11,6 @@ #include -// working around MSVC weirdness with props.hxx and SGMathFwd -#include - #include "props.hxx" #include "props_io.hxx" diff --git a/simgear/props/vectorPropTemplates.hxx b/simgear/props/vectorPropTemplates.hxx new file mode 100644 index 00000000..d3425c85 --- /dev/null +++ b/simgear/props/vectorPropTemplates.hxx @@ -0,0 +1,49 @@ +// vectorPropTemplates.hxx -- Templates Requiring Vector Properties +// +// Separate header file for any templates requiring SGVecXX vector types. + +#ifndef __VECTORPROPTEMPLATES_HXX +#define __VECTORPROPTEMPLATES_HXX + +#include "props.hxx" + +// The templates below depend on the full SGMath.hxx include. Forward +// declarations (SGMathFwd.hxx) would be insufficient here (at least with MSVC). +#include + +namespace simgear +{ + +// Extended properties +template<> +std::istream& readFrom(std::istream& stream, SGVec3d& result); +template<> +std::istream& readFrom(std::istream& stream, SGVec4d& result); + +namespace props +{ + +template<> +struct PropertyTraits +{ + static const Type type_tag = VEC3D; + enum { Internal = 0 }; +}; + +template<> +struct PropertyTraits +{ + static const Type type_tag = VEC4D; + enum { Internal = 0 }; +}; +} +} + +template<> +std::ostream& SGRawBase::printOn(std::ostream& stream) const; +template<> +std::ostream& SGRawBase::printOn(std::ostream& stream) const; + +#endif // __VECTORPROPTEMPLATES_HXX + +// end of vectorPropTemplates.hxx diff --git a/simgear/scene/material/Effect.cxx b/simgear/scene/material/Effect.cxx index 978aa064..2e103185 100644 --- a/simgear/scene/material/Effect.cxx +++ b/simgear/scene/material/Effect.cxx @@ -74,7 +74,7 @@ #include #include #include - +#include namespace simgear diff --git a/simgear/scene/material/TextureBuilder.cxx b/simgear/scene/material/TextureBuilder.cxx index c06883aa..99527fcb 100644 --- a/simgear/scene/material/TextureBuilder.cxx +++ b/simgear/scene/material/TextureBuilder.cxx @@ -43,6 +43,7 @@ #include #include #include +#include namespace simgear { diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index 6e149230..e25e6b13 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -479,7 +480,7 @@ void SGMaterial::buildEffectProperties(const SGReaderWriterOptions* options) makeChild(propRoot, "inherits-from")->setStringValue(effect); SGPropertyNode* paramProp = makeChild(propRoot, "parameters"); SGPropertyNode* materialProp = makeChild(paramProp, "material"); - makeChild(materialProp, "ambient")->setValue(SGVec4d(ambient)); + makeChild(materialProp, "ambient")->setValue(SGVec4d(ambient)); makeChild(materialProp, "diffuse")->setValue(SGVec4d(diffuse)); makeChild(materialProp, "specular")->setValue(SGVec4d(specular)); makeChild(materialProp, "emissive")->setValue(SGVec4d(emission)); diff --git a/simgear/scene/model/SGLightAnimation.cxx b/simgear/scene/model/SGLightAnimation.cxx index 2fc90a8d..5ecb07ee 100644 --- a/simgear/scene/model/SGLightAnimation.cxx +++ b/simgear/scene/model/SGLightAnimation.cxx @@ -26,6 +26,7 @@ #include #include +#include #include #include #include