| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/functions/TeRasterIteratorSet.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00026 #ifndef _RASTER_ITERATOR_SET_H_
    00027 #define _RASTER_ITERATOR_SET_H_
    00028
    00029 #include <vector>
    00030
    00046 template <class It>
    00047 class RasterIteratorSet
    00048 {
    00049 public:
    00050
    00051   class iterator : public It
    00052            {
    00053              public:
    00054
    00055                iterator()
    00056                  : _set(NULL), _currIndex(0) {}
    00057
    00058                iterator(RasterIteratorSet<It>* set, unsigned index, It current)
    00059                  : It(current), _set(set), _currIndex(index) {}
    00060
    00061                                  iterator& operator++()
    00062                                  {
    00063                                    if(It::operator++() == _set->_endSet.at(_currIndex) &&
    00064                                       _currIndex < (_set->_endSet.size()-1))
    00065                                    {
    00066                                      _currIndex++;
    00067                                      // Altera estado para aquele do novo iterador
    00068                                  It* ptr = (It*)this;
    00069                                    *ptr = _set->_beginSet.at(_currIndex);
    00070                                    }
    00071                                    return *this;
    00072                                  }
    00073
    00074                                  bool operator==(const iterator& rhs) const
    00075                                  {
    00076                                    return (It::operator==(rhs) && _set == rhs._set && _currIndex == rhs._currIndex);
    00077                                  }
    00078
    00079                                  bool operator!=(const iterator& rhs) const
    00080                                  {
    00081                                    return (It::operator!=(rhs) || _set != rhs._set || _currIndex != rhs._currIndex);
    00082                                  }
    00083
    00084              private:
    00085                RasterIteratorSet<It>* _set;
    00086                unsigned               _currIndex;
    00087            };
    00088
    00089            RasterIteratorSet() {}
    00090
    00091            void addIterator(It begin, It end)
    00092            {
    00093              _beginSet.push_back(begin);
    00094              _endSet.push_back(end);
    00095            }
    00096
    00097            iterator begin() { return _beginSet.size() ? iterator(this, 0, _beginSet.at(0)) : iterator(); }
    00098            iterator end()         { int i = _endSet.size()-1; return i >= 0 ? iterator(this, i, _endSet.at(i)) : iterator(); }
    00099
    00100 private:
    00101   std::vector<It> _beginSet;
    00102   std::vector<It> _endSet;
    00103 };
    00104
    00105 #endif
    00106

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines