TaskPropertyHandler.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/qt/TaskPropertyHandler.h
22 
23  \brief A handler to list task properties into a property browser
24 */
25 
26 #ifndef __TERRALIB_PROCESS_QT_INTERNAL_TASKPROPERTYHANDLER_H
27 #define __TERRALIB_PROCESS_QT_INTERNAL_TASKPROPERTYHANDLER_H
28 
29 #include "../../Config.h"
30 
31 #include "../../ParameterDescriptor.h"
32 
33 // TerreLib Includes
34 #include "../../../common/AbstractFactory.h"
35 
36 // QtPropertyBrowser
37 #include <QObject>
38 #include <QtPropertyBrowser/QtProperty>
39 
40 // STL Includes
41 #include <string>
42 
43 namespace te
44 {
45  namespace dt
46  {
47  class AbstractData;
48  }
49 
50  namespace process
51  {
52  class TaskSharedPtr;
53 
54  namespace qt
55  {
56  class ProcessManager;
57 
58  /*!
59  \class TaskPropertyHandler
60 
61  \brief A handler to list task properties into a property browser
62 
63  */
64  class TEPROCESSEXPORT TaskPropertyHandler : public QObject
65  {
66  Q_OBJECT
67 
68  public:
69 
70  /*! \brief Default constructor. */
71  TaskPropertyHandler(const std::string& taskType);
72 
73  /*! \brief Virtual destructor. */
75 
76  void setTask(const std::string& taskId, ProcessManager* manager);
77 
78  //!< Gets the type of the task
79  const std::string& getType() const;
80 
81  virtual void setDefaultProperties(QtProperty* parent);
82 
83  virtual void setInputProperties(QtProperty* parent);
84 
85  virtual void setOutputProperties(QtProperty* parent);
86 
87  void valueChanged(QtProperty* p, const QVariant& qVariant);
88 
89  protected:
90 
92 
93  /*! \brief Function used to create the right property type given a param descriptor.
94 
95  \param paramDesc Param descriptor used to create the property
96 
97  \return QtProperty object.
98 
99  */
101 
102  /*! \brief Function used to get a terralib object data from a Task param.
103 
104  \param paramName Parameter name
105 
106  \return TerraLib data object, if a valid type was founded.
107 
108  */
109  virtual te::dt::AbstractData* getParamData(const std::string& paramName);
110 
111  /*! \brief Function used to set into qt property a terralib data.
112 
113  \param data TerraLib object data
114  \param property Qt property object
115  \param dataType TerraLib object data type
116 
117  */
118  virtual void setPropertyData(const te::dt::AbstractData* data, QtProperty* property, int dataType) = 0;
119 
120  /*! \brief Function used to create a terralib object data from a QtProperty contents (QVariant).
121 
122  \param paramDesc Parameters descriptor, used to get the data type
123  \param var Qt object with data
124 
125  \return TerraLib data object, if a valid type was founded.
126 
127  */
129 
131 
132  protected:
133 
134  std::string m_taskType; //!< The type of the task. Used by the factory
135 
136  std::string m_taskId;
137 
139 
140  std::map<std::string, QtProperty*> m_propertyMap; //!< A map between string property name and property objects
141  };
142 
143  /*!
144  \class TaskPropertyHandlerFactory
145 
146  \brief Abstract factory used to create Tasks property handlers.
147  */
148  class TEPROCESSEXPORT TaskPropertyHandlerFactory : public te::common::AbstractFactory < te::process::qt::TaskPropertyHandler, std::string >
149  {
150  public:
151 
152  /*!
153  \brief Constructor.
154 
155  \param factoryKey The key that identifies the factory.
156  */
157  TaskPropertyHandlerFactory(const std::string& taskType);
158 
159  //!< Destructor
161 
162  };
163 
164  //!< Wrapper function used to create taks. Used to avoid C++ to create multiple instances of the factory singleton on Windows
165  TEPROCESSEXPORT TaskPropertyHandler* CreateTaskPropertyHandler(const std::string& taskType, const std::string& taskId, ProcessManager* manager);
166  }
167  }
168 }
169 
170 #endif // __TERRALIB_PROCESS_QT_INTERNAL_TASKPROPERTYHANDLER_H
This class defines the interface of abstract factories without initializing parameters.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
A QObject class to handle with process management.
Wrapper function used to create taks. Used to avoid C++ to create multiple instances of the factory s...
TaskPropertyHandlerFactory(const std::string &taskType)
Constructor.
A handler to list task properties into a property browser.
virtual te::dt::AbstractData * getParamData(const std::string &paramName)
Function used to get a terralib object data from a Task param.
virtual QtProperty * createProperty(te::process::TaskSharedPtr task, te::process::ParameterDescriptor &paramDesc)=0
Function used to create the right property type given a param descriptor.
QString getParameterToolTip(te::process::TaskSharedPtr task, te::process::ParameterDescriptor &paramDesc)
TaskPropertyHandler(const std::string &taskType)
Default constructor.
const std::string & getType() const
virtual te::dt::AbstractData * createPropertyData(te::process::ParameterDescriptor &paramDesc, const QVariant &var)
Function used to create a terralib object data from a QtProperty contents (QVariant).
virtual void setOutputProperties(QtProperty *parent)
virtual void setPropertyData(const te::dt::AbstractData *data, QtProperty *property, int dataType)=0
Function used to set into qt property a terralib data.
virtual ~TaskPropertyHandler()
Virtual destructor.
void setProperty(QtProperty *parent, te::process::ParameterDescriptor::Direction dir)
virtual void setDefaultProperties(QtProperty *parent)
std::map< std::string, QtProperty * > m_propertyMap
A map between string property name and property objects.
std::string m_taskType
The type of the task. Used by the factory.
virtual void setInputProperties(QtProperty *parent)
void valueChanged(QtProperty *p, const QVariant &qVariant)
void setTask(const std::string &taskId, ProcessManager *manager)
Gets the type of the task.
TEPROCESSEXPORT TaskPropertyHandler * CreateTaskPropertyHandler(const std::string &taskType, const std::string &taskId, ProcessManager *manager)
TerraLib.
#define TEPROCESSEXPORT
Definition: Config.h:47