ColorXML.cxx

Go to the documentation of this file.
00001 
00011 // for dll interface warning
00012 #ifdef _MSC_VER
00013 #include "msdevstudio/MSconfig.h"
00014 #endif
00015 
00016 #include "ColorXML.h"
00017 
00018 #include "XmlElement.h"
00019 
00020 #include "graphics/Color.h"
00021 
00022 using std::string;
00023 
00024 namespace hippodraw {
00025 
00026 ColorXML::ColorXML ( XmlController * controller )
00027   : BaseXML ( "Color", controller ),
00028     m_red ( "red" ),
00029     m_green ( "green" ),
00030     m_blue ( "blue" )
00031 {
00032 }
00033 
00034 XmlElement * ColorXML::createElement ( const Color & color )
00035 {
00036   XmlElement * tag = BaseXML::createElement ();
00037 
00038   tag->setAttribute ( m_red,   color.getRed () );
00039   tag->setAttribute ( m_green, color.getGreen () );
00040   tag->setAttribute ( m_blue,  color.getBlue () );
00041 
00042   return tag;
00043 }
00044 
00045 Color * ColorXML::createObject ( const XmlElement * element )
00046 {
00047   int red = 0;
00048   bool ok = element->attribute ( m_red, red );
00049 
00050   int green = 0;
00051   ok = element->attribute ( m_green, green );
00052 
00053   int blue = 0;
00054   ok = element->attribute ( m_blue, blue );
00055 
00056   Color * color = new Color ();
00057   color->setColor ( red, green, blue );
00058 
00059   return color;
00060 }
00061 
00062 } // namespace hippodraw
00063 

Generated for HippoDraw Class Library by doxygen