<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>HippoDraw Class Library</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" href="hippoApp.ico"> </head><body> <!-- Generated by Doxygen 1.6.2 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_d71d549033b3d00bbeb107001643b90a.html">xml</a> </div> </div> <div class="contents"> <h1>FunctionProjectorXML.cxx</h1><a href="FunctionProjectorXML_8cxx.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00012"></a>00012 <span class="comment">// for truncation warning</span> <a name="l00013"></a>00013 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#include "msdevstudio/MSconfig.h"</span> <a name="l00015"></a>00015 <span class="preprocessor">#endif</span> <a name="l00016"></a>00016 <span class="preprocessor"></span> <a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="FunctionProjectorXML_8h.html" title="FunctionProjectorXML class interface.">FunctionProjectorXML.h</a>"</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#include "<a class="code" href="XmlController_8h.html" title="XmlController class interface.">XmlController.h</a>"</span> <a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="XmlElement_8h.html" title="XmlElement class interface.">XmlElement.h</a>"</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="FunctionController_8h.html" title="hippodraw::FunctionController class interface">controllers/FunctionController.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="FunctionRep_8h.html" title="hippodraw::FunctionRep class interface">datareps/FunctionRep.h</a>"</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="FunctionBase_8h.html" title="hippodraw::FunctionBase class interface">functions/FunctionBase.h</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="string__convert_8h.html" title="The namespace for conversion to string.">pattern/string_convert.h</a>"</span> <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="FunctionProjector_8h.html" title="hippodraw::FunctionProjector class interface">projectors/FunctionProjector.h</a>"</span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="keyword">using</span> std::string; <a name="l00029"></a>00029 <span class="keyword">using</span> std::vector; <a name="l00030"></a>00030 <a name="l00031"></a>00031 <span class="keyword">namespace </span>hippodraw { <a name="l00032"></a>00032 <a name="l00033"></a><a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#a17d32c45468125f9de495bfe3f5c2ca9">00033</a> <a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#a058c1cdca1661f6811bdbaafef02ba78" title="A private copy constructor in order to avoid copying.">FunctionProjectorXML::FunctionProjectorXML</a> ( <a class="code" href="classhippodraw_1_1XmlController.html" title="A base class that is the interface between GUI and the XML serialization and deserialization...">XmlController</a> * controller ) <a name="l00034"></a>00034 : <a class="code" href="classhippodraw_1_1BaseXML.html" title="A base class of XML element controllers.">BaseXML</a> ( <span class="stringliteral">"FunctionProjector"</span>, controller ) <a name="l00035"></a>00035 { <a name="l00036"></a>00036 } <a name="l00037"></a>00037 <a name="l00038"></a>00038 <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> * <a name="l00039"></a><a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#aa6ac679555b2de7dc199615c28d1bb63">00039</a> <a class="code" href="classhippodraw_1_1BaseXML.html#afa1d42a894a8739e0d120ed9c4383d38" title="Creates a new element node.">FunctionProjectorXML::createElement</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1FunctionProjector.html" title="A projector that plots one function.">FunctionProjector</a> & projector ) <a name="l00040"></a>00040 { <a name="l00041"></a>00041 <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> * tag = <a class="code" href="classhippodraw_1_1BaseXML.html#afa1d42a894a8739e0d120ed9c4383d38" title="Creates a new element node.">BaseXML::createElement</a> (); <a name="l00042"></a>00042 <a name="l00043"></a>00043 <span class="keyword">const</span> <span class="keywordtype">void</span> * addr = reinterpret_cast < <span class="keyword">const</span> <span class="keywordtype">void</span> * > ( & projector ); <a name="l00044"></a>00044 <span class="keywordtype">int</span> <span class="keywordtype">id</span> = <a class="code" href="classhippodraw_1_1BaseXML.html#ae50d78be58d5938b4434515f4f037ece" title="The singleton XML controller object.">m_controller</a> -> getId ( addr ); <a name="l00045"></a>00045 <a class="code" href="classhippodraw_1_1BaseXML.html#aba09fa4e77f2c85cc12df1116cb5f31e" title="Sets the unique identification of the object.">setId</a> ( *tag, <span class="keywordtype">id</span> ); <a name="l00046"></a>00046 <a class="code" href="classhippodraw_1_1FunctionBase.html" title="A function that can be added to a DataRep and used in a fitter.">FunctionBase</a> * function = projector.<a class="code" href="classhippodraw_1_1FunctionProjector.html#a3f4729504d1bf7595bec0c800e421bcd" title="Returns a pointer to the contained function.">function</a> (); <a name="l00047"></a>00047 tag-><a class="code" href="classhippodraw_1_1XmlElement.html#abf6f7e218f61b094107a9e93ab267fd8" title="Sets attribute named name to the int value value.">setAttribute</a> ( <span class="stringliteral">"name"</span>, function-><a class="code" href="classhippodraw_1_1FunctionBase.html#a11c23a386abb9eb8a42f0c2c2835d640" title="Returns the name of the function.">name</a>() ); <a name="l00048"></a>00048 <a name="l00049"></a>00049 <span class="keyword">const</span> vector < double > & parms = function-><a class="code" href="classhippodraw_1_1FunctionBase.html#ab6d95a533aca7f862becee6eca151a68" title="Returns the values of the parameters as a vector.">getParameters</a> (); <a name="l00050"></a>00050 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">size</a> = parms.size(); <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < size; i++ ) { <a name="l00053"></a>00053 <span class="keywordtype">string</span> parm ( <span class="stringliteral">"Parm"</span> ); <a name="l00054"></a>00054 parm += <a class="code" href="namespacehippodraw_1_1Axes.html#ae2337bddf33bc8b17dd5c08e665422cd" title="Converts from string representation ot Axes::Type representation.">String::convert</a> ( i ); <a name="l00055"></a>00055 tag -> setAttribute ( parm, parms[i] ); <a name="l00056"></a>00056 } <a name="l00057"></a>00057 <a name="l00058"></a>00058 <span class="keywordflow">return</span> tag; <a name="l00059"></a>00059 } <a name="l00060"></a>00060 <a name="l00061"></a>00061 <span class="keywordtype">string</span> <a name="l00062"></a>00062 <a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#ab7eabb412ed10468b4e6f897faf846db" title="Get the function name from the XML element.">FunctionProjectorXML::</a> <a name="l00063"></a><a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#ab7eabb412ed10468b4e6f897faf846db">00063</a> <a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#ab7eabb412ed10468b4e6f897faf846db" title="Get the function name from the XML element.">getFunctionName</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> * element ) <a name="l00064"></a>00064 { <a name="l00065"></a>00065 <span class="keywordtype">string</span> fname; <a name="l00066"></a>00066 <span class="keywordtype">bool</span> ok = element-><a class="code" href="classhippodraw_1_1XmlElement.html#afa83a3518bac3d6ae2bc519084071fad" title="Sets value to the attribute name&#39;s value.">attribute</a> ( <span class="stringliteral">"name"</span>, fname ); <a name="l00067"></a>00067 <span class="keywordflow">if</span> ( ! ok ) <span class="keywordflow">return</span> 0; <a name="l00068"></a>00068 <a name="l00069"></a>00069 <span class="keywordflow">return</span> fname; <a name="l00070"></a>00070 } <a name="l00071"></a>00071 <a name="l00072"></a>00072 <span class="keywordtype">void</span> <a name="l00073"></a>00073 <a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#a25e87e16f91e49ae137b7a66d5037362" title="Set the values for the function from the XML element.">FunctionProjectorXML::</a> <a name="l00074"></a><a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#a25e87e16f91e49ae137b7a66d5037362">00074</a> <a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#a25e87e16f91e49ae137b7a66d5037362" title="Set the values for the function from the XML element.">setAttributes</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> * element, <a class="code" href="classhippodraw_1_1FunctionBase.html" title="A function that can be added to a DataRep and used in a fitter.">FunctionBase</a> * function ) <a name="l00075"></a>00075 { <a name="l00076"></a>00076 <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">size</a> = function-><a class="code" href="classhippodraw_1_1FunctionBase.html#ab8e4e3e2a7bf18888b71bdf9dda0770b" title="Returns the number of parameters.">size</a>(); <a name="l00077"></a>00077 vector < double > parms ( size ); <a name="l00078"></a>00078 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < size; i++ ) { <a name="l00079"></a>00079 <span class="keywordtype">string</span> parm ( <span class="stringliteral">"Parm"</span> ); <a name="l00080"></a>00080 parm += <a class="code" href="namespacehippodraw_1_1Axes.html#ae2337bddf33bc8b17dd5c08e665422cd" title="Converts from string representation ot Axes::Type representation.">String::convert</a> ( i ); <a name="l00081"></a>00081 element -> attribute ( parm, parms[i] ); <a name="l00082"></a>00082 } <a name="l00083"></a>00083 <a name="l00084"></a>00084 function-><a class="code" href="classhippodraw_1_1FunctionBase.html#aec721242269c5b893d79e271e85c3f79" title="Sets the parameter values.">setParameters</a> ( parms ); <a name="l00085"></a>00085 } <a name="l00086"></a>00086 <a name="l00087"></a>00087 <a class="code" href="classhippodraw_1_1DataRep.html" title="The base class for data representations.">DataRep</a> * <a name="l00088"></a>00088 <a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#a0911168599fc07461a4ba68f31d0d997" title="Creates a FunctionRep from element with target DataRep.">FunctionProjectorXML::</a> <a name="l00089"></a><a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#a0911168599fc07461a4ba68f31d0d997">00089</a> <a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#a0911168599fc07461a4ba68f31d0d997" title="Creates a FunctionRep from element with target DataRep.">createFunctionRep</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> * fun_element, <a name="l00090"></a>00090 <a class="code" href="classhippodraw_1_1DataRep.html" title="The base class for data representations.">DataRep</a> * drep ) <a name="l00091"></a>00091 { <a name="l00092"></a>00092 <a class="code" href="classhippodraw_1_1FunctionRep.html" title="A derived class of DataRep which is a base class for displaying a function.">FunctionRep</a> * rep = 0; <a name="l00093"></a>00093 <a name="l00094"></a>00094 std::string fname = <a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#ab7eabb412ed10468b4e6f897faf846db" title="Get the function name from the XML element.">getFunctionName</a> ( fun_element ); <a name="l00095"></a>00095 <a class="code" href="classhippodraw_1_1FunctionController.html" title="A singleton class is the interface between an application and the list of FunctionRep...">FunctionController</a> * fc = <a class="code" href="classhippodraw_1_1FunctionController.html#add005d3cdf4fc316aa46841a275f046d" title="Returns the pointer to the singleton instance.">FunctionController::instance</a>(); <a name="l00096"></a>00096 <span class="keywordflow">if</span> ( fc -> functionExists ( fname ) ) { <a name="l00097"></a>00097 rep = fc-><a class="code" href="classhippodraw_1_1FunctionController.html#a5dea7df6dd8fb8e9c40af5fbbe8170f6" title="Returns a newly created FunctionRep object with function of type name and target...">createFunctionRep</a> ( fname, drep ); <a name="l00098"></a>00098 <a class="code" href="classhippodraw_1_1FunctionBase.html" title="A function that can be added to a DataRep and used in a fitter.">FunctionBase</a> * function = rep-><a class="code" href="classhippodraw_1_1FunctionRep.html#ad4b11c2e6c3e1a2b7e7c985ccd8e7b3d" title="Returns the actual function, a FunctionBase derived class.">getFunction</a> (); <a name="l00099"></a>00099 <a class="code" href="classhippodraw_1_1FunctionProjectorXML.html#a25e87e16f91e49ae137b7a66d5037362" title="Set the values for the function from the XML element.">setAttributes</a> ( fun_element, function ); <a name="l00100"></a>00100 rep-><a class="code" href="classhippodraw_1_1FunctionRep.html#a8891f76510f573d291a4492e82058277" title="Saves the function parameters in a cache so that they can be restored.">saveParameters</a> (); <a name="l00101"></a>00101 } <a name="l00102"></a>00102 <span class="keywordflow">return</span> rep; <a name="l00103"></a>00103 } <a name="l00104"></a>00104 <a name="l00105"></a>00105 } <span class="comment">// namespace hippodraw</span> <a name="l00106"></a>00106 </pre></div></div> <hr size="1"><address style="align: right;"><small> Generated for HippoDraw Class Library by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0> </a> </small></address> </body> </html>