All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParameterValue.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2011 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/serialization/se/ParameterValue.cpp
22 
23  \brief Support for ParameterValue serialization.
24 */
25 
26 // TerraLib
27 #include "../../se/ParameterValue.h"
28 #include "../../xml/Reader.h"
29 #include "../../xml/Writer.h"
30 #include "../fe/Expression.h"
31 #include "ParameterValue.h"
32 
33 // STL
34 #include <cassert>
35 #include <memory>
36 
38 {
39  std::auto_ptr<te::se::ParameterValue> param(new te::se::ParameterValue);
40 
41  // Expression TODO: (n's expressions?)
43  p->m_expression = Expression::getInstance().read(reader);
44 
45  // TODO: and mixed data?!
46 
47  param->add(p);
48 
49  assert(reader.getNodeType() == te::xml::END_ELEMENT);
50  reader.next();
51 
52  return param.release();
53 }
54 
56 {
57  if(p == 0)
58  return;
59 
60  std::size_t n = p->getNParameters();
61 
62  for(std::size_t i = 0; i != n; ++i)
63  {
65 
66  if(param->m_mixedData)
67  writer.writeValue(*(param->m_mixedData));
68  else
69  Expression::getInstance().write(param->m_expression, writer);
70  }
71 }
TESERIALIZATIONEXPORT te::se::ParameterValue * ReadParameterValue(te::xml::Reader &reader)
This class models a XML reader object.
Definition: Reader.h:55
virtual bool next()=0
It gets the next event to be read.
TESERIALIZATIONEXPORT void Save(const te::fe::Filter *filter, te::xml::Writer &writer)
Definition: Filter.cpp:54
te::fe::Expression * m_expression
Parameter from an expression.
const Parameter * getParameter(size_t i) const
virtual void writeValue(const std::string &value)
Definition: Writer.cpp:120
size_t getNParameters() const
The ParameterValueType uses WFS-Filter expressions to give values for SE graphic parameters.
std::string * m_mixedData
Parameter from a mixed data content.
virtual NodeType getNodeType() const =0
It return the type of node read.
The &quot;ParameterValueType&quot; uses WFS-Filter expressions to give values for SE graphic parameters...
This class models a XML writer object.
Definition: Writer.h:52