Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.38 KB | None | 0 0
  1. #ifndef SPATIAL_STORAGE_BASE_HPP
  2. #define SPATIAL_STORAGE_BASE_HPP
  3.  
  4.  
  5. #include <list>
  6. #include <functional>
  7. #include <gmtl/gmtl.h>
  8.  
  9.  
  10. namespace zserver
  11. {
  12.  
  13. namespace game
  14. {
  15.  
  16. namespace storage
  17. {
  18.  
  19. template<class Item>
  20. gmtl::AABoxf locate(Item item);
  21.  
  22. template<class Item>
  23. gmtl::AABoxf locate(Item const& item);
  24.  
  25. template<class Item>
  26. gmtl::AABoxf locate(Item* item);
  27.  
  28. template<class Item>
  29. gmtl::AABoxf locate(Item const* item);
  30.  
  31. template<class Item>
  32. gmtl::AABoxf locate(Item const* const item);
  33.  
  34. template<class Item>
  35. struct locator : public std::unary_function<Item, gmtl::AABoxf>
  36. {
  37.     gmtl::AABoxf operator()(Item const& item) const
  38.     {
  39.         return locate(item);
  40.     }
  41. };
  42.  
  43. /******************************************************************************
  44. * spatial_storage_base
  45. *
  46. * Generic container to store arbitrary but spatial items.
  47. ******************************************************************************/
  48. template<class Item, class Locator = locator<Item> >
  49. class spatial_storage_base
  50. {
  51. public:
  52.     /**************************************************************************
  53.     * Parameterless constructor.
  54.     **************************************************************************/
  55.     spatial_storage_base<Item, Locator>()
  56.     {
  57.     }
  58.  
  59.     /**************************************************************************
  60.     * Virtual destructor.
  61.     **************************************************************************/
  62.     virtual ~spatial_storage_base<Item, Locator>()
  63.     {
  64.     }
  65.  
  66.     /**************************************************************************
  67.     * Insert an item.
  68.     **************************************************************************/
  69.     virtual void insert(Item const& item) = 0;
  70.  
  71.     /**************************************************************************
  72.     * Remove an item.
  73.     **************************************************************************/
  74.     virtual void remove(Item const& item) = 0;
  75.  
  76.     /**************************************************************************
  77.     * Find items contained or overlapped by a given box.
  78.     **************************************************************************/
  79.     virtual std::list<Item> find(gmtl::AABoxf const& box) = 0;
  80. };
  81.  
  82. } // namespace storage
  83.  
  84. } // namespace game
  85.  
  86. } // namespace zserver
  87.  
  88.  
  89. #endif // SPATIAL_STORAGE_BASE_HPP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement