GroupThreadManager.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 GroupThreadManager.h
22 
23  \brief Class to manager group values in threads.
24 
25  \ingroup vp
26  */
27 
28 #ifndef __TERRALIB_VP_INTERNAL_GROUP_THREAD_MANAGER_H
29 #define __TERRALIB_VP_INTERNAL_GROUP_THREAD_MANAGER_H
30 
31 #include "Config.h"
32 #include "../common/progress/TaskProgress.h"
33 
34 // STL
35 #include <map>
36 #include <vector>
37 
38 // Boost
39 #include <boost/thread/mutex.hpp>
40 
41 namespace te
42 {
43  namespace common
44  {
45  class TaskProgress;
46  }
47 
48  namespace da
49  {
50  class DataSet;
51  class DataSetType;
52  class DataSource;
53  }
54 
55  namespace mem
56  {
57  class DataSet;
58  class DataSetItem;
59  }
60 
61  namespace gm
62  {
63  class Geometry;
64  }
65 
66  namespace vp
67  {
69  {
70  public:
71 
72  GroupThreadManager( const std::map<std::string, std::vector<int> >& groups
73  , te::da::DataSet* dataSet
74  , te::da::DataSetType* dataSetType
75  , te::mem::DataSet* outputDataSet
76  , te::da::DataSetType* outputDataSetType
77  , te::da::DataSource* outputDataSource
78  , std::map<std::string, te::dt::AbstractData*> specificParams);
79 
80  virtual ~GroupThreadManager() {}
81 
82  bool getNextGroup(std::vector< te::mem::DataSetItem*>& nextGroup);
83 
84  bool getNextOutput(std::vector< te::mem::DataSetItem*>& nextOutput);
85 
87 
89 
91 
92  std::map<std::string, te::dt::AbstractData*> getSpecificParameters() const;
93 
95 
96  std::vector<std::string> getWarnings() const;
97 
99 
100  void addOutput(std::vector<te::mem::DataSetItem*>& itemGroup);
101 
102  void addWarning(const std::string& warning, const bool& appendIfExists = false);
103 
104  private:
105 
107 
109 
110  std::map<std::string, std::vector<int> > m_groups;
111  std::size_t m_savedCount;
114 
118 
119  std::map<std::string, te::dt::AbstractData*> m_specificParams;
120 
121  std::map<std::string, std::vector<int> >::iterator m_groupsIterator;
122 
123  std::vector< std::vector<te::mem::DataSetItem*> > m_outputQueue;
125 
126  std::vector<std::string> m_warnings;
127 
128  boost::mutex m_mtx;
129  boost::mutex m_mtxOutput;
130  boost::mutex m_mtxWarning;
131  };
132  }
133 }
134 #endif // __TERRALIB_VP_INTERNAL_GROUP_THREAD_MANAGER_H
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:54
A class that models the description of a dataset.
Definition: DataSetType.h:73
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:114
An abstract class for data providers like a DBMS, Web Services or a regular file.
Definition: DataSource.h:120
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver.
Definition: DataSetItem.h:55
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver.
Definition: DataSet.h:66
te::common::TaskProgress m_task
void addOutput(std::vector< te::mem::DataSetItem * > &itemGroup)
std::map< std::string, te::dt::AbstractData * > getSpecificParameters() const
std::map< std::string, std::vector< int > > m_groups
GroupThreadManager(const std::map< std::string, std::vector< int > > &groups, te::da::DataSet *dataSet, te::da::DataSetType *dataSetType, te::mem::DataSet *outputDataSet, te::da::DataSetType *outputDataSetType, te::da::DataSource *outputDataSource, std::map< std::string, te::dt::AbstractData * > specificParams)
void addWarning(const std::string &warning, const bool &appendIfExists=false)
std::vector< std::vector< te::mem::DataSetItem * > > m_outputQueue
bool getNextOutput(std::vector< te::mem::DataSetItem * > &nextOutput)
te::mem::DataSet * m_outputDataSet
std::map< std::string, std::vector< int > >::iterator m_groupsIterator
te::da::DataSetType * m_outputDataSetType
te::da::DataSetType * m_dataSetType
te::da::DataSource * m_outputDataSource
const GroupThreadManager & operator=(const GroupThreadManager &)
te::mem::DataSetItem * createOutputItem()
std::vector< std::string > m_warnings
bool getNextGroup(std::vector< te::mem::DataSetItem * > &nextGroup)
std::map< std::string, te::dt::AbstractData * > m_specificParams
te::mem::DataSet * getClearOutputDataSet()
std::vector< std::string > getWarnings() const
te::da::DataSetType * getOutputDataSetType() const
GroupThreadManager(const GroupThreadManager &)
te::da::DataSource * getOutputDataSource() const
te::da::DataSetType * getDataSetType() const
TerraLib.
#define TEVPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
Proxy configuration file for TerraView (see terraview_config.h).