TileIndex.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef TileIndex_h
  19. #define TileIndex_h
  20. #include <limits>
  21. #include <wtf/Vector.h>
  22. namespace BlackBerry {
  23. namespace WebKit {
  24. class TileIndex {
  25. public:
  26. TileIndex()
  27. : m_i(std::numeric_limits<unsigned>::max())
  28. , m_j(std::numeric_limits<unsigned>::max()) { }
  29. TileIndex(unsigned i, unsigned j)
  30. : m_i(i)
  31. , m_j(j) { }
  32. ~TileIndex() { }
  33. unsigned i() const { return m_i; }
  34. unsigned j() const { return m_j; }
  35. void setIndex(unsigned i, unsigned j)
  36. {
  37. m_i = i;
  38. m_j = j;
  39. }
  40. bool isValid() const
  41. {
  42. return m_i != std::numeric_limits<unsigned>::max()
  43. && m_j != std::numeric_limits<unsigned>::max();
  44. }
  45. private:
  46. unsigned m_i;
  47. unsigned m_j;
  48. };
  49. inline bool operator==(const BlackBerry::WebKit::TileIndex& a, const BlackBerry::WebKit::TileIndex& b)
  50. {
  51. return a.i() == b.i() && a.j() == b.j();
  52. }
  53. inline bool operator!=(const BlackBerry::WebKit::TileIndex& a, const BlackBerry::WebKit::TileIndex& b)
  54. {
  55. return a.i() != b.i() || a.j() != b.j();
  56. }
  57. typedef WTF::Vector<TileIndex> TileIndexList;
  58. }
  59. }
  60. #endif // TileIndex_h