Vector doesn't need to be told the type every time.
This commit is contained in:
parent
12db1d9638
commit
49f7d15379
12 changed files with 31 additions and 29 deletions
|
@ -11,7 +11,7 @@ namespace dk {
|
|||
template <typename T, uint32_t D>
|
||||
class BaseMapSource {
|
||||
public:
|
||||
typedef dk::Vector<dk::CoordinateScalarType, D> coords;
|
||||
typedef dk::Vector<D> coords;
|
||||
BaseMapSource ( void ) = default;
|
||||
virtual ~BaseMapSource ( void ) noexcept = default;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace dk {
|
|||
template <uint32_t D>
|
||||
class LayerBase {
|
||||
public:
|
||||
typedef Vector<CoordinateScalarType, D> coords;
|
||||
typedef Vector<D> coords;
|
||||
|
||||
LayerBase ( const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize );
|
||||
virtual ~LayerBase ( void ) noexcept = default;
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace dk {
|
|||
|
||||
namespace implem {
|
||||
template <uint32_t D>
|
||||
size_t get_index_from_pos ( const Vector<CoordinateScalarType, D>& parPos, const Vector<CoordinateScalarType, D>& parSize ) a_pure;
|
||||
size_t get_index_from_pos ( const Vector<D>& parPos, const Vector<D>& parSize ) a_pure;
|
||||
|
||||
template <typename I, typename O>
|
||||
struct TypeWithQualifiers {
|
||||
|
@ -34,24 +34,24 @@ namespace dk {
|
|||
|
||||
#if defined(NDEBUG)
|
||||
template <>
|
||||
size_t get_index_from_pos<2> ( const Vector<CoordinateScalarType, 2>& parPos, const Vector<CoordinateScalarType, 2>& parSize ) a_pure;
|
||||
size_t get_index_from_pos<2> ( const Vector<2>& parPos, const Vector<2>& parSize ) a_pure;
|
||||
#endif
|
||||
|
||||
template <uint32_t D>
|
||||
Vector<CoordinateScalarType, D> buildPastEndCoordinate ( const Vector<CoordinateScalarType, D>& parFrom, const Vector<CoordinateScalarType, D>& parTo ) a_pure;
|
||||
Vector<D> buildPastEndCoordinate ( const Vector<D>& parFrom, const Vector<D>& parTo ) a_pure;
|
||||
|
||||
template <typename T, uint32_t D, typename T1>
|
||||
const Vector<CoordinateScalarType, D>& get_from_from_iterator ( const TileIterator<T, D, T1>& parIterator );
|
||||
const Vector<D>& get_from_from_iterator ( const TileIterator<T, D, T1>& parIterator );
|
||||
} //namespace implem
|
||||
|
||||
template <typename T, uint32_t D, typename T1=typename std::remove_cv<T>::type>
|
||||
class TileIterator : public boost::iterator_facade<TileIterator<T, D>, T, boost::bidirectional_traversal_tag> {
|
||||
friend class boost::iterator_core_access;
|
||||
friend const Vector<CoordinateScalarType, D>& implem::get_from_from_iterator<> ( const TileIterator& parIterator );
|
||||
friend const Vector<D>& implem::get_from_from_iterator<> ( const TileIterator& parIterator );
|
||||
typedef std::vector<T1> vector_type;
|
||||
typedef typename implem::TypeWithQualifiers<T, vector_type>::result qualif_vector_type;
|
||||
public:
|
||||
typedef Vector<CoordinateScalarType, D> coords;
|
||||
typedef Vector<D> coords;
|
||||
|
||||
TileIterator ( void );
|
||||
TileIterator ( const TileIterator& parOther ) = default;
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace dk {
|
|||
template <uint32_t D>
|
||||
class Viewport {
|
||||
public:
|
||||
typedef Vector<CoordinateScalarType, D> coords;
|
||||
typedef Vector<D> coords;
|
||||
|
||||
Viewport ( const Viewport& parOther ) = default;
|
||||
explicit Viewport ( Tyler<D>& parTyler );
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace dkh {
|
|||
|
||||
class AsciiMapSource : public dk::BaseMapSource<implem::AsciiMapTileType, 2> {
|
||||
public:
|
||||
typedef dk::Vector<dk::CoordinateScalarType, 2> coords;
|
||||
typedef dk::Vector<2> coords;
|
||||
typedef implem::AsciiMapTileType MapTileType;
|
||||
enum {
|
||||
MapDimensions = 2
|
||||
|
|
|
@ -5,16 +5,16 @@
|
|||
|
||||
namespace dkh {
|
||||
template <typename T, typename T1>
|
||||
dk::Vector<dk::CoordinateScalarType, 2> get_diamond_coordinates ( const dk::TileIterator<T, 2, T1>& parIterator, const dk::Vector<dk::CoordinateScalarType, 2>& parSize );
|
||||
dk::Vector<2> get_diamond_coordinates ( const dk::TileIterator<T, 2, T1>& parIterator, const dk::Vector<2>& parSize );
|
||||
|
||||
template <typename T, typename T1>
|
||||
dk::Vector<dk::CoordinateScalarType, 2> get_half_diamond_coordinates ( const dk::TileIterator<T, 2, T1>& parIterator, const dk::Vector<dk::CoordinateScalarType, 2>& parSize );
|
||||
dk::Vector<2> get_half_diamond_coordinates ( const dk::TileIterator<T, 2, T1>& parIterator, const dk::Vector<2>& parSize );
|
||||
|
||||
template <typename T, uint32_t D, typename T1>
|
||||
dk::Vector<dk::CoordinateScalarType, D> get_square_coordinates ( const dk::TileIterator<T, D, T1>& parIterator, const dk::Vector<dk::CoordinateScalarType, D>& parSize );
|
||||
dk::Vector<D> get_square_coordinates ( const dk::TileIterator<T, D, T1>& parIterator, const dk::Vector<D>& parSize );
|
||||
|
||||
template <typename T, typename T1>
|
||||
dk::Vector<dk::CoordinateScalarType, 2> get_hex_coordinates ( const dk::TileIterator<T, 2, T1>& parIterator, const dk::Vector<dk::CoordinateScalarType, 2>& parSize );
|
||||
dk::Vector<2> get_hex_coordinates ( const dk::TileIterator<T, 2, T1>& parIterator, const dk::Vector<2>& parSize );
|
||||
} //namespace dkh
|
||||
|
||||
#include "doorkeeper/implem/tilecoordinates.inl"
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace dkh {
|
|||
template <typename T, uint32_t D>
|
||||
class TylerMapSource : public dk::BaseMapSource<T, D> {
|
||||
public:
|
||||
typedef dk::Vector<dk::CoordinateScalarType, 2> coords;
|
||||
typedef dk::Vector<D> coords;
|
||||
typedef T MapTileType;
|
||||
enum {
|
||||
MapDimensions = D
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
namespace dk {
|
||||
namespace implem {
|
||||
template <uint32_t D>
|
||||
CoordinateScalarType area ( const Vector<CoordinateScalarType, D>& parVec ) a_pure;
|
||||
CoordinateScalarType area ( const Vector<D>& parVec ) a_pure;
|
||||
} //namespace implem
|
||||
} //namespace dk
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ namespace dk {
|
|||
///----------------------------------------------------------------------
|
||||
///----------------------------------------------------------------------
|
||||
template <uint32_t D>
|
||||
CoordinateScalarType area (const Vector<CoordinateScalarType, D>& parVec) {
|
||||
CoordinateScalarType area (const Vector<D>& parVec) {
|
||||
CoordinateScalarType retval(1);
|
||||
for (size_t d = 0; d < D; ++d) {
|
||||
retval *= parVec[d];
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
namespace dkh {
|
||||
template <typename T, typename T1>
|
||||
inline
|
||||
dk::Vector<dk::CoordinateScalarType, 2> get_diamond_coordinates (const dk::TileIterator<T, 2, T1>& parIterator, const dk::Vector<dk::CoordinateScalarType, 2>& parSize) {
|
||||
typedef dk::Vector<dk::CoordinateScalarType, 2> vec;
|
||||
dk::Vector<2> get_diamond_coordinates (const dk::TileIterator<T, 2, T1>& parIterator, const dk::Vector<2>& parSize) {
|
||||
typedef dk::Vector<2> vec;
|
||||
|
||||
const auto abspos(parIterator.abs_position());
|
||||
const auto from(dk::implem::get_from_from_iterator(parIterator));
|
||||
|
@ -13,14 +13,14 @@ namespace dkh {
|
|||
|
||||
template <typename T, typename T1>
|
||||
inline
|
||||
dk::Vector<dk::CoordinateScalarType, 2> get_half_diamond_coordinates (const dk::TileIterator<T, 2, T1>& parIterator, const dk::Vector<dk::CoordinateScalarType, 2>& parSize) {
|
||||
typedef dk::Vector<dk::CoordinateScalarType, 2> vec;
|
||||
dk::Vector<2> get_half_diamond_coordinates (const dk::TileIterator<T, 2, T1>& parIterator, const dk::Vector<2>& parSize) {
|
||||
typedef dk::Vector<2> vec;
|
||||
return get_diamond_coordinates(parIterator, parSize / vec(1, 2));
|
||||
}
|
||||
|
||||
template <typename T, uint32_t D, typename T1>
|
||||
inline
|
||||
dk::Vector<dk::CoordinateScalarType, D> get_square_coordinates (const dk::TileIterator<T, D, T1>& parIterator, const dk::Vector<dk::CoordinateScalarType, D>& parSize) {
|
||||
dk::Vector<D> get_square_coordinates (const dk::TileIterator<T, D, T1>& parIterator, const dk::Vector<D>& parSize) {
|
||||
return (parIterator.abs_position() - dk::implem::get_from_from_iterator(parIterator)) * parSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
namespace dk {
|
||||
namespace implem {
|
||||
template <uint32_t D>
|
||||
inline size_t get_index_from_pos (const Vector<CoordinateScalarType, D>& parPos, const Vector<CoordinateScalarType, D>& parSize) {
|
||||
inline size_t get_index_from_pos (const Vector<D>& parPos, const Vector<D>& parSize) {
|
||||
size_t index = 0;
|
||||
for (size_t d = 0; d < D; ++d) {
|
||||
size_t pos = static_cast<size_t>(parPos[D - 1 - d]);
|
||||
|
@ -16,14 +16,14 @@ namespace dk {
|
|||
|
||||
#if defined(NDEBUG)
|
||||
template <>
|
||||
inline size_t get_index_from_pos<2> (const Vector<CoordinateScalarType, 2>& parPos, const Vector<CoordinateScalarType, 2>& parSize) {
|
||||
inline size_t get_index_from_pos<2> (const Vector<2>& parPos, const Vector<2>& parSize) {
|
||||
return parPos.y() * parSize.x() + parPos.x();
|
||||
}
|
||||
#endif
|
||||
|
||||
template <uint32_t D>
|
||||
inline Vector<CoordinateScalarType, D> buildPastEndCoordinate (const Vector<CoordinateScalarType, D>& parFrom, const Vector<CoordinateScalarType, D>& parTo) {
|
||||
Vector<CoordinateScalarType, D> retval;
|
||||
inline Vector<D> buildPastEndCoordinate (const Vector<D>& parFrom, const Vector<D>& parTo) {
|
||||
Vector<D> retval;
|
||||
for (size_t d = 0; d < D - 1; ++d) {
|
||||
retval[d] = parFrom[d];
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace dk {
|
|||
}
|
||||
|
||||
template <typename T, uint32_t D, typename T1>
|
||||
inline const Vector<CoordinateScalarType, D>& get_from_from_iterator (const TileIterator<T, D, T1>& parIterator) {
|
||||
inline const Vector<D>& get_from_from_iterator (const TileIterator<T, D, T1>& parIterator) {
|
||||
return parIterator.m_from;
|
||||
}
|
||||
} //namespace implem
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
#ifndef id583F11FE0934446E9135B4ADCFA1E4F9
|
||||
#define id583F11FE0934446E9135B4ADCFA1E4F9
|
||||
|
||||
#include <ciso646>
|
||||
#include "implem/compatibility.h"
|
||||
#include "implem/configuration.h"
|
||||
#include "implem/vector.hpp"
|
||||
#include <ciso646>
|
||||
#include <cstdint>
|
||||
|
||||
namespace dk {
|
||||
using cloonel::Vector;
|
||||
template <uint32_t D>
|
||||
using Vector = cloonel::Vector<CoordinateScalarType, D>;
|
||||
} //namespace dk
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue