All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  */
57 
58  /*!
59  \brief Returns new segment unique IDs.
60  \param idsNumber The number of unique IDs to return.
61  \param id The segment IDs.
62  \return true if OK, false on errors.
63  */
64  bool getNewIDs(
65  const unsigned int& idsNumber,
66  std::vector< SegmenterSegmentsBlock::SegmentIdDataType >& ids );
67 
68  /*!
69  \brief Stores a free unique ID for later use.
70  \param id The segment ID.
71  */
72  void addFreeID( const SegmenterSegmentsBlock::SegmentIdDataType& id );
73 
74  /*!
75  \brief Stores free unique IDs for later use.
76  \param ids The segment IDs.
77  */
78  void addFreeIDs(
79  const std::vector< SegmenterSegmentsBlock::SegmentIdDataType >& ids );
80 
81  /*!
82  \brief Stores free unique IDs for later use.
83  \param ids The segment IDs.
84  */
85  void addFreeIDs(
86  const std::list< SegmenterSegmentsBlock::SegmentIdDataType >& ids );
87 
88  protected :
89 
90  /*! Internal free segments IDs counter - default 0) */
92 
93  /*! Internal free segments IDs counter mutex */
94  boost::mutex m_mutex;
95 
96  /*! Internal free segments IDs list */
97  std::list< SegmenterSegmentsBlock::SegmentIdDataType > m_freeIDs;
98  };
99  } // namespace rp
100  } // namespace te
101 
102 #endif
Segmenter segments IDs manager.
volatile SegmenterSegmentsBlock::SegmentIdDataType m_segmentsIdsCounter
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:141
std::list< SegmenterSegmentsBlock::SegmentIdDataType > m_freeIDs
Configuration flags for the Raster Processing module of TerraLib.
Segments block.