fw4spl
GenericField.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "dataReg/parser/GenericField.hpp"
8 
9 #include <fwData/Boolean.hpp>
10 #include <fwData/Float.hpp>
11 #include <fwData/GenericField.hpp>
12 #include <fwData/Integer.hpp>
13 #include <fwData/String.hpp>
14 
15 #include <fwServices/macros.hpp>
16 
17 
19 
21 
22 fwServicesRegisterMacro( ::fwServices::IXMLParser, ::dataReg::parser::FloatParser, ::fwData::Float );
23 
25 
26 
27 namespace dataReg
28 {
29 namespace parser
30 {
31 
32 //------------------------------------------------------------------------------
33 
35 {
36  SLM_FATAL("This method is deprecated, and thus shouldn't be used.");
37 }
38 
39 //------------------------------------------------------------------------------
40 
41 void GenericField::createConfig( ::fwTools::Object::sptr _obj )
42 {
43  ::fwData::GenericFieldBase::sptr field = ::fwData::GenericFieldBase::dynamicCast( _obj );
44  SLM_ASSERT("GenericField not instanced", field);
45 
46  ::fwRuntime::ConfigurationElementContainer configs = m_cfg->findAllConfigurationElement("value");
47  SLM_ASSERT("GenericField config must contain at most one tag <value>...</value>", configs.size() <= 1);
48 
49  if ( configs.size() >= 1 )
50  {
51  ::fwRuntime::ConfigurationElement::sptr config = *configs.begin();
52  std::string input = config->getValue();
53  field->fromString(input);
54  }
55 }
56 
57 //------------------------------------------------------------------------------
58 
59 } //namespace parser
60 } //namespace dataReg
61 
FWRUNTIME_API Iterator begin()
Retrieves the iterator on the first managed configuration element.
This class contains an integer value. Integer object is essentially used as a field in other objects...
Definition: Integer.hpp:24
The namespace dataReg (data registration) contains classes which allow to parse the xml configuration...
Specialisation of GenericField parser for float.
virtual DATAREG_API void updating() override
Updating method : create the process object.
#define SLM_FATAL(message)
Definition: spyLog.hpp:283
Specialisation of GenericField parser for string.
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308
FWRUNTIME_API size_t size() const
Return the number of configurations.
Specialisation of GenericField parser for integer.
Defines the generic configuration element container class.
This class contains an float value.
Definition: Float.hpp:25
Service type for the construction of an object and associated services from an XML-based description...
Definition: IXMLParser.hpp:36
Specialisation of GenericField parser for boolean.
This class contains an std::string value.
This class contains a boolean value.