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