tabs/space

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@193 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2005-07-28 14:13:46 +00:00
parent 9e4ea0178b
commit da325e4b8e
4 changed files with 358 additions and 352 deletions

View file

@ -50,8 +50,8 @@ namespace Loki
////////////////////////////////////////////////////////////////////////////////
/*
class template Factory
Implements a generic object factory
class template Factory
Implements a generic object factory
cretae functions with up to 15 parameters
@ -95,7 +95,7 @@ namespace Loki
// class template FunctorImpl
////////////////////////////////////////////////////////////////////////////////
struct FactoryImplBase
struct FactoryImplBase
{
typedef EmptyType Parm1;
typedef EmptyType Parm2;
@ -441,14 +441,14 @@ namespace Loki
typedef typename Impl::Parm14 Parm14;
typedef typename Impl::Parm15 Parm15;
Factory()
{
}
Factory()
{
}
~Factory()
{
associations_.erase(associations_.begin(), associations_.end());
}
~Factory()
{
associations_.erase(associations_.begin(), associations_.end());
}
typedef typename IdToProductMap::iterator iterator;
@ -472,7 +472,7 @@ namespace Loki
{
ProductCreator creator( p, fn );
return associations_.insert(
typename IdToProductMap::value_type(id, creator)).second != 0;
typename IdToProductMap::value_type(id, creator)).second != 0;
}
@ -745,3 +745,6 @@ namespace Loki
////////////////////////////////////////////////////////////////////////////////
#endif // FACTORY_INC_
// $Log:

View file

@ -13,16 +13,16 @@
#if defined(CLASS_LEVEL_THREADING) || defined(OBJECT_LEVEL_THREADING)
// threads only on windows
// threads only on windows
#include <windows.h>
#define SINGLETON_DEFAULT_THREADING ::Loki::ClassLevelLockable
#if defined(CLASS_LEVEL_THREADING)
#define DEFAULT_THREADING ::Loki::ClassLevelLockable
#else
#define DEFAULT_THREADING ::Loki::ObjectLevelLockable
#endif
#define SINGLETON_DEFAULT_THREADING ::Loki::ClassLevelLockable
#if defined(CLASS_LEVEL_THREADING)
#define DEFAULT_THREADING ::Loki::ClassLevelLockable
#else
#define DEFAULT_THREADING ::Loki::ObjectLevelLockable
#endif
#else
#define DEFAULT_THREADING ::Loki::SingleThreaded
#define DEFAULT_THREADING ::Loki::SingleThreaded
#endif
#include <cassert>
@ -220,7 +220,8 @@ namespace Loki
// July 26, 2005: some asserts by Peter Kümmel
////////////////////////////////////////////////////////////////////////////////
// $Log:
#endif
// $Log:

View file

@ -32,362 +32,362 @@ using Loki::SingletonHolder;
namespace FactoryTestParmPrivate
{
class AbstractProduct
{
};
class AbstractProduct
{
};
class Product : public AbstractProduct
{
public:
Product()
{}
Product(int)
{}
Product(int, int)
{}
Product(int, int, int)
{}
Product(int, int, int, int)
{}
Product(int, int, int, int, int)
{}
Product(int, int, int, int, int,
int)
{}
Product(int, int, int, int, int,
int, int)
{}
Product(int, int, int, int, int,
int, int, int)
{}
Product(int, int, int, int, int,
int, int, int, int)
{}
Product(int, int, int, int, int,
int, int, int, int, int)
{}
Product(int, int, int, int, int,
int, int, int, int, int,
int)
{}
Product(int, int, int, int, int,
int, int, int, int, int,
int, int)
{}
Product(int, int, int, int, int,
int, int, int, int, int,
int, int, int)
{}
Product(int, int, int, int, int,
int, int, int, int, int,
int, int, int, int)
{}
Product(int, int, int, int, int,
int, int, int, int, int,
int, int, int, int, int)
{}
class Product : public AbstractProduct
{
public:
Product()
{}
Product(int)
{}
Product(int, int)
{}
Product(int, int, int)
{}
Product(int, int, int, int)
{}
Product(int, int, int, int, int)
{}
Product(int, int, int, int, int,
int)
{}
Product(int, int, int, int, int,
int, int)
{}
Product(int, int, int, int, int,
int, int, int)
{}
Product(int, int, int, int, int,
int, int, int, int)
{}
Product(int, int, int, int, int,
int, int, int, int, int)
{}
Product(int, int, int, int, int,
int, int, int, int, int,
int)
{}
Product(int, int, int, int, int,
int, int, int, int, int,
int, int)
{}
Product(int, int, int, int, int,
int, int, int, int, int,
int, int, int)
{}
Product(int, int, int, int, int,
int, int, int, int, int,
int, int, int, int)
{}
Product(int, int, int, int, int,
int, int, int, int, int,
int, int, int, int, int)
{}
};
};
template< class T>
class CreatorClass
{
public:
CreatorClass()
{
}
T* create0()
{
return new T;
}
T* create1( int)
{
return new T(1);
}
T* create2( int, int)
{
return new T(1,2);
}
T* create3( int, int, int)
{
return new T(1,2,3);
}
T* create4( int, int, int, int)
{
return new T(1,2,3,4);
}
T* create5( int, int, int, int, int)
{
return new T(1,2,3,4,5);
}
T* create6( int, int, int, int, int,
int)
{
return new T(1,2,3,4,5,6);
}
T* create7( int, int, int, int, int,
int, int)
{
return new T(1,2,3,4,5,6,7);
}
T* create8( int, int, int, int, int,
int, int, int)
{
return new T(1,2,3,4,5,6,7,8);
}
T* create9( int, int, int, int, int,
int, int, int, int)
{
return new T(1,2,3,4,5,6,7,8,9);
}
T* create10(int, int, int, int, int,
int, int, int, int, int)
{
return new T(1,2,3,4,5,6,7,8,9,10);
}
T* create11(int, int, int, int, int,
int, int, int, int, int,
int)
{
return new T(1,2,3,4,5,6,7,8,9,10,11);
}
T* create12(int, int, int, int, int,
int, int, int, int, int,
int, int)
{
return new T(1,2,3,4,5,6,7,8,9,10,11,12);
}
T* create13(int, int, int, int, int,
int, int, int, int, int,
int, int, int)
{
return new T(1,2,3,4,5,6,7,8,9,10,11,12,13);
}
T* create14(int, int, int, int, int,
int, int, int, int, int,
int, int, int, int)
{
return new T(1,2,3,4,5,6,7,8,9,10,11,12,13,14);
}
T* create15(int, int, int, int, int,
int, int, int, int, int,
int, int, int, int, int)
{
return new T(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
}
};
template< class T>
class CreatorClass
{
public:
CreatorClass()
{
}
T* create0()
{
return new T;
}
T* create1( int)
{
return new T(1);
}
T* create2( int, int)
{
return new T(1,2);
}
T* create3( int, int, int)
{
return new T(1,2,3);
}
T* create4( int, int, int, int)
{
return new T(1,2,3,4);
}
T* create5( int, int, int, int, int)
{
return new T(1,2,3,4,5);
}
T* create6( int, int, int, int, int,
int)
{
return new T(1,2,3,4,5,6);
}
T* create7( int, int, int, int, int,
int, int)
{
return new T(1,2,3,4,5,6,7);
}
T* create8( int, int, int, int, int,
int, int, int)
{
return new T(1,2,3,4,5,6,7,8);
}
T* create9( int, int, int, int, int,
int, int, int, int)
{
return new T(1,2,3,4,5,6,7,8,9);
}
T* create10(int, int, int, int, int,
int, int, int, int, int)
{
return new T(1,2,3,4,5,6,7,8,9,10);
}
T* create11(int, int, int, int, int,
int, int, int, int, int,
int)
{
return new T(1,2,3,4,5,6,7,8,9,10,11);
}
T* create12(int, int, int, int, int,
int, int, int, int, int,
int, int)
{
return new T(1,2,3,4,5,6,7,8,9,10,11,12);
}
T* create13(int, int, int, int, int,
int, int, int, int, int,
int, int, int)
{
return new T(1,2,3,4,5,6,7,8,9,10,11,12,13);
}
T* create14(int, int, int, int, int,
int, int, int, int, int,
int, int, int, int)
{
return new T(1,2,3,4,5,6,7,8,9,10,11,12,13,14);
}
T* create15(int, int, int, int, int,
int, int, int, int, int,
int, int, int, int, int)
{
return new T(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
}
};
typedef
SingletonHolder<
Factory< AbstractProduct, int >
>Factory0;
typedef
SingletonHolder<
Factory< AbstractProduct, int >
>Factory0;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_1( int ) >
>Factory1;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_1( int ) >
>Factory1;
typedef SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_2( int, int ) >
>Factory2;
typedef SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_2( int, int ) >
>Factory2;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_3( int, int, int ) >
>Factory3;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_3( int, int, int ) >
>Factory3;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_4( int, int, int, int ) >
>Factory4;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_4( int, int, int, int ) >
>Factory4;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_5( int, int, int, int, int ) >
>Factory5;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_5( int, int, int, int, int ) >
>Factory5;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_6( int, int, int, int, int,
int ) >
>Factory6;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_6( int, int, int, int, int,
int ) >
>Factory6;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_7( int, int, int, int, int,
int, int ) >
>Factory7;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_7( int, int, int, int, int,
int, int ) >
>Factory7;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_8( int, int, int, int, int,
int, int, int ) >
>Factory8;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_8( int, int, int, int, int,
int, int, int ) >
>Factory8;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_9( int, int, int, int, int,
int, int, int, int ) >
>Factory9;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_9( int, int, int, int, int,
int, int, int, int ) >
>Factory9;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_10( int, int, int, int, int,
int, int, int, int, int ) >
>Factory10;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_10( int, int, int, int, int,
int, int, int, int, int ) >
>Factory10;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_11( int, int, int, int, int,
int, int, int, int, int,
int ) >
>Factory11;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_11( int, int, int, int, int,
int, int, int, int, int,
int ) >
>Factory11;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_12( int, int, int, int, int,
int, int, int, int, int,
int, int ) >
>Factory12;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_12( int, int, int, int, int,
int, int, int, int, int,
int, int ) >
>Factory12;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_13( int, int, int, int, int,
int, int, int, int, int,
int, int, int ) >
>Factory13;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_13( int, int, int, int, int,
int, int, int, int, int,
int, int, int ) >
>Factory13;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_14( int, int, int, int, int,
int, int, int, int, int,
int, int, int, int ) >
>Factory14;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_14( int, int, int, int, int,
int, int, int, int, int,
int, int, int, int ) >
>Factory14;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_15( int, int, int, int, int,
int, int, int, int, int,
int, int, int, int, int ) >
>Factory15;
typedef
SingletonHolder<
Factory< AbstractProduct, int, TYPELIST_15( int, int, int, int, int,
int, int, int, int, int,
int, int, int, int, int ) >
>Factory15;
CreatorClass<Product> creaClass;
CreatorClass<Product> creaClass;
bool registerAll(){
bool registerAll(){
bool const o0 = Factory0::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create0 );
bool const o1 = Factory1::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create1 );
bool const o2 = Factory2::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create2 );
bool const o3 = Factory3::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create3 );
bool const o4 = Factory4::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create4 );
bool const o5 = Factory5::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create5 );
bool const o6 = Factory6::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create6 );
bool const o7 = Factory7::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create7 );
bool const o8 = Factory8::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create8 );
bool const o9 = Factory9::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create9 );
bool const o10 = Factory10::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create10 );
bool const o11 = Factory11::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create11 );
bool const o12 = Factory12::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create12 );
bool const o13 = Factory13::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create13 );
bool const o14 = Factory14::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create14 );
bool const o15 = Factory15::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create15 );
bool const o0 = Factory0::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create0 );
bool const o1 = Factory1::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create1 );
bool const o2 = Factory2::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create2 );
bool const o3 = Factory3::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create3 );
bool const o4 = Factory4::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create4 );
bool const o5 = Factory5::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create5 );
bool const o6 = Factory6::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create6 );
bool const o7 = Factory7::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create7 );
bool const o8 = Factory8::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create8 );
bool const o9 = Factory9::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create9 );
bool const o10 = Factory10::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create10 );
bool const o11 = Factory11::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create11 );
bool const o12 = Factory12::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create12 );
bool const o13 = Factory13::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create13 );
bool const o14 = Factory14::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create14 );
bool const o15 = Factory15::Instance().Register( 1, &creaClass, &CreatorClass<Product>::create15 );
return o0 && o1 && o2 && o3 && o4 && o5 && o6 && o7 && o8 && o9 && o10 && o11 && o13 && o14 && o15;
}
return o0 && o1 && o2 && o3 && o4 && o5 && o6 && o7 && o8 && o9 && o10 && o11 && o13 && o14 && o15;
}
bool testFactoryParm()
{
bool reg = registerAll();
bool testFactoryParm()
{
bool reg = registerAll();
AbstractProduct* p;
AbstractProduct* p;
p = Factory0::Instance().CreateObject(1);
delete p;
bool test0=p!=NULL;
p = Factory0::Instance().CreateObject(1);
delete p;
bool test0=p!=NULL;
p = Factory1::Instance().CreateObject(1,64);
delete p;
bool test1=p!=NULL;
p = Factory1::Instance().CreateObject(1,64);
delete p;
bool test1=p!=NULL;
p = Factory2::Instance().CreateObject(1,64,64);
delete p;
bool test2=p!=NULL;
p = Factory2::Instance().CreateObject(1,64,64);
delete p;
bool test2=p!=NULL;
p = Factory3::Instance().CreateObject(1,64,64,64);
delete p;
bool test3=p!=NULL;
p = Factory3::Instance().CreateObject(1,64,64,64);
delete p;
bool test3=p!=NULL;
p = Factory4::Instance().CreateObject(1,64,64,64,64);
delete p;
bool test4=p!=NULL;
p = Factory4::Instance().CreateObject(1,64,64,64,64);
delete p;
bool test4=p!=NULL;
p = Factory5::Instance().CreateObject(1,64,64,64,64,64);
delete p;
bool test5=p!=NULL;
p = Factory5::Instance().CreateObject(1,64,64,64,64,64);
delete p;
bool test5=p!=NULL;
p = Factory6::Instance().CreateObject(1, 64,64,64,64,64,
64);
delete p;
bool test6=p!=NULL;
p = Factory6::Instance().CreateObject(1, 64,64,64,64,64,
64);
delete p;
bool test6=p!=NULL;
p = Factory7::Instance().CreateObject(1, 64,64,64,64,64,
64,64);
delete p;
bool test7=p!=NULL;
p = Factory7::Instance().CreateObject(1, 64,64,64,64,64,
64,64);
delete p;
bool test7=p!=NULL;
p = Factory8::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64);
delete p;
bool test8=p!=NULL;
p = Factory8::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64);
delete p;
bool test8=p!=NULL;
p = Factory9::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64);
delete p;
bool test9=p!=NULL;
p = Factory9::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64);
delete p;
bool test9=p!=NULL;
p = Factory10::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64,64);
delete p;
bool test10=p!=NULL;
p = Factory10::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64,64);
delete p;
bool test10=p!=NULL;
p = Factory11::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64,64,
64);
delete p;
bool test11=p!=NULL;
p = Factory11::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64,64,
64);
delete p;
bool test11=p!=NULL;
p = Factory12::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64,64,
64,64);
delete p;
bool test12=p!=NULL;
p = Factory12::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64,64,
64,64);
delete p;
bool test12=p!=NULL;
p = Factory13::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64,64,
64,64,64);
delete p;
bool test13=p!=NULL;
p = Factory13::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64,64,
64,64,64);
delete p;
bool test13=p!=NULL;
p = Factory14::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64,64,
64,64,64,64);
delete p;
bool test14=p!=NULL;
p = Factory14::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64,64,
64,64,64,64);
delete p;
bool test14=p!=NULL;
p = Factory15::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64,64,
64,64,64,64,64);
delete p;
bool test15=p!=NULL;
p = Factory15::Instance().CreateObject(1, 64,64,64,64,64,
64,64,64,64,64,
64,64,64,64,64);
delete p;
bool test15=p!=NULL;
return reg && test0 &&
test1 && test2 && test3 && test4 && test5 &&
test6 && test7 && test8 && test9 && test10 &&
test11 && test12 && test13 && test14 && test15;
}
return reg && test0 &&
test1 && test2 && test3 && test4 && test5 &&
test6 && test7 && test8 && test9 && test10 &&
test11 && test12 && test13 && test14 && test15;
}
}
@ -395,20 +395,20 @@ namespace FactoryTestParmPrivate
class FactoryParmTest : public Test
{
public:
FactoryParmTest() : Test("FactoryParm.h") {}
FactoryParmTest() : Test("FactoryParm.h") {}
virtual void execute(TestResult &result)
{
printName(result);
virtual void execute(TestResult &result)
{
printName(result);
bool test1=FactoryTestParmPrivate::testFactoryParm();
bool test1=FactoryTestParmPrivate::testFactoryParm();
bool r=test1;
bool r=test1;
testAssert("FactoryParm",r,result);
testAssert("FactoryParm",r,result);
std::cout << '\n';
}
std::cout << '\n';
}
} factoryParmTest;
@ -419,3 +419,4 @@ public:
// $Log:

View file

@ -107,4 +107,5 @@ return result;
}
// $Log:@
// $Log: