Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef SPATIAL_STORAGE_BASE_HPP
- #define SPATIAL_STORAGE_BASE_HPP
- #include <list>
- #include <functional>
- #include <gmtl/gmtl.h>
- namespace zserver
- {
- namespace game
- {
- namespace storage
- {
- template<class Item>
- gmtl::AABoxf locate(Item item);
- template<class Item>
- gmtl::AABoxf locate(Item const& item);
- template<class Item>
- gmtl::AABoxf locate(Item* item);
- template<class Item>
- gmtl::AABoxf locate(Item const* item);
- template<class Item>
- gmtl::AABoxf locate(Item const* const item);
- template<class Item>
- struct locator : public std::unary_function<Item, gmtl::AABoxf>
- {
- gmtl::AABoxf operator()(Item const& item) const
- {
- return locate(item);
- }
- };
- /******************************************************************************
- * spatial_storage_base
- *
- * Generic container to store arbitrary but spatial items.
- ******************************************************************************/
- template<class Item, class Locator = locator<Item> >
- class spatial_storage_base
- {
- public:
- /**************************************************************************
- * Parameterless constructor.
- **************************************************************************/
- spatial_storage_base<Item, Locator>()
- {
- }
- /**************************************************************************
- * Virtual destructor.
- **************************************************************************/
- virtual ~spatial_storage_base<Item, Locator>()
- {
- }
- /**************************************************************************
- * Insert an item.
- **************************************************************************/
- virtual void insert(Item const& item) = 0;
- /**************************************************************************
- * Remove an item.
- **************************************************************************/
- virtual void remove(Item const& item) = 0;
- /**************************************************************************
- * Find items contained or overlapped by a given box.
- **************************************************************************/
- virtual std::list<Item> find(gmtl::AABoxf const& box) = 0;
- };
- } // namespace storage
- } // namespace game
- } // namespace zserver
- #endif // SPATIAL_STORAGE_BASE_HPP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement