DoorKeeper/include/doorkeeper/components/tyler.hpp

75 lines
2.4 KiB
C++
Raw Normal View History

2015-08-19 19:06:58 +00:00
/* Copyright 2015, Michele Santullo
* This file is part of DoorKeeper.
*
* DoorKeeper is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DoorKeeper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DoorKeeper. If not, see <http://www.gnu.org/licenses/>.
*/
2014-09-02 14:41:21 +00:00
#ifndef id6FB3FC97331449038D42AAAB4C01ABA1
#define id6FB3FC97331449038D42AAAB4C01ABA1
#include "doorkeeper/components/layer.hpp"
#include "doorkeeper/components/exception.hpp"
2015-08-31 15:11:11 +00:00
#include "doorkeeper/implem/idmanager.hpp"
2014-09-02 14:41:21 +00:00
#include <vector>
#include <ciso646>
#include <memory>
#include <cstdint>
2015-08-27 15:12:55 +00:00
#include <boost/iterator/indirect_iterator.hpp>
2015-08-28 15:31:05 +00:00
#include <functional>
2014-09-02 14:41:21 +00:00
namespace dk {
template <uint32_t D>
class BaseMapSource;
template <uint32_t D>
2014-09-02 14:41:21 +00:00
class Tyler {
typedef std::unique_ptr<LayerBase<D>> LayerPtr;
typedef std::vector<LayerPtr> LayerList;
2015-08-31 15:11:11 +00:00
typedef IDManager<7, 9> LayerObsIDManager;
2014-09-02 14:41:21 +00:00
public:
typedef typename LayerBase<D>::coords coords;
2015-08-27 15:12:55 +00:00
typedef boost::indirect_iterator<typename LayerList::iterator> iterator;
typedef boost::indirect_iterator<typename LayerList::const_iterator> const_iterator;
2015-08-28 15:31:05 +00:00
typedef std::function<void(const LayerBase<D>&, bool) noexcept> layer_callback;
2015-08-31 15:11:11 +00:00
typedef LayerObsIDManager::value_type LayerObsID;
2015-08-26 16:08:05 +00:00
Tyler ( void );
Tyler ( Tyler&& ) = default;
~Tyler ( void ) noexcept = default;
template <typename T>
Layer<T, D>& push_layer ( BaseMapSource<D>* parTilemap, int parIndex );
template <typename T>
void push_layer_void ( BaseMapSource<D>* parTilemap, int parIndex );
2014-09-02 14:41:21 +00:00
2015-08-27 15:12:55 +00:00
iterator begin ( void );
const_iterator begin ( void ) const;
iterator end ( void );
const_iterator end ( void ) const;
void preload ( const coords& parFrom, const coords& parTo );
2015-08-31 15:11:11 +00:00
LayerObsID register_for_layeradd ( layer_callback parCallback );
void unregister_for_layeradd ( LayerObsID parID );
2014-09-02 14:41:21 +00:00
private:
2015-08-31 15:11:11 +00:00
LayerObsIDManager m_layerobs_idmanager;
LayerList m_layers;
2015-08-31 15:11:11 +00:00
std::vector<layer_callback> m_layerobs_callbacks;
2014-09-02 14:41:21 +00:00
};
} //namespace dk
#include "doorkeeper/implem/tyler.inl"
2014-09-02 14:41:21 +00:00
#endif