]> git.mxchange.org Git - simgear.git/commitdiff
Move vector property templates to separate header file.
authorThorstenB <brehmt@gmail.com>
Fri, 4 May 2012 22:07:07 +0000 (00:07 +0200)
committerThorstenB <brehmt@gmail.com>
Fri, 4 May 2012 22:07:07 +0000 (00:07 +0200)
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.

simgear/props/CMakeLists.txt
simgear/props/propertyObject_test.cxx
simgear/props/props.cxx
simgear/props/props.hxx
simgear/props/props_io.cxx
simgear/props/props_test.cxx
simgear/props/vectorPropTemplates.hxx [new file with mode: 0644]
simgear/scene/material/Effect.cxx
simgear/scene/material/TextureBuilder.cxx
simgear/scene/material/mat.cxx
simgear/scene/model/SGLightAnimation.cxx

index f0dcbed8a9597d0bd28f6b9ae83e4705297905da..a11e703e7911f8527982329d0c11f0cef5ba7d06 100644 (file)
@@ -10,6 +10,7 @@ set(HEADERS
     props_io.hxx
     propsfwd.hxx
     tiedpropertylist.hxx
+    vectorPropTemplates.hxx
     )
 
 set(SOURCES 
index c09292e7c6f3b88cf46a2f08a77451ec6cd991d4..7021395a64839a0b0f3daa558b20425c87361476 100644 (file)
@@ -15,9 +15,6 @@
 #include <cstdlib>
 #include <cstring>
 
-// working around MSVC weirdness with props.hxx and SGMathFwd
-#include <simgear/math/SGMath.hxx>
-
 #include "propertyObject.hxx"
 
 #include <simgear/structure/exception.hxx>
index 95b85c77f6bc0d23934b04dfad4ab086df1a68cc..3aeaaf17598ce8c1221db18855c6dbdcbb84968c 100644 (file)
@@ -11,6 +11,7 @@
 #endif
 
 #include "props.hxx"
+#include "vectorPropTemplates.hxx"
 
 #include <algorithm>
 
index 38c9c0a2e2ea058cdd9eb684b047ef00970e789b..ff174c392505be037a6047426cf575a20bf15ab2 100644 (file)
@@ -63,13 +63,6 @@ inline T parseString(const std::string& str)
     return result;
 }
 
-// Extended properties
-template<>
-std::istream& readFrom<SGVec3d>(std::istream& stream, SGVec3d& result);
-template<>
-std::istream& readFrom<SGVec4d>(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<SGVec3d>
-{
-    static const Type type_tag = VEC3D;
-    enum  { Internal = 0 };
-};
-
-template<>
-struct PropertyTraits<SGVec4d>
-{
-    static const Type type_tag = VEC4D;
-    enum  { Internal = 0 };
-};
 }
 }
 
@@ -689,11 +669,6 @@ std::istream& SGRawBase<T, 0>::readFrom(std::istream& stream)
     return stream;
 }
 
-template<>
-std::ostream& SGRawBase<SGVec3d>::printOn(std::ostream& stream) const;
-template<>
-std::ostream& SGRawBase<SGVec4d>::printOn(std::ostream& stream) const;
-
 \f
 /**
  * The smart pointer that manage reference counting
index 8fae12f8b205c3a09f4344cedd8b62b4d86c6104..297cad8714121155418e253b7d17621a070e8656 100644 (file)
@@ -14,7 +14,7 @@
 
 #include <simgear/compiler.h>
 
-#include <stdlib.h>            // atof() atoi()
+#include <stdlib.h>     // atof() atoi()
 
 #include <simgear/sg_inlines.h>
 #include <simgear/debug/logstream.hxx>
 
 #include "props.hxx"
 #include "props_io.hxx"
+#include "vectorPropTemplates.hxx"
 
 #include <iostream>
 #include <fstream>
 #include <string>
-#include <cstring>             // strcmp()
+#include <cstring>      // strcmp()
 #include <vector>
 #include <map>
 
index f8299263a1252f58753a99e25139eee9385243db..14f52348b7ceb8d9263be35db3a92c3ed13d90c7 100644 (file)
@@ -11,9 +11,6 @@
 
 #include <iostream>
 
-// working around MSVC weirdness with props.hxx and SGMathFwd
-#include <simgear/math/SGMath.hxx>
-
 #include "props.hxx"
 #include "props_io.hxx"
 
diff --git a/simgear/props/vectorPropTemplates.hxx b/simgear/props/vectorPropTemplates.hxx
new file mode 100644 (file)
index 0000000..d3425c8
--- /dev/null
@@ -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 <simgear/math/SGMath.hxx>
+
+namespace simgear
+{
+
+// Extended properties
+template<>
+std::istream& readFrom<SGVec3d>(std::istream& stream, SGVec3d& result);
+template<>
+std::istream& readFrom<SGVec4d>(std::istream& stream, SGVec4d& result);
+
+namespace props
+{
+
+template<>
+struct PropertyTraits<SGVec3d>
+{
+    static const Type type_tag = VEC3D;
+    enum  { Internal = 0 };
+};
+
+template<>
+struct PropertyTraits<SGVec4d>
+{
+    static const Type type_tag = VEC4D;
+    enum  { Internal = 0 };
+};
+}
+}
+
+template<>
+std::ostream& SGRawBase<SGVec3d>::printOn(std::ostream& stream) const;
+template<>
+std::ostream& SGRawBase<SGVec4d>::printOn(std::ostream& stream) const;
+
+#endif // __VECTORPROPTEMPLATES_HXX
+
+// end of vectorPropTemplates.hxx
index 978aa064e7d7f4851842dc4784e9c5eab649bfea..2e1031854592db741c7fcbe1adea8d2283da4f61 100644 (file)
@@ -74,7 +74,7 @@
 #include <simgear/scene/util/StateAttributeFactory.hxx>
 #include <simgear/structure/OSGUtils.hxx>
 #include <simgear/structure/SGExpression.hxx>
-
+#include <simgear/props/vectorPropTemplates.hxx>
 
 
 namespace simgear
index c06883aab0f5b0eda332e3269eb4ec472c44cf78..99527fcba92001b0aae438e65bf3c2508e98b653 100644 (file)
@@ -43,6 +43,7 @@
 #include <simgear/scene/util/SGSceneFeatures.hxx>
 #include <simgear/scene/util/StateAttributeFactory.hxx>
 #include <simgear/structure/OSGUtils.hxx>
+#include <simgear/props/vectorPropTemplates.hxx>
 
 namespace simgear
 {
index 6e149230097b332446bf96c83c126c948bd1f0fb..e25e6b137cac169ecb00ebe47efc845a0e43a303 100644 (file)
@@ -52,6 +52,7 @@
 #include <simgear/misc/sgstream.hxx>
 #include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/props/props_io.hxx>
+#include <simgear/props/vectorPropTemplates.hxx>
 #include <simgear/scene/model/model.hxx>
 #include <simgear/scene/util/RenderConstants.hxx>
 #include <simgear/scene/util/StateAttributeFactory.hxx>
@@ -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));
index 2fc90a8db5429eed59bdef78bfa7020a985cb529..5ecb07eebac276a8f7c45658402ea2181171012a 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <osg/Geometry>
 #include <osg/MatrixTransform>
+#include <simgear/props/vectorPropTemplates.hxx>
 #include <simgear/scene/material/EffectGeode.hxx>
 #include <simgear/scene/material/Technique.hxx>
 #include <simgear/scene/material/Pass.hxx>