[uLib geometry]

- adds some to Programmable accessors
- Static interface test
- Mpl sequence
This commit is contained in:
Andrea Rigoni
2014-12-19 17:37:44 +00:00
parent d3ac2b9e86
commit 39ee7e4a94
17 changed files with 1379 additions and 384 deletions

View File

@@ -6,11 +6,14 @@
#include "Core/Mpl.h"
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// COMPOUND DETAIL //
namespace uLib {
namespace detail {
template < class _Seq >
struct ClassCompound : ULIB_MPL_INHERIT_SEQ(_Seq) {
typedef _Seq Seq;
@@ -27,7 +30,10 @@ struct ClassCompound : ULIB_MPL_INHERIT_SEQ(_Seq) {
template < class T >
void copy(const T &t, const boost::true_type&) const {
// this must be defined not throwing //
static_cast<T &>(*m_dst) = t;
// TODO: constness should removed to use swap ... (think!)
// std::swap(static_cast<T &>(*m_dst),t);
}
template < class A >
@@ -41,25 +47,42 @@ struct ClassCompound : ULIB_MPL_INHERIT_SEQ(_Seq) {
};
template < class Other >
ClassCompound(const Other &t) {
ClassCompound(const Other &copy) {
typedef typename Other::Seq _seq;
mpl::for_each<_seq>(CopyOp<Other>(&t,this));
mpl::for_each<_seq>(CopyOp<Other>(&copy,this));
}
template < class Other >
const ClassCompound & operator = (const Other &t) {
inline void copy ( const Other &copy ) throw () {
typedef typename Other::Seq _seq;
mpl::for_each<_seq>(CopyOp<Other>(&t,this));
mpl::for_each<_seq>(CopyOp<Other>(&copy,this));
}
template < class Other >
const ClassCompound & operator = (const Other &copy) {
this->copy(copy);
return *this;
}
template < int n, class A >
ClassCompound< typename mpl::replace_el<Seq,A,n>::type >
SetComponent(const A &alg) {
typedef typename mpl::replace_el<Seq,A,n>::type _seq;
ClassCompound< _seq > out = *this;
static_cast< A& >(out) = alg;
return out;
}
};
} // detail
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// COMPOUND SPECIALIZATIONS //
struct Null {};
template < class T0 = Null,
class T1 = Null,
@@ -67,22 +90,38 @@ template < class T0 = Null,
class T3 = Null,
class T4 = Null,
class T5 = Null >
struct ClassCompound {
typedef T0 A0;
typedef T1 A1;
typedef T2 A2;
typedef T3 A3;
typedef T4 A4;
typedef T5 A5;
class ClassCompound : detail::ClassCompound< mpl::vector<> > {
public:
typedef detail::ClassCompound< mpl::vector<> > BaseClass;
//NEVER REACHED //
T0& A0();
T1& A1();
T2& A2();
T3& A3();
T4& A4();
T5& A5();
using BaseClass::operator =;
private:
// NOT ACCESSIBLE because never reached //
ClassCompound() {}
template < class Other >
ClassCompound(const Other &t) : BaseClass(t) {}
};
template < class _A0 >
struct ClassCompound<_A0> : detail::ClassCompound< mpl::vector<_A0> > {
typedef detail::ClassCompound< mpl::vector<_A0> > BaseClass;
typedef _A0 A1;
_A0& A0() { return (_A0&)*this; }
const _A0& A0() const { return (const _A0&)*this; }
ClassCompound() {}
@@ -96,15 +135,18 @@ template < class _A0,
class _A1 >
struct ClassCompound<_A0,_A1> : detail::ClassCompound< mpl::vector<_A0,_A1> > {
typedef detail::ClassCompound< mpl::vector<_A0,_A1> > BaseClass;
typedef _A0 A0;
typedef _A1 A1;
_A0& A0() { return (_A0&)*this; }
_A1& A1() { return (_A1&)*this; }
const _A0& A0() const { return (const _A0&)*this; }
const _A1& A1() const { return (const _A1&)*this; }
ClassCompound() {}
ClassCompound() {}
template < class Other >
ClassCompound(const Other &t) : BaseClass(t) {}
using BaseClass::operator =;
using BaseClass::SetComponent;
};
template < class _A0,
@@ -113,9 +155,12 @@ template < class _A0,
struct ClassCompound<_A0,_A1,_A2> : detail::ClassCompound< mpl::vector<_A0,_A1,_A2> > {
typedef detail::ClassCompound< mpl::vector<_A0,_A1,_A2> > BaseClass;
typedef _A0 A0;
typedef _A1 A1;
typedef _A2 A2;
_A0& A0() { return (_A0&)*this; }
_A1& A1() { return (_A1&)*this; }
_A2& A2() { return (_A2&)*this; }
const _A0& A0() const { return (const _A0&)*this; }
const _A1& A1() const { return (const _A1&)*this; }
const _A2& A2() const { return (const _A2&)*this; }
ClassCompound() {}
@@ -133,10 +178,14 @@ template < class _A0,
struct ClassCompound<_A0,_A1,_A2,_A3> : detail::ClassCompound< mpl::vector<_A0,_A1,_A2,_A3> > {
typedef detail::ClassCompound< mpl::vector<_A0,_A1,_A2,_A3> > BaseClass;
typedef _A0 A0;
typedef _A1 A1;
typedef _A2 A2;
typedef _A3 A3;
_A0& A0() { return (_A0&)*this; }
_A1& A1() { return (_A1&)*this; }
_A2& A2() { return (_A2&)*this; }
_A3& A3() { return (_A3&)*this; }
const _A0& A0() const { return (const _A0&)*this; }
const _A1& A1() const { return (const _A1&)*this; }
const _A2& A2() const { return (const _A2&)*this; }
const _A3& A3() const { return (const _A3&)*this; }
ClassCompound() {}
@@ -154,11 +203,16 @@ template < class _A0,
struct ClassCompound<_A0,_A1,_A2,_A3,_A4> : detail::ClassCompound< mpl::vector<_A0,_A1,_A2,_A3,_A4> > {
typedef detail::ClassCompound< mpl::vector<_A0,_A1,_A2,_A3,_A4> > BaseClass;
typedef _A0 A0;
typedef _A1 A1;
typedef _A2 A2;
typedef _A3 A3;
typedef _A4 A4;
_A0& A0() { return (_A0&)*this; }
_A1& A1() { return (_A1&)*this; }
_A2& A2() { return (_A2&)*this; }
_A3& A3() { return (_A3&)*this; }
_A4& A4() { return (_A4&)*this; }
const _A0& A0() const { return (const _A0&)*this; }
const _A1& A1() const { return (const _A1&)*this; }
const _A2& A2() const { return (const _A2&)*this; }
const _A3& A3() const { return (const _A3&)*this; }
const _A4& A4() const { return (const _A4&)*this; }
ClassCompound() {}