Process.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/Process.h
22 
23  \brief This class represents a container of tasks and connectors and is responsible for controlling its execution flow
24  */
25 
26 #ifndef __TERRALIB_PROCESS_INTERNAL_PROCESS_H
27 #define __TERRALIB_PROCESS_INTERNAL_PROCESS_H
28 
29  // TerraLib
30 #include "Config.h"
31 
32 //STL include files
33 #include <memory>
34 #include <thread>
35 #include <string>
36 #include <vector>
37 
38 namespace te
39 {
40  namespace process
41  {
42  class ConnectorSharedPtr;
43  class ProcessListener;
44  class TaskSharedPtr;
45 
46  /*!
47  \class Progress
48 
49  \brief This class represents a container of tasks and connectors and is responsible for controlling its execution flow
50  */
52  {
53  public:
54 
55  /*!
56  \brief Constructor
57  */
59 
60  /*! \brief Virtual destructor. */
61  virtual ~Process();
62 
63  //!< Clears the association
64  void clear();
65 
66  //!< Checks if the process is valid
67  bool isValid(te::process::ProcessListener* listener) const;
68 
69  //!< Adds a task to the process. Process will be the holder of the given shared pointers
71 
72  //!< Adds a connector to the process. Process will be the holder of the given shared pointers
74 
75  //!< Gets the task associated to the given id
76  te::process::TaskSharedPtr getTask(const std::string& id) const;
77 
78  //!< Gets the connector associated to the given id
79  te::process::ConnectorSharedPtr getConnector(const std::string& id) const;
80 
81  //!< Removed the task associated to the given id
82  void removeTask(const std::string& id);
83 
84  //!< Removes the connector associated to the given id
85  void removeConnector(const std::string& id);
86 
87  //!< Gets all taks from the process
88  const std::vector<te::process::TaskSharedPtr>& getTasks() const;
89 
90  //!< Gets all connectors from the process
91  const std::vector<te::process::ConnectorSharedPtr>& getConnectors() const;
92 
93  //!< Runs the process synchronously
95 
96  //!< Runs the process asynchronously
98 
99  //!< Requests that the asynchronously execution be stopped
100  void requestStop();
101 
102  protected:
103 
104  //!< Gets all tasks that are ready to rund
105  std::vector<te::process::TaskSharedPtr> getReadyToRunTasks() const;
106 
107  protected:
108  std::thread* m_thread;
109  std::vector<te::process::TaskSharedPtr> m_vecTasks;
110  std::vector<te::process::ConnectorSharedPtr> m_vecConnectors;
111 
112  };
113  } // end namespace process
114 } // end namespace te
115 
116 #endif // __TERRALIB_PROCESS_INTERNAL_PROCESS_H
te::process::Process::runAsync
void runAsync(te::process::ProcessListener *listener)
Requests that the asynchronously execution be stopped.
te::process::Process::removeConnector
void removeConnector(const std::string &id)
Gets all taks from the process.
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::process::ProcessListener
This abstract class a listener to the process flow.
Definition: ProcessListener.h:47
te::process::TaskSharedPtr
Definition: Task.h:150
te::process::Process::Process
Process()
Constructor.
te::process::Process::run
bool run(te::process::ProcessListener *listener)
Runs the process asynchronously.
te::process::Process::requestStop
void requestStop()
te::process::Process::addTask
void addTask(te::process::TaskSharedPtr taskPtr)
Adds a connector to the process. Process will be the holder of the given shared pointers.
te::process::Process::getReadyToRunTasks
std::vector< te::process::TaskSharedPtr > getReadyToRunTasks() const
< Gets all tasks that are ready to rund
te::process::ConnectorSharedPtr
Definition: Connector.h:118
te::process::Process::clear
void clear()
Checks if the process is valid.
te::process::Process::getConnectors
const std::vector< te::process::ConnectorSharedPtr > & getConnectors() const
Runs the process synchronously.
te::process::Process::m_vecTasks
std::vector< te::process::TaskSharedPtr > m_vecTasks
Definition: Process.h:109
te::process::Process::m_vecConnectors
std::vector< te::process::ConnectorSharedPtr > m_vecConnectors
Definition: Process.h:110
te::process::Process::isValid
bool isValid(te::process::ProcessListener *listener) const
Adds a task to the process. Process will be the holder of the given shared pointers.
te::process::Process::~Process
virtual ~Process()
Virtual destructor.
te::process::Process::getTasks
const std::vector< te::process::TaskSharedPtr > & getTasks() const
Gets all connectors from the process.
te::process::Process::getTask
te::process::TaskSharedPtr getTask(const std::string &id) const
Gets the connector associated to the given id.
TEPROCESSEXPORT
#define TEPROCESSEXPORT
Definition: Config.h:47
te::process::Process::m_thread
std::thread * m_thread
Definition: Process.h:108
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::process::Process::removeTask
void removeTask(const std::string &id)
Removes the connector associated to the given id.
te::process::Process::getConnector
te::process::ConnectorSharedPtr getConnector(const std::string &id) const
Removed the task associated to the given id.
te::process::Process
Definition: Process.h:52
te::process::Process::addConnector
void addConnector(te::process::ConnectorSharedPtr connectorPtr)
Gets the task associated to the given id.