Some changes and the build is fine again.
This is a test version, design is still in progress.
This commit is contained in:
parent
f9e249a972
commit
e63aebe6e1
15 changed files with 252 additions and 19 deletions
|
@ -5,6 +5,12 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11 -g -O0 -Wall -Wex
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -O3 -Wall -Wextra")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -O3 -Wall -Wextra")
|
||||||
#string(COMPARE EQUAL CMAKE_BINARY_DIR CMAKE_SOURCE_DIR IN_SOURCE_BUILD)
|
#string(COMPARE EQUAL CMAKE_BINARY_DIR CMAKE_SOURCE_DIR IN_SOURCE_BUILD)
|
||||||
|
|
||||||
|
find_library(Boost 1.21.0 REQUIRED)
|
||||||
|
|
||||||
|
include_directories(SYSTEM
|
||||||
|
${Boost_INCLUDE_DIRECTORIES}
|
||||||
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
src/
|
src/
|
||||||
include/
|
include/
|
||||||
|
@ -13,4 +19,5 @@ include_directories(
|
||||||
add_executable(${PROJECT_NAME}
|
add_executable(${PROJECT_NAME}
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
src/doorkeeper.cpp
|
src/doorkeeper.cpp
|
||||||
|
src/test/test_tiler.cpp
|
||||||
)
|
)
|
||||||
|
|
40
include/components/tileiterator.hpp
Normal file
40
include/components/tileiterator.hpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#ifndef id873715F57B504CCF8227CE03EA28CAFA
|
||||||
|
#define id873715F57B504CCF8227CE03EA28CAFA
|
||||||
|
|
||||||
|
#include <boost/iterator/iterator_facade.hpp>
|
||||||
|
#include <iterator>
|
||||||
|
#include "primitivetypes.hpp"
|
||||||
|
|
||||||
|
namespace dk {
|
||||||
|
template <typename T, size_t D>
|
||||||
|
class TileIterator : public boost::iterator_facade<TileIterator<T, D>, T, boost::biderectional_traversal_tag> {
|
||||||
|
friend class boost::iterator_core_access;
|
||||||
|
public:
|
||||||
|
typedef Vector<CoordinateScalarType, D> coords;
|
||||||
|
|
||||||
|
TileIterator ( void );
|
||||||
|
TileIterator ( const TileIterator& parOther ) = default;
|
||||||
|
TileIterator ( const coords& parFrom, const coords& parTo );
|
||||||
|
TileIterator ( const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo, const coords& parTotal );
|
||||||
|
~TileIterator ( void ) = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void increment ( void );
|
||||||
|
void decrement ( void );
|
||||||
|
void advance ( size_t parAdvance );
|
||||||
|
ptrdiff_t distance_to ( const MeshSelectionIterator& parOther );
|
||||||
|
bool equal ( const MeshSelectionIterator& parOther ) const;
|
||||||
|
T& dereference ( void ) const;
|
||||||
|
|
||||||
|
coords m_pos;
|
||||||
|
coords m_from;
|
||||||
|
coords m_to;
|
||||||
|
coords m_areafrom;
|
||||||
|
coords m_areato;
|
||||||
|
coords m_total;
|
||||||
|
};
|
||||||
|
} //namespace dk
|
||||||
|
|
||||||
|
#include "implem/tileiterator.inl"
|
||||||
|
|
||||||
|
#endif
|
33
include/components/tilestreamer.hpp
Normal file
33
include/components/tilestreamer.hpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef id9B1C02049E474F6997D367932C4C2D21
|
||||||
|
#define id9B1C02049E474F6997D367932C4C2D21
|
||||||
|
|
||||||
|
#include "primitivetypes.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace dk {
|
||||||
|
template <typename T, size_t D>
|
||||||
|
class TileStreamer {
|
||||||
|
public:
|
||||||
|
typedef Vector<CoordinateScalarType, D> coords;
|
||||||
|
typedef std::unique_ptr<std::istream> StreamPtr;
|
||||||
|
|
||||||
|
explicit TileStreamer ( StreamPtr&& parStream );
|
||||||
|
TileStreamer ( const TileStreamer& ) = delete;
|
||||||
|
TileStreamer ( TileStreamer&& ) = default;
|
||||||
|
~TileStreamer ( void ) noexcept = default;
|
||||||
|
|
||||||
|
TileStreamer& operator= ( const TileStreamer& ) = delete;
|
||||||
|
|
||||||
|
void copy ( std::vector<T>& parDest, const coords& parFrom, const coords& parTo );
|
||||||
|
|
||||||
|
private:
|
||||||
|
StreamPtr m_stream;
|
||||||
|
};
|
||||||
|
} //namespace dk
|
||||||
|
|
||||||
|
#include "implem/tilestreamer.inl"
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,25 +1,38 @@
|
||||||
#ifndef id6FB3FC97331449038D42AAAB4C01ABA1
|
#ifndef id6FB3FC97331449038D42AAAB4C01ABA1
|
||||||
#define id6FB3FC97331449038D42AAAB4C01ABA1
|
#define id6FB3FC97331449038D42AAAB4C01ABA1
|
||||||
|
|
||||||
#include "implem/coords.hpp"
|
#include "primitivetypes.hpp"
|
||||||
|
#include "components/tilestreamer.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <cassert>
|
||||||
|
#include <ciso646>
|
||||||
|
|
||||||
namespace dk {
|
namespace dk {
|
||||||
|
template <size_t D>
|
||||||
class Viewport;
|
class Viewport;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T, size_t D, typename S=TileStreamer<T, D> >
|
||||||
class Tyler {
|
class Tyler {
|
||||||
public:
|
public:
|
||||||
Tyler ( const coords& parCoords );
|
typedef S streamer_type;
|
||||||
|
typedef Vector<CoordinateScalarType, D> coords;
|
||||||
|
|
||||||
|
Tyler ( void ) = delete;
|
||||||
|
Tyler ( const coords& parSize, streamer_type&& );
|
||||||
virtual ~Tyler ( void ) noexcept = default;
|
virtual ~Tyler ( void ) noexcept = default;
|
||||||
|
|
||||||
virtual bool batch_load ( const coords& parFrom, const coords& parTo );
|
virtual bool batch_load ( const std::vector<T>& parLoad ) = 0;
|
||||||
virtual bool single_load ( const coords& parCoords );
|
virtual bool single_load ( const T& parLoad ) = 0;
|
||||||
|
|
||||||
|
size_t tiles_count ( void ) const { return m_tiles.size(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const coords m_size;
|
const coords m_size;
|
||||||
std::vector<T> m_tiles;
|
std::vector<T> m_tiles;
|
||||||
|
streamer_type m_streamer;
|
||||||
};
|
};
|
||||||
} //namespace dk
|
} //namespace dk
|
||||||
|
|
||||||
|
#include "implem/tyler.inl"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
#ifndef id0ADBCC15BA574485BF3267254090D99B
|
#ifndef id0ADBCC15BA574485BF3267254090D99B
|
||||||
#define id0ADBCC15BA574485BF3267254090D99B
|
#define id0ADBCC15BA574485BF3267254090D99B
|
||||||
|
|
||||||
#include "implem/coords.hpp"
|
#include "primitivetypes.hpp"
|
||||||
|
|
||||||
namespace dk {
|
namespace dk {
|
||||||
|
template <size_t D>
|
||||||
class Viewport {
|
class Viewport {
|
||||||
public:
|
public:
|
||||||
|
typedef Vector<CoordinateScalarType, D> coords;
|
||||||
|
|
||||||
explicit Viewport ( const coords& parSize );
|
explicit Viewport ( const coords& parSize );
|
||||||
Viewport ( const coords& parSize, const coords& parPos );
|
Viewport ( const coords& parSize, const coords& parPos );
|
||||||
~Viewport ( void ) noexcept = default;
|
~Viewport ( void ) noexcept = default;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef id5A4C05FA7D264B65B7B7D14A0792E3A2
|
#ifndef id5A4C05FA7D264B65B7B7D14A0792E3A2
|
||||||
#define id5A4C05FA7D264B65B7B7D14A0792E3A2
|
#define id5A4C05FA7D264B65B7B7D14A0792E3A2
|
||||||
|
|
||||||
|
#include "primitivetypes.hpp"
|
||||||
#include "components/tyler.hpp"
|
#include "components/tyler.hpp"
|
||||||
#include "components/viewport.hpp"
|
#include "components/viewport.hpp"
|
||||||
|
|
||||||
|
|
24
include/implem/configuration.h
Normal file
24
include/implem/configuration.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef id2E81C803F1B94170B2C61A63D5020E08
|
||||||
|
#define id2E81C803F1B94170B2C61A63D5020E08
|
||||||
|
|
||||||
|
#if !defined(DK_COORD_SCALAR_TYPE)
|
||||||
|
# define DK_COORD_SCALAR_TYPE int
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
# define MAKE_DK_NAME(a) a
|
||||||
|
namespace dk {
|
||||||
|
#else
|
||||||
|
# define MAKE_DK_NAME(a) dk_ ## a
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef DK_COORD_SCALAR_TYPE MAKE_DK_NAME(CoordinateScalarType);
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
} //namespace dk
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef DK_COORD_SCALAR_TYPE
|
||||||
|
#undef MAKE_DK_NAME
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,12 +0,0 @@
|
||||||
#ifndef id305A77366E3B4D3C84CC345C93A7C38B
|
|
||||||
#define id305A77366E3B4D3C84CC345C93A7C38B
|
|
||||||
|
|
||||||
#include "implem/vector.hpp"
|
|
||||||
|
|
||||||
namespace dk {
|
|
||||||
typedef int coord_type;
|
|
||||||
typedef cloonel::Vector<coord_type, 2> coords;
|
|
||||||
typedef cloonel::Vector<int, 2> int2;
|
|
||||||
} //namespace dk
|
|
||||||
|
|
||||||
#endif
|
|
46
include/implem/tileiterator.inl
Normal file
46
include/implem/tileiterator.inl
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
namespace dk {
|
||||||
|
template <typename T, size_t D>
|
||||||
|
TileIterator<T, D>::TileIterator() :
|
||||||
|
m_pos(CoordinateScalarType()),
|
||||||
|
m_from(CoordinateScalarType()),
|
||||||
|
m_to(CoordinateScalarType()),
|
||||||
|
m_areafrom(CoordinateScalarType()),
|
||||||
|
m_areato(CoordinateScalarType()),
|
||||||
|
m_total(CoordinateScalarType())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, size_t D>
|
||||||
|
TileIterator<T, D>::TileIterator (const coords& parFrom, const coords& parTo) :
|
||||||
|
m_pos(parFrom),
|
||||||
|
m_from(parFrom),
|
||||||
|
m_to(parTo),
|
||||||
|
m_areafrom(parFrom),
|
||||||
|
m_areato(parTo),
|
||||||
|
m_total(parTo - parFrom)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, size_t D>
|
||||||
|
TileIterator<T, D>::TileIterator (const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo, const coords& parTotal) :
|
||||||
|
m_pos(parFrom),
|
||||||
|
m_from(parFrom),
|
||||||
|
m_to(parTo),
|
||||||
|
m_areafrom(parAreaFrom),
|
||||||
|
m_areato(parAreaTo),
|
||||||
|
m_total(parTotal)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, size_t D>
|
||||||
|
void TileIterator<T, D>::increment() {
|
||||||
|
for (size_t d = 0; d < D - 1; ++d) {
|
||||||
|
++m_pos[d];
|
||||||
|
if (m_pos[d] >= m_areato[d])
|
||||||
|
m_pos[d] = m_areafrom[d];
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
++m_pos[D - 1];
|
||||||
|
}
|
||||||
|
} //namespace dk
|
7
include/implem/tilestreamer.inl
Normal file
7
include/implem/tilestreamer.inl
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
namespace dk {
|
||||||
|
template <typename T, size_t D>
|
||||||
|
TileStreamer<T, D>::TileStreamer (StreamPtr&& parStream) :
|
||||||
|
m_stream(std::move(parStream))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
} //namespace dk
|
12
include/implem/tyler.inl
Normal file
12
include/implem/tyler.inl
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
namespace dk {
|
||||||
|
///------------------------------------------------------------------------
|
||||||
|
///------------------------------------------------------------------------
|
||||||
|
template <typename T, size_t D, typename S>
|
||||||
|
Tyler<T, D, S>::Tyler (const coords& parSize, streamer_type&& parStream) :
|
||||||
|
m_size(parSize),
|
||||||
|
m_tiles(parSize.x() * parSize.y()),
|
||||||
|
m_streamer(std::move(parStream))
|
||||||
|
{
|
||||||
|
assert(m_size.x() > 0 and m_size.y() > 0);
|
||||||
|
}
|
||||||
|
} //namespace dk
|
11
include/primitivetypes.hpp
Normal file
11
include/primitivetypes.hpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef id583F11FE0934446E9135B4ADCFA1E4F9
|
||||||
|
#define id583F11FE0934446E9135B4ADCFA1E4F9
|
||||||
|
|
||||||
|
#include "implem/configuration.h"
|
||||||
|
#include "implem/vector.hpp"
|
||||||
|
|
||||||
|
namespace dk {
|
||||||
|
using cloonel::Vector;
|
||||||
|
} //namespace dk
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,9 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "doorkeeper.hpp"
|
#include "test/test_tiler.hpp"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
TestTiler simpleMap(TestTiler::coords(200, 150), "test.map");
|
||||||
|
|
||||||
|
std::cout << "Total tiles: " << simpleMap.tiles_count() << "\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
26
src/test/test_tiler.cpp
Normal file
26
src/test/test_tiler.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include "test/test_tiler.hpp"
|
||||||
|
|
||||||
|
typedef dk::TileStreamer<int, 2> TileStreamerType;
|
||||||
|
|
||||||
|
///----------------------------------------------------------------------------
|
||||||
|
///----------------------------------------------------------------------------
|
||||||
|
TestTiler::TestTiler (const coords& parSize, const std::string&& parPath) :
|
||||||
|
parent_type(parSize, TileStreamerType(TileStreamerType::StreamPtr(new std::ifstream(parPath))))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
///----------------------------------------------------------------------------
|
||||||
|
///----------------------------------------------------------------------------
|
||||||
|
bool TestTiler::batch_load (const std::vector<int>& parLoad) {
|
||||||
|
std::cout << "Would batch-load " << parLoad.size() << " elements\n";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
///----------------------------------------------------------------------------
|
||||||
|
///----------------------------------------------------------------------------
|
||||||
|
bool TestTiler::single_load (const int&) {
|
||||||
|
std::cout << "Would load 1 element\n";
|
||||||
|
return true;
|
||||||
|
}
|
19
src/test/test_tiler.hpp
Normal file
19
src/test/test_tiler.hpp
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef idDD0A66B75FF546FCAF01C65E980DF224
|
||||||
|
#define idDD0A66B75FF546FCAF01C65E980DF224
|
||||||
|
|
||||||
|
#include "doorkeeper.hpp"
|
||||||
|
|
||||||
|
class TestTiler : public dk::Tyler<int, 2> {
|
||||||
|
typedef dk::Tyler<int, 2> parent_type;
|
||||||
|
public:
|
||||||
|
typedef parent_type::coords coords;
|
||||||
|
|
||||||
|
TestTiler ( const coords& parSize, const std::string&& parPath );
|
||||||
|
|
||||||
|
virtual ~TestTiler ( void ) noexcept = default;
|
||||||
|
|
||||||
|
virtual bool batch_load ( const std::vector<int>& parLoad );
|
||||||
|
virtual bool single_load ( const int& parLoad );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Reference in a new issue