From 1428a1cc3cea46866bf8b5dbb94c4f311a59fefe Mon Sep 17 00:00:00 2001 From: ganovelli Date: Fri, 19 Mar 2010 17:17:06 +0000 Subject: [PATCH] added a derivation chain to support the modification to the trimesh definition (below) [ Changes in definition of TriMesh: PART II ] Note: No changes to existing code need be the done, this mod should be fully backward compatible Old way to define a TriMesh ============== struct MyMesh: public vcg::tri::TriMesh< vector , vector >{}; new ways to define a TriMesh ============== struct MyMesh: public vcg::tri::TriMesh< CONT1 >{}; struct MyMesh: public vcg::tri::TriMesh< CONT1 , CONT2>{}; struct MyMesh: public vcg::tri::TriMesh< CONT1 , CONT2, CONT3>{}; where CONT[i] can be vector< [MyVertex | MyEdge | MyFace ] > (the order is unimportant) --- vcg/container/derivation_chain.h | 46 ++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/vcg/container/derivation_chain.h b/vcg/container/derivation_chain.h index 933d9b19..fa3fd655 100644 --- a/vcg/container/derivation_chain.h +++ b/vcg/container/derivation_chain.h @@ -28,6 +28,9 @@ namespace vcg{ /*------------------------------------------------------------------*/ // Metaprogramming Core +template < typename T=int> +class DefaultDeriver : public T {}; + template < class Base, template class A> @@ -120,8 +123,47 @@ template < template class K, template class L> class Arity12: public L > {}; -template < typename T=int> -class DefaultDeriver : public T {}; + +// chain with 2 template arguments on the derivers +template < + class Base, + class TA, + template class A > + class MArity1: public A< Base, TA > { + }; + +template < + class Base, + class TA, + template class A, + class TB, + template class B> + class MArity2: public B< MArity1,TB > {}; + +template < + class Base, + class TA, + template class A, + class TB, + template class B, + class TC, + template class C > + class MArity3: public C,TC > {}; + +template < + class Base, + class TA, + template class A, + class TB, + template class B, + class TC, + template class C, + class TD, + template class D> + class MArity4: public D,TD > {}; + + + class DumClass {}; }// end namespace vcg