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  */
58  Process();
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
70  void addTask(te::process::TaskSharedPtr taskPtr);
71 
72  //!< Adds a connector to the process. Process will be the holder of the given shared pointers
73  void addConnector(te::process::ConnectorSharedPtr connectorPtr);
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
94  bool run(te::process::ProcessListener* listener);
95 
96  //!< Runs the process asynchronously
97  void runAsync(te::process::ProcessListener* listener);
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
std::vector< te::process::TaskSharedPtr > m_vecTasks
Definition: Process.h:109
Configuration flags for TerraLib Process.
This abstract class a listener to the process flow.
std::thread * m_thread
Definition: Process.h:108
TerraLib.
std::vector< te::process::ConnectorSharedPtr > m_vecConnectors
Definition: Process.h:110
#define TEPROCESSEXPORT
Definition: Config.h:47