SimpleDataParameterValue.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 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/process/SimpleDataParameterValue.h
22 
23  \brief This class represents a simple data parameter value
24  */
25 
26 #ifndef __TERRALIB_PROCESS_INTERNAL_SIMPLEDATAPARAMETERVALUE_H
27 #define __TERRALIB_PROCESS_INTERNAL_SIMPLEDATAPARAMETERVALUE_H
28 
29  // TerraLib
30 #include "Config.h"
31 
32 #include "ParameterValue.h"
33 
34 //STL include files
35 #include <memory>
36 #include <string>
37 
38 namespace te
39 {
40  namespace dt
41  {
42  class AbstractData;
43  }
44 
45  namespace process
46  {
47  /*!
48  \class Task
49 
50  \brief This class represents the value of a parameter.
51  */
53  {
54  public:
55 
56  //!< Constructor
57  explicit SimpleDataParameterValue(int dataType);
58 
59  //!< Constructor
61 
62  /*! \brief Virtual destructor. */
63  virtual ~SimpleDataParameterValue();
64 
65  //!< Clones the object
66  virtual ParameterValue* clone() const override;
67 
68  //!< Returns the string representation of the parameter value
69  virtual std::string toString() const override;
70 
71  //!< Decodes the given string representation and sets the value into the parameter value object
72  virtual void fromString(const std::string& strValue) override;
73 
74  //!< Gets the value associated to this parameter
75  virtual const te::dt::AbstractData* getValue() const;
76 
77  //!< Gets the value associated to this parameter, casting it to the requested type
78  template<typename T>
79  const T* getValueAs() const;
80 
81  //!< Sets the value to be associated to this parameter. This object will take the ownership of the given pointer
82  virtual void setValue(te::dt::AbstractData* absData);
83 
84  protected:
85 
86  std::unique_ptr<te::dt::AbstractData> m_absData; //!< The data of the parameter value
87  };
88 
90  {
91  public:
92 
93  //!< Constructor
94  SimpleDataParameterValueFactory(int dataType);
95 
96  //!< Destructor
98 
99  protected:
100 
102  };
103 
104 
105  //implementation
106  template<typename T>
108  {
109  const te::dt::AbstractData* absData = getValue();
110  if (absData == nullptr)
111  {
112  return nullptr;
113  }
114 
115  return dynamic_cast<const T*>(absData);
116  }
117 
118  } // end namespace process
119 } // end namespace te
120 
121 #endif // __TERRALIB_PROCESS_INTERNAL_SIMPLEDATAPARAMETERVALUE_H
122 
Configuration flags for TerraLib Process.
This class represents the value of a parameter.
const T * getValueAs() const
Sets the value to be associated to this parameter. This object will take the ownership of the given p...
TerraLib.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:55
#define TEPROCESSEXPORT
Definition: Config.h:47
virtual const te::dt::AbstractData * getValue() const
Gets the value associated to this parameter, casting it to the requested type.
Wrapper function used to create taks. Used to avoid C++ to create multiple instances of the factory s...
SimpleDataParameterValueFactory(int dataType)
< Constructor
te::process::ParameterValue * build() override
Concrete factories (derived from this one) must implement this method in order to create objects...
std::unique_ptr< te::dt::AbstractData > m_absData
The data of the parameter value.