Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

BinnerAxisXML.cxx

Go to the documentation of this file.
00001 
00012 // for truncation warning
00013 #ifdef _MSC_VER
00014 #include "msdevstudio/MSconfig.h"
00015 #endif
00016 
00017 #include "BinnerAxisXML.h"
00018 
00019 #include "XmlElement.h"
00020 
00021 #include "binners/BinnerAxis.h"
00022 #include "binners/BinnerAxisFactory.h"
00023 
00024 #include <cassert>
00025 
00026 using std::string;
00027 
00028 BinnerAxisXML::BinnerAxisXML ( XmlController * controller )
00029   : BaseXML ( "BinnerBase", controller ),
00030     m_width ( "width" ),
00031     m_high ( "high" ),
00032     m_low ( "low" )
00033 {
00034 }
00035 
00036 XmlElement * 
00037 BinnerAxisXML::
00038 createElement ( const BinnerAxis & binner )
00039 {
00040   XmlElement * tag = BaseXML::createElement ();
00041   setAttributes ( tag, binner );
00042 
00043   return tag;
00044 }
00045 
00046 void
00047 BinnerAxisXML::
00048 setAttributes ( XmlElement * tag, const BinnerAxis & binner )
00049 {
00050   const string & type = binner.name();
00051   tag->setAttribute ( m_type, type );
00052 
00053   const Range & range = binner.getRange ();
00054   double high = range.high();
00055   double low = range.low ();
00056 
00057   tag->setAttribute ( m_high, high );
00058   tag->setAttribute ( m_low, low );
00059 
00060   double width = binner.getBinWidth ();
00061   tag->setAttribute ( m_width, width );
00062 }
00063 
00064 BinnerAxis * 
00065 BinnerAxisXML::
00066 createObject ( const XmlElement * element )
00067 {
00068   string type;
00069   bool ok = element->attribute ( m_type, type );
00070   assert ( ok );
00071 
00072   BinnerAxisFactory * factory = BinnerAxisFactory::instance ();
00073   BinnerAxis * binner = factory->create ( type );
00074 
00075   double high = 1.0;
00076   double low = 0.0;
00077   ok  = element->attribute ( m_high, high );
00078   ok &= element->attribute ( m_low, low );
00079   assert ( ok );
00080   Range range ( low, high );
00081   binner->setRange ( range, false );
00082 
00083   double width = -1.0;
00084   ok = element->attribute ( m_width, width );
00085   assert ( ok );
00086   binner->setBinWidth ( width );
00087 
00088   return binner;
00089 }

Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3