PreparedItemCopy.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/memory/PreparedItemCopy.h
22 
23  \brief This class is used to optimize the copy of several dataSetItems by caching the mapping between the columns from the input and the output
24 */
25 
26 #ifndef __TERRALIB_MEMORY_INTERNAL_PREPAREDITEMCOPY_H
27 #define __TERRALIB_MEMORY_INTERNAL_PREPAREDITEMCOPY_H
28 
29 // TerraLib
30 #include "Config.h"
31 
32 #include <utility>
33 #include <vector>
34 
35 namespace te
36 {
37  namespace da
38  {
39 // Forward declaration
40  class DataSetItem;
41  }
42 
43  namespace mem
44  {
45  using ColumnMapping = std::vector< std::pair<std::size_t, std::size_t> >;
46 
47  class DataSetItem;
48 
49  /*!
50  \class PreparedItemCopy
51 
52  \brief This class is used to optimize the copy of several dataSetItems by caching the mapping between the columns from the input and the output
53  */
55  {
56  public:
57 
59 
61 
62  void reset();
63 
64  /*!
65  \brief Copies the values from the source dataSet item to the destination dataSet item by matching the column names. If a column from the source does not exist in the destination, it will not be copied
66  */
67  void copyValues(const te::da::DataSetItem* source, te::mem::DataSetItem* destination, bool copyGeometries = true) const;
68 
69  protected:
70 
71  /*!
72  \brief Creates a list mapping the input columns to the output columns. This is used to optmize significantly when you need to copy several items with the same column order
73  */
74  ColumnMapping prepareCopyValues(const te::da::DataSetItem* source, te::mem::DataSetItem* destination, bool copyGeometries) const;
75 
76  /*!
77  \brief Copies the values from the source dataSet item to the destination dataSet item using the given pre calculated vecColumnsMapping.
78  */
79  void copyValues(const te::da::DataSetItem* source, te::mem::DataSetItem* destination, const ColumnMapping& vecColumnsMapping) const;
80 
81  protected:
82 
84  };
85  } // end namespace mem
86 } // end namespace te
87 
88 #endif // __TERRALIB_MEMORY_INTERNAL_PREPAREDITEMCOPY_H
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver.
Definition: DataSetItem.h:59
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver.
Definition: DataSetItem.h:55
This class is used to optimize the copy of several dataSetItems by caching the mapping between the co...
ColumnMapping prepareCopyValues(const te::da::DataSetItem *source, te::mem::DataSetItem *destination, bool copyGeometries) const
Creates a list mapping the input columns to the output columns. This is used to optmize significantly...
void copyValues(const te::da::DataSetItem *source, te::mem::DataSetItem *destination, bool copyGeometries=true) const
Copies the values from the source dataSet item to the destination dataSet item by matching the column...
void copyValues(const te::da::DataSetItem *source, te::mem::DataSetItem *destination, const ColumnMapping &vecColumnsMapping) const
Copies the values from the source dataSet item to the destination dataSet item using the given pre ca...
std::vector< std::pair< std::size_t, std::size_t > > ColumnMapping
TerraLib.
#define TEMEMORYEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:84
Proxy configuration file for TerraView (see terraview_config.h).