Commit 6e72f129 authored by Pascal Monnier's avatar Pascal Monnier
Browse files

See #2052 : Added ProcessObject translator to serialize ::fwData::ProcessObject and associated

unit test.

--HG--
branch : fw4spl_0.8.3
extra : rebase_source : 2db699e833982c48f9c52a2ecd5a19ff06e52363
parent 6670cbc8
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2010.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#ifndef _FWXML_XML_PROCESSOBJECTXMLTRANSLATOR_HPP_
#define _FWXML_XML_PROCESSOBJECTXMLTRANSLATOR_HPP_
#include <fwData/ProcessObject.hpp>
#include "fwXML/XML/XMLTranslator.hpp"
namespace fwXML
{
class FWXML_CLASS_API ProcessObjectXMLTranslator : public XMLTranslator
{
public:
/// trivial constructor
FWXML_API ProcessObjectXMLTranslator() ;
/// trivial destructor
FWXML_API virtual ~ProcessObjectXMLTranslator() ;
/// get XML from current object
FWXML_API xmlNodePtr getXMLFrom( ::fwData::Object::sptr obj );
/// get Object from an XML node
FWXML_API void updateDataFromXML( ::fwData::Object::sptr toUpdate, xmlNodePtr source);
};
}
#endif /*_FWXML_XML_PROCESSOBJECTXMLTRANSLATOR_HPP_*/
......@@ -7,7 +7,9 @@
<xsd:complexType name="ProcessObjectXSDType">
<xsd:sequence>
<xsd:element name="Name" type="xsd:string"/>
<xsd:element name="inputs" type="xsd:anyType" minOccurs="1" maxOccurs="1"/>
<xsd:element name="outputs" type="xsd:anyType" minOccurs="1" maxOccurs="1"/>
<xsd:element name="Attributes" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="DynamicAttributes" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
......@@ -21,4 +23,4 @@
</xsd:schema>
\ No newline at end of file
</xsd:schema>
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2010.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#include <boost/filesystem/convenience.hpp>
#include "fwXML/Serializer.hpp"
#include "fwXML/XML/XMLParser.hpp"
#include "fwXML/XML/GenericXMLTranslator.hpp"
#include "fwXML/XML/XMLTranslatorHelper.hpp"
#include "fwXML/boostSerializer/ProcessObject.hpp"
#include "fwXML/XML/ProcessObjectXMLTranslator.hpp"
namespace fwXML
{
ProcessObjectXMLTranslator::ProcessObjectXMLTranslator()
{}
//------------------------------------------------------------------------------
ProcessObjectXMLTranslator::~ProcessObjectXMLTranslator()
{}
//------------------------------------------------------------------------------
xmlNodePtr ProcessObjectXMLTranslator::getXMLFrom( ::fwData::Object::sptr obj )
{
::fwData::ProcessObject::sptr dictionary = ::fwData::ProcessObject::dynamicCast(obj);
xmlNodePtr masterNode = XMLTranslatorHelper::MasterNode( obj );
SLM_ASSERT("Node not instanced", masterNode);
XMLTranslatorHelper::addAttributeComposite( masterNode, "inputs", dictionary->getInputs() );
XMLTranslatorHelper::addAttributeComposite( masterNode, "outputs", dictionary->getOutputs() );
return masterNode;
}
//-----------------------------------------------------------------------------
void ProcessObjectXMLTranslator::updateDataFromXML( ::fwData::Object::sptr toUpdate, xmlNodePtr source)
{
SLM_ASSERT("toUpdate not instanced", toUpdate);
::fwData::ProcessObject::sptr processObject = ::fwData::ProcessObject::dynamicCast(toUpdate);
processObject->setInputs(XMLTranslatorHelper::getAttributeComposite< ::fwData::Object >( source, "inputs" ) );
processObject->setOutputs(XMLTranslatorHelper::getAttributeComposite< ::fwData::Object >( source, "outputs" ) );
}
//------------------------------------------------------------------------------
}
......@@ -72,6 +72,7 @@
#include "fwXML/XML/StructureTraitsDictionaryXMLTranslator.hpp"
#include "fwXML/XML/ResectionDBXMLTranslator.hpp"
#include "fwXML/XML/DictionaryXMLTranslator.hpp"
#include "fwXML/XML/ProcessObjectXMLTranslator.hpp"
INSTANTIATE_SERIALIZER(::fwData::Object);
INSTANTIATE_SERIALIZER(::fwData::Acquisition);
......@@ -102,7 +103,6 @@ namespace fwXML
REGISTER_BINDING_BYCLASSNAME( XMLTranslator , GenericXMLTranslator< ::fwData::Object> , ::fwData::Object );
REGISTER_BINDING_BYCLASSNAME( XMLTranslator , GenericXMLTranslator< ::fwData::Boolean> , ::fwData::Boolean );
REGISTER_BINDING_BYCLASSNAME( XMLTranslator , GenericXMLTranslator< ::fwData::ProcessObject> , ::fwData::ProcessObject );
REGISTER_BINDING_BYCLASSNAME( XMLTranslator , GenericXMLTranslator< ::fwData::Float> , ::fwData::Float );
REGISTER_BINDING_BYCLASSNAME( XMLTranslator , GenericXMLTranslator< ::fwData::Histogram> , ::fwData::Histogram );
REGISTER_BINDING_BYCLASSNAME( XMLTranslator , GenericXMLTranslator< ::fwData::TransformationMatrix3D> , ::fwData::TransformationMatrix3D );
......@@ -141,6 +141,8 @@ REGISTER_BINDING_BYCLASSNAME( XMLTranslator , StructureTraitsXMLTranslator
REGISTER_BINDING_BYCLASSNAME( XMLTranslator , ROITraitsXMLTranslator , ::fwData::ROITraits );
REGISTER_BINDING_BYCLASSNAME( XMLTranslator , ReconstructionTraitsXMLTranslator , ::fwData::ReconstructionTraits );
REGISTER_BINDING_BYCLASSNAME( XMLTranslator , StructureTraitsDictionaryXMLTranslator , ::fwData::StructureTraitsDictionary);
REGISTER_BINDING_BYCLASSNAME( XMLTranslator , ProcessObjectXMLTranslator , ::fwData::ProcessObject );
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment