make disabling the TYPELIST macros possible
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@333 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
ba524baf5a
commit
570f0ed652
15 changed files with 1252 additions and 375 deletions
|
@ -16,6 +16,11 @@
|
|||
#include <iostream>
|
||||
#include "loki/Factory.h"
|
||||
#include "loki/Functor.h"
|
||||
|
||||
#ifdef LOKI_DISABLE_TYPELIST_MACROS
|
||||
#define USE_WQUENCE
|
||||
#endif
|
||||
|
||||
#ifdef USE_SEQUENCE
|
||||
#include "loki/Sequence.h"
|
||||
using Loki::Seq;
|
||||
|
@ -61,7 +66,7 @@ typedef SingletonHolder
|
|||
#ifndef USE_SEQUENCE
|
||||
Factory< AbstractProduct, int, LOKI_TYPELIST_2( int, int ) >
|
||||
#else
|
||||
Factory< AbstractProduct, int, Seq< int, int >::Type >
|
||||
Factory< AbstractProduct, int, Seq< int, int > >
|
||||
#endif
|
||||
>
|
||||
PFactory;
|
||||
|
@ -149,7 +154,7 @@ public:
|
|||
#ifndef USE_SEQUENCE
|
||||
typedef Functor<Product*,LOKI_TYPELIST_2(int,int)> CreateFunctor;
|
||||
#else
|
||||
typedef Functor<Product*,Seq<int,int>::Type> CreateFunctor;
|
||||
typedef Functor<Product*,Seq<int,int> > CreateFunctor;
|
||||
#endif
|
||||
|
||||
typedef
|
||||
|
@ -158,7 +163,7 @@ SingletonHolder
|
|||
#ifndef USE_SEQUENCE
|
||||
Factory< AbstractProduct, int,LOKI_TYPELIST_3(CreateFunctor,int,int) >
|
||||
#else
|
||||
Factory< AbstractProduct, int,Seq<CreateFunctor,int,int>::Type >
|
||||
Factory< AbstractProduct, int,Seq<CreateFunctor,int,int> >
|
||||
#endif
|
||||
>
|
||||
PFactoryFunctorParm;
|
||||
|
@ -244,6 +249,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
// $Log$
|
||||
// Revision 1.4 2005/10/30 13:49:44 syntheticpp
|
||||
// make disabling the TYPELIST macros possible
|
||||
//
|
||||
// Revision 1.3 2005/10/06 17:50:14 syntheticpp
|
||||
// adding template based list/sequence implementation, should replace LOKI_TYPELIST_, update some files
|
||||
//
|
||||
|
|
|
@ -73,9 +73,9 @@ Loki::OrderedStatic<1,L1> l1;
|
|||
Loki::OrderedStatic<2,L2> l2;
|
||||
|
||||
Loki::OrderedStatic<1, std::string, std::string(*)() > s1( &func );
|
||||
Loki::OrderedStatic<2, std::string, LOKI_TYPELIST_1(char *) > s2( "s2" );
|
||||
Loki::OrderedStatic<2, std::string, Loki::Seq<char *> > s2( "s2" );
|
||||
|
||||
Loki::OrderedStatic<1, Loki::Functor<int>, LOKI_TYPELIST_1( int(*)() ) > f1(f);
|
||||
Loki::OrderedStatic<1, Loki::Functor<int>, Loki::Seq<int(*)()> > f1(f);
|
||||
|
||||
#else
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ class BadSoldier : public Soldier {};
|
|||
class BadMonster : public Monster {};
|
||||
class BadSuperMonster : public SuperMonster {};
|
||||
|
||||
#ifndef LOKI_DISABLE_TYPELIST_MACROS
|
||||
|
||||
typedef Loki::AbstractFactory<LOKI_TYPELIST_3(Soldier, Monster, SuperMonster)> AbstractEnemyFactory;
|
||||
|
||||
typedef Loki::ConcreteFactory<AbstractEnemyFactory, Loki::OpNewFactoryUnit,
|
||||
|
@ -43,6 +45,18 @@ typedef Loki::ConcreteFactory<AbstractEnemyFactory, Loki::OpNewFactoryUnit,
|
|||
typedef Loki::ConcreteFactory<AbstractEnemyFactory, Loki::OpNewFactoryUnit,
|
||||
LOKI_TYPELIST_3(BadSoldier, BadMonster, BadSuperMonster)> HardLevelEnemyFactory;
|
||||
|
||||
#else // LOKI_DISABLE_TYPELIST_MACROS
|
||||
|
||||
typedef Loki::AbstractFactory<Seq<Soldier, Monster, SuperMonster>::Type > AbstractEnemyFactory;
|
||||
|
||||
typedef Loki::ConcreteFactory<AbstractEnemyFactory, Loki::OpNewFactoryUnit,
|
||||
Seq<SillySoldier, SillyMonster, SillySuperMonster>::Type > EasyLevelEnemyFactory;
|
||||
|
||||
typedef Loki::ConcreteFactory<AbstractEnemyFactory, Loki::OpNewFactoryUnit,
|
||||
Seq<BadSoldier, BadMonster, BadSuperMonster>::Type > HardLevelEnemyFactory;
|
||||
|
||||
#endif
|
||||
|
||||
class AbstractFactoryTest : public Test
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -37,12 +37,23 @@ public:
|
|||
TestFunctor testFunctor;
|
||||
TestClass testClass;
|
||||
|
||||
Functor<void,LOKI_TYPELIST_1(bool &)> function(testFunction);
|
||||
|
||||
#ifndef LOKI_DISABLE_TYPELIST_MACROS
|
||||
Functor<void,LOKI_TYPELIST_1(bool &)> function(testFunction);
|
||||
Functor<void,LOKI_TYPELIST_1(bool &)> functor(testFunctor);
|
||||
Functor<void,LOKI_TYPELIST_1(bool &)> classFunctor(&testClass,&TestClass::member);
|
||||
Functor<void,LOKI_TYPELIST_1(bool &)> functorCopy(function);
|
||||
Functor<void,NullType> bindFunctor(BindFirst(function,testResult));
|
||||
Functor<void> chainFunctor(Chain(bindFunctor,bindFunctor));
|
||||
#else
|
||||
Functor<void,Seq<bool &> > function(testFunction);
|
||||
Functor<void,Seq<bool &> > functor(testFunctor);
|
||||
Functor<void,Seq<bool &> > classFunctor(&testClass,&TestClass::member);
|
||||
Functor<void,Seq<bool &> > functorCopy(function);
|
||||
//TODO:
|
||||
//Functor<void,NullType> bindFunctor(BindFirst(function,testResult));
|
||||
//Functor<void> chainFunctor(Chain(bindFunctor,bindFunctor));
|
||||
#endif
|
||||
|
||||
testResult=false;
|
||||
function(testResult);
|
||||
|
@ -60,6 +71,7 @@ public:
|
|||
functorCopy(testResult);
|
||||
bool functorCopyResult=testResult;
|
||||
|
||||
#ifndef LOKI_DISABLE_TYPELIST_MACROS
|
||||
testResult=false;
|
||||
bindFunctor();
|
||||
bool bindFunctorResult=testResult;
|
||||
|
@ -70,6 +82,10 @@ public:
|
|||
|
||||
r=functionResult && functorResult && classFunctorResult && functorCopyResult && bindFunctorResult &&
|
||||
chainFunctorResult;
|
||||
#else
|
||||
//TODO!
|
||||
r=functionResult && functorResult && classFunctorResult && functorCopyResult;
|
||||
#endif
|
||||
|
||||
testAssert("Functor",r,result);
|
||||
|
||||
|
|
|
@ -41,22 +41,22 @@ Test::tests_type Test::tests;
|
|||
// is the header inclusion to execute the correspond
|
||||
// unit test.
|
||||
|
||||
#include "SmallObjectTest.h"
|
||||
#include "SingletonTest.h"
|
||||
|
||||
#include "ThreadsTest.h"
|
||||
#include "TypelistTest.h"
|
||||
#include "SequenceTest.h"
|
||||
#include "TypeManipTest.h"
|
||||
#include "TypeTraitsTest.h"
|
||||
#include "TypeTraitsTest2.h"
|
||||
#include "SmallObjectTest.h"
|
||||
#include "SingletonTest.h"
|
||||
#include "SmartPtrTest.h"
|
||||
#include "FactoryTest.h"
|
||||
#include "FactoryParmTest.h"
|
||||
#include "AbstractFactoryTest.h"
|
||||
#include "AssocVectorTest.h"
|
||||
#include "FunctorTest.h"
|
||||
#include "DataGeneratorsTest.h"
|
||||
|
||||
//#include "AssocVectorTest.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -117,6 +117,9 @@ int main()
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.11 2005/10/30 13:49:44 syntheticpp
|
||||
// make disabling the TYPELIST macros possible
|
||||
//
|
||||
// Revision 1.10 2005/10/24 20:51:38 syntheticpp
|
||||
// Table is out of date
|
||||
//
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define TYPELISTTEST_H
|
||||
|
||||
#include <loki/Typelist.h>
|
||||
#include <loki/Sequence.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// TypelistTest
|
||||
|
@ -33,13 +34,23 @@ public:
|
|||
using namespace Loki;
|
||||
using namespace Loki::TL;
|
||||
|
||||
typedef LOKI_TYPELIST_1(char) CharList;
|
||||
#ifndef LOKI_DISABLE_TYPELIST_MACROS
|
||||
typedef LOKI_TYPELIST_1(char) CharList;
|
||||
typedef LOKI_TYPELIST_3(char,int,double) CharIntDoubleList;
|
||||
typedef LOKI_TYPELIST_4(char,int,double,char) CharIntDoubleCharList;
|
||||
typedef LOKI_TYPELIST_3(Base,Derived1,Derived2) BaseDerived1Derived2List;
|
||||
typedef LOKI_TYPELIST_3(Derived2,Derived1,Base) Derived2Derived1BaseList;
|
||||
typedef LOKI_TYPELIST_4(Base,Derived1,Base,Derived2) BaseDerived1BaseDerived2List;
|
||||
typedef LOKI_TYPELIST_4(Derived1,Base,Derived1,Derived2) Derived1BaseDerived1Derived2List;
|
||||
#else
|
||||
typedef Seq<char>::Type CharList;
|
||||
typedef Seq<char,int,double>::Type CharIntDoubleList;
|
||||
typedef Seq<char,int,double,char>::Type CharIntDoubleCharList;
|
||||
typedef Seq<Base,Derived1,Derived2>::Type BaseDerived1Derived2List;
|
||||
typedef Seq<Derived2,Derived1,Base>::Type Derived2Derived1BaseList;
|
||||
typedef Seq<Base,Derived1,Base,Derived2>::Type BaseDerived1BaseDerived2List;
|
||||
typedef Seq<Derived1,Base,Derived1,Derived2>::Type Derived1BaseDerived1Derived2List;
|
||||
#endif
|
||||
|
||||
bool r;
|
||||
|
||||
|
@ -84,6 +95,8 @@ public:
|
|||
// Append, Erase, EraseAll, NoDuplicates, Replace, ReplaceAll, Reverse,
|
||||
// MostDerived and DerivedToFront doesn't work on MSVC 6.0
|
||||
|
||||
#ifndef LOKI_DISABLE_TYPELIST_MACROS
|
||||
|
||||
r=SameType<Append<NullType,NullType>::Result,NullType>::value &&
|
||||
SameType<Append<NullType,char>::Result,LOKI_TYPELIST_1(char)>::value &&
|
||||
SameType<Append<NullType,CharList>::Result,CharList>::value &&
|
||||
|
@ -162,7 +175,93 @@ public:
|
|||
SameType<DerivedToFront<BaseDerived1BaseDerived2List>::Result,LOKI_TYPELIST_4(Derived2,Derived1,Base,Base)>::value &&
|
||||
SameType<DerivedToFront<Derived1BaseDerived1Derived2List>::Result,LOKI_TYPELIST_4(Derived2,Derived1,Derived1,Base)>::value;
|
||||
|
||||
testAssert("DerivedToFront",r,result);
|
||||
testAssert("DerivedToFront",r,result);
|
||||
|
||||
#else //LOKI_DISABLE_TYPELIST_MACROS
|
||||
|
||||
r=SameType<Append<NullType,NullType>::Result,NullType>::value &&
|
||||
SameType<Append<NullType,char>::Result,Seq<char>::Type >::value &&
|
||||
SameType<Append<NullType,CharList>::Result,CharList>::value &&
|
||||
SameType<Append<CharList,NullType>::Result,CharList>::value &&
|
||||
SameType<Append<CharList,int>::Result,Seq<char,int>::Type >::value &&
|
||||
SameType<Append<CharList,CharIntDoubleList>::Result,Seq<char,char,int,double>::Type >::value;
|
||||
|
||||
testAssert("Append",r,result);
|
||||
|
||||
r=SameType<Erase<NullType,char>::Result,NullType>::value &&
|
||||
SameType<Erase<CharList,char>::Result,NullType>::value &&
|
||||
SameType<Erase<CharList,long>::Result,CharList>::value &&
|
||||
SameType<Erase<CharIntDoubleList,int>::Result,Seq<char,double>::Type >::value &&
|
||||
SameType<Erase<CharIntDoubleList,double>::Result,Seq<char,int>::Type >::value;
|
||||
|
||||
testAssert("Erase",r,result);
|
||||
|
||||
r=SameType<EraseAll<NullType,char>::Result,NullType>::value &&
|
||||
SameType<EraseAll<CharList,char>::Result,NullType>::value &&
|
||||
SameType<EraseAll<CharList,long>::Result,CharList>::value &&
|
||||
SameType<EraseAll<CharIntDoubleList,int>::Result,Seq<char,double>::Type >::value &&
|
||||
SameType<EraseAll<CharIntDoubleList,double>::Result,Seq<char,int>::Type >::value &&
|
||||
SameType<EraseAll<CharIntDoubleCharList,char>::Result,Seq<int,double>::Type >::value &&
|
||||
SameType<EraseAll<CharIntDoubleCharList,int>::Result,Seq<char,double,char>::Type >::value &&
|
||||
SameType<EraseAll<CharIntDoubleCharList,double>::Result,Seq<char,int,char>::Type >::value;
|
||||
|
||||
testAssert("EraseAll",r,result);
|
||||
|
||||
r=SameType<NoDuplicates<NullType>::Result,NullType>::value &&
|
||||
SameType<NoDuplicates<CharList>::Result,CharList>::value &&
|
||||
SameType<NoDuplicates<CharIntDoubleList>::Result,CharIntDoubleList>::value &&
|
||||
SameType<NoDuplicates<CharIntDoubleCharList>::Result,CharIntDoubleList>::value;
|
||||
|
||||
testAssert("NoDuplicates",r,result);
|
||||
|
||||
r=SameType<Replace<NullType,char,long>::Result,NullType>::value &&
|
||||
SameType<Replace<CharList,char,long>::Result,Seq<long>::Type >::value &&
|
||||
SameType<Replace<CharList,int,long>::Result,CharList>::value &&
|
||||
SameType<Replace<CharIntDoubleList,char,long>::Result,Seq<long,int,double>::Type >::value &&
|
||||
SameType<Replace<CharIntDoubleList,long,char[16]>::Result,CharIntDoubleList>::value &&
|
||||
SameType<Replace<CharIntDoubleCharList,char,long>::Result,Seq<long,int,double,char>::Type >::value;
|
||||
|
||||
testAssert("Replace",r,result);
|
||||
|
||||
r=SameType<ReplaceAll<NullType,char,long>::Result,NullType>::value &&
|
||||
SameType<ReplaceAll<CharList,char,long>::Result,Seq<long>::Type >::value &&
|
||||
SameType<ReplaceAll<CharList,int,long>::Result,CharList>::value &&
|
||||
SameType<ReplaceAll<CharIntDoubleList,char,long>::Result,Seq<long,int,double>::Type >::value &&
|
||||
SameType<ReplaceAll<CharIntDoubleList,long,char[16]>::Result,CharIntDoubleList>::value &&
|
||||
SameType<ReplaceAll<CharIntDoubleCharList,char,long>::Result,Seq<long,int,double,long>::Type >::value;
|
||||
|
||||
testAssert("ReplaceAll",r,result);
|
||||
|
||||
r=SameType<Reverse<NullType>::Result,NullType>::value &&
|
||||
SameType<Reverse<CharList>::Result,CharList>::value &&
|
||||
SameType<Reverse<CharIntDoubleList>::Result,Seq<double,int,char>::Type >::value;
|
||||
|
||||
testAssert("Reverse",r,result);
|
||||
|
||||
r=SameType<MostDerived<NullType,Base>::Result,Base>::value &&
|
||||
SameType<MostDerived<BaseDerived1Derived2List,Base>::Result,Derived2>::value &&
|
||||
SameType<MostDerived<BaseDerived1Derived2List,Derived1>::Result,Derived2>::value &&
|
||||
SameType<MostDerived<BaseDerived1Derived2List,Derived2>::Result,Derived2>::value &&
|
||||
SameType<MostDerived<Derived2Derived1BaseList,Base>::Result,Derived2>::value &&
|
||||
SameType<MostDerived<Derived2Derived1BaseList,Derived1>::Result,Derived2>::value &&
|
||||
SameType<MostDerived<Derived2Derived1BaseList,Derived2>::Result,Derived2>::value;
|
||||
|
||||
testAssert("MostDerived",r,result);
|
||||
|
||||
r=SameType<DerivedToFront<NullType>::Result,NullType>::value &&
|
||||
SameType<DerivedToFront<CharList>::Result,CharList>::value &&
|
||||
SameType<DerivedToFront<CharIntDoubleList>::Result,CharIntDoubleList>::value &&
|
||||
SameType<DerivedToFront<CharIntDoubleCharList>::Result,CharIntDoubleCharList>::value &&
|
||||
SameType<DerivedToFront<BaseDerived1Derived2List>::Result,Derived2Derived1BaseList>::value &&
|
||||
SameType<DerivedToFront<Derived2Derived1BaseList>::Result,Derived2Derived1BaseList>::value &&
|
||||
SameType<DerivedToFront<BaseDerived1BaseDerived2List>::Result,Seq<Derived2,Derived1,Base,Base>::Type >::value &&
|
||||
SameType<DerivedToFront<Derived1BaseDerived1Derived2List>::Result,Seq<Derived2,Derived1,Derived1,Base>::Type >::value;
|
||||
|
||||
testAssert("DerivedToFront",r,result);
|
||||
|
||||
#endif //LOKI_DISABLE_TYPELIST_MACROS
|
||||
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue