+template<>
+struct AttributeType<LightModel>
+ : public TypeHolder<StateAttribute::LIGHTMODEL>
+{};
+
+template<>
+struct AttributeType<LineStipple>
+ : public TypeHolder<StateAttribute::LINESTIPPLE>
+{};
+
+template<>
+struct AttributeType<LineWidth>
+ : public TypeHolder<StateAttribute::LINEWIDTH>
+{};
+
+template<>
+struct AttributeType<LogicOp>
+ : public TypeHolder<StateAttribute::LOGICOP>
+{};
+
+template<>
+struct AttributeType<Material>
+ : public TypeHolder<StateAttribute::MATERIAL>
+{};
+
+template<>
+struct AttributeType<Multisample>
+ : public TypeHolder<StateAttribute::MULTISAMPLE>
+{};
+
+template<>
+struct AttributeType<Point>
+ : public TypeHolder<StateAttribute::POINT>
+{};
+
+template<>
+struct TexAttributeType<PointSprite>
+ : public TypeHolder<StateAttribute::POINTSPRITE>
+{};
+
+template<>
+struct AttributeType<PolygonMode>
+ : public TypeHolder<StateAttribute::POLYGONMODE>
+{};
+
+template<>
+struct AttributeType<PolygonOffset>
+ : public TypeHolder<StateAttribute::POLYGONOFFSET>
+{};
+
+template<>
+struct AttributeType<PolygonStipple>
+ : public TypeHolder<StateAttribute::POLYGONSTIPPLE>
+{};
+
+template<>
+struct AttributeType<Program>
+ : public TypeHolder<StateAttribute::PROGRAM>
+{};
+
+template<>
+struct AttributeType<Scissor>
+ : public TypeHolder<StateAttribute::SCISSOR>
+{};
+
+template<>
+struct AttributeType<ShadeModel>
+ : public TypeHolder<StateAttribute::SHADEMODEL>
+{};
+
+template<>
+struct AttributeType<Stencil>
+ : public TypeHolder<StateAttribute::STENCIL>
+{};
+
+template<>
+struct AttributeType<StencilTwoSided>
+ : public TypeHolder<StateAttribute::STENCIL>
+{};
+
+// TexEnvCombine is not a subclass of TexEnv, so we can't do a
+// typesafe access of the attribute.
+#if 0
+template<>
+struct TexAttributeType<TexEnv>
+ : public TypeHolder<StateAttribute::TEXENV>
+{};
+
+template<>
+struct TexAttributeType<TexEnvCombine>
+ : public TypeHolder<StateAttribute::TEXENV>
+{};
+#endif
+
+template<>
+struct TexAttributeType<TexEnvFilter>
+ : public TypeHolder<StateAttribute::TEXENVFILTER>
+{};
+
+template<>
+struct TexAttributeType<TexGen>
+ : public TypeHolder<StateAttribute::TEXGEN>
+{};
+
+template<>
+struct TexAttributeType<TexMat>
+ : public TypeHolder<StateAttribute::TEXMAT>
+{};
+
+template<>
+struct TexAttributeType<Texture>
+ : public TypeHolder<StateAttribute::TEXTURE>
+{};
+
+template<>
+struct AttributeType<VertexProgram>
+ : public TypeHolder<StateAttribute::VERTEXPROGRAM>
+{};
+
+template<>
+struct AttributeType<Viewport>
+ : public TypeHolder<StateAttribute::VIEWPORT>
+{};
+} // namespace osgutils
+
+template<typename AT>
+inline AT* getStateAttribute(osg::StateSet* ss)