SegmenterIdsManager.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/rp/SegmenterIdsManager.h
22  \brief Segments IDs manager.
23  */
24 
25 #ifndef __TERRALIB_RP_INTERNAL_SEGMENTERIDSMANAGER_H
26 #define __TERRALIB_RP_INTERNAL_SEGMENTERIDSMANAGER_H
27 
28  #include "SegmenterSegmentsBlock.h"
29  #include "Config.h"
30 
31  #include <boost/thread.hpp>
32 
33  #include <list>
34  #include <vector>
35 
36  namespace te
37  {
38  namespace rp
39  {
40  /*!
41  \class SegmenterIdsManager
42  \brief Segmenter segments IDs manager.
43  */
45  {
46  public :
47 
49 
51 
52  /*!
53  \brief Returns a new segment unique ID.
54  \return id A positive new segment ID or zero if an error occurred.
55  \note This method is thread safe.
56  */
58 
59  /*!
60  \brief Returns new segment unique IDs.
61  \param idsNumber The number of unique IDs to return.
62  \param id The segment IDs.
63  \return true if OK, false on errors.
64  \note This method is thread safe.
65  */
66  bool getNewIDs(
67  const unsigned int& idsNumber,
68  std::vector< SegmenterSegmentsBlock::SegmentIdDataType >& ids );
69 
70  /*!
71  \brief Stores a free unique ID for later use.
72  \param id The segment ID.
73  \note This method is thread safe.
74  */
75  void addFreeID( const SegmenterSegmentsBlock::SegmentIdDataType& id );
76 
77  /*!
78  \brief Stores free unique IDs for later use.
79  \param ids The segment IDs.
80  \note This method is thread safe.
81  */
82  void addFreeIDs(
83  const std::vector< SegmenterSegmentsBlock::SegmentIdDataType >& ids );
84 
85  /*!
86  \brief Stores free unique IDs for later use.
87  \param ids The segment IDs.
88  \note This method is thread safe.
89  */
90  void addFreeIDs(
91  const std::list< SegmenterSegmentsBlock::SegmentIdDataType >& ids );
92 
93  protected :
94 
95  /*! Internal free segments IDs counter - default 0) */
97 
98  /*! Internal free segments IDs counter mutex */
99  boost::mutex m_mutex;
100 
101  /*! Internal free segments IDs list */
102  std::list< SegmenterSegmentsBlock::SegmentIdDataType > m_freeIDs;
103  };
104  } // namespace rp
105  } // namespace te
106 
107 #endif
Segmenter segments IDs manager.
volatile SegmenterSegmentsBlock::SegmentIdDataType m_segmentsIdsCounter
URI C++ Library.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
std::list< SegmenterSegmentsBlock::SegmentIdDataType > m_freeIDs
Configuration flags for the Raster Processing module of TerraLib.
Segments block.