Store Sequence sequence location in a shared_ptr class
[mussa.git] / alg / color.hpp
index 3e4def5e1253bf5cc181ed55508833cc670b16ff..abf8b686994ff12c775ce32a3301a51dcada84ec 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef _GLCOLOR_H_
 #define _GLCOLOR_H_
 
+#include <boost/serialization/export.hpp>
+#include <boost/serialization/nvp.hpp>
+#include <boost/serialization/version.hpp>
+
 #include <ostream>
 
 //! convienece class for handling opengl colors
@@ -10,10 +14,10 @@ public:
   Color();
   Color(const Color &);
   //! initialize with red, green, blue, alpha
-  Color(float r, float g, float b, float a=0.0);
+  Color(float r, float g, float b, float a=1.0);
 
   //! set all channels simultaneously 
-  void set(float r, float g, float b, float a=0.0);
+  void set(float r, float g, float b, float a=1.0);
   //! return an array of 4 colors (stored by class)
   const float* const get() const;
   void setR(float);
@@ -31,7 +35,18 @@ public:
 
 protected:
   float colors[4];
+
+private:
+  friend class boost::serialization::access;
+  template<class Archive>
+  void serialize(Archive& ar, const unsigned int /*version*/) {
+    ar & boost::serialization::make_nvp("red",   colors[RedChannel]);
+    ar & boost::serialization::make_nvp("green", colors[GreenChannel]);
+    ar & boost::serialization::make_nvp("blue",  colors[BlueChannel]);
+    ar & boost::serialization::make_nvp("alpha", colors[AlphaChannel]);
+  }
 };
+BOOST_CLASS_EXPORT(Color)
 
 #endif