diff --git a/include/loki/Factory.h b/include/loki/Factory.h index 87cbe27..72eff70 100644 --- a/include/loki/Factory.h +++ b/include/loki/Factory.h @@ -12,7 +12,7 @@ //////////////////////////////////////////////////////////////////////////////// // $Header: - + #ifndef FACTORYPARM_INC_ #define FACTORYPARM_INC_ @@ -24,7 +24,7 @@ namespace Loki { - + //////////////////////////////////////////////////////////////////////////////// // class template DefaultFactoryError // Manages the "Unknown Type" error in an object factory @@ -43,18 +43,18 @@ namespace Loki throw Exception(); } }; - - + + //#define ENABLE_FACTORY_BOOK_VERSION_ONLY #ifndef ENABLE_FACTORY_BOOK_VERSION_ONLY //////////////////////////////////////////////////////////////////////////////// /* - class template Factory - Implements a generic object factory + class template Factory + Implements a generic object factory cretae functions with up to 15 parameters - - + + template < class AbstractProduct, @@ -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: + diff --git a/include/loki/Threads.h b/include/loki/Threads.h index 4bfc69f..6f9b60f 100644 --- a/include/loki/Threads.h +++ b/include/loki/Threads.h @@ -13,16 +13,16 @@ #if defined(CLASS_LEVEL_THREADING) || defined(OBJECT_LEVEL_THREADING) - // threads only on windows + // threads only on windows #include - #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 @@ -220,7 +220,8 @@ namespace Loki // July 26, 2005: some asserts by Peter Kümmel //////////////////////////////////////////////////////////////////////////////// -// $Log: #endif +// $Log: + diff --git a/tools/RegressionTest/FactoryParmTest.h b/tools/RegressionTest/FactoryParmTest.h index 5b6c7ac..59d894c 100755 --- a/tools/RegressionTest/FactoryParmTest.h +++ b/tools/RegressionTest/FactoryParmTest.h @@ -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 creaClass; + CreatorClass creaClass; - bool registerAll(){ + bool registerAll(){ - bool const o0 = Factory0::Instance().Register( 1, &creaClass, &CreatorClass::create0 ); - bool const o1 = Factory1::Instance().Register( 1, &creaClass, &CreatorClass::create1 ); - bool const o2 = Factory2::Instance().Register( 1, &creaClass, &CreatorClass::create2 ); - bool const o3 = Factory3::Instance().Register( 1, &creaClass, &CreatorClass::create3 ); - bool const o4 = Factory4::Instance().Register( 1, &creaClass, &CreatorClass::create4 ); - bool const o5 = Factory5::Instance().Register( 1, &creaClass, &CreatorClass::create5 ); - bool const o6 = Factory6::Instance().Register( 1, &creaClass, &CreatorClass::create6 ); - bool const o7 = Factory7::Instance().Register( 1, &creaClass, &CreatorClass::create7 ); - bool const o8 = Factory8::Instance().Register( 1, &creaClass, &CreatorClass::create8 ); - bool const o9 = Factory9::Instance().Register( 1, &creaClass, &CreatorClass::create9 ); - bool const o10 = Factory10::Instance().Register( 1, &creaClass, &CreatorClass::create10 ); - bool const o11 = Factory11::Instance().Register( 1, &creaClass, &CreatorClass::create11 ); - bool const o12 = Factory12::Instance().Register( 1, &creaClass, &CreatorClass::create12 ); - bool const o13 = Factory13::Instance().Register( 1, &creaClass, &CreatorClass::create13 ); - bool const o14 = Factory14::Instance().Register( 1, &creaClass, &CreatorClass::create14 ); - bool const o15 = Factory15::Instance().Register( 1, &creaClass, &CreatorClass::create15 ); - - return o0 && o1 && o2 && o3 && o4 && o5 && o6 && o7 && o8 && o9 && o10 && o11 && o13 && o14 && o15; - } + bool const o0 = Factory0::Instance().Register( 1, &creaClass, &CreatorClass::create0 ); + bool const o1 = Factory1::Instance().Register( 1, &creaClass, &CreatorClass::create1 ); + bool const o2 = Factory2::Instance().Register( 1, &creaClass, &CreatorClass::create2 ); + bool const o3 = Factory3::Instance().Register( 1, &creaClass, &CreatorClass::create3 ); + bool const o4 = Factory4::Instance().Register( 1, &creaClass, &CreatorClass::create4 ); + bool const o5 = Factory5::Instance().Register( 1, &creaClass, &CreatorClass::create5 ); + bool const o6 = Factory6::Instance().Register( 1, &creaClass, &CreatorClass::create6 ); + bool const o7 = Factory7::Instance().Register( 1, &creaClass, &CreatorClass::create7 ); + bool const o8 = Factory8::Instance().Register( 1, &creaClass, &CreatorClass::create8 ); + bool const o9 = Factory9::Instance().Register( 1, &creaClass, &CreatorClass::create9 ); + bool const o10 = Factory10::Instance().Register( 1, &creaClass, &CreatorClass::create10 ); + bool const o11 = Factory11::Instance().Register( 1, &creaClass, &CreatorClass::create11 ); + bool const o12 = Factory12::Instance().Register( 1, &creaClass, &CreatorClass::create12 ); + bool const o13 = Factory13::Instance().Register( 1, &creaClass, &CreatorClass::create13 ); + bool const o14 = Factory14::Instance().Register( 1, &creaClass, &CreatorClass::create14 ); + bool const o15 = Factory15::Instance().Register( 1, &creaClass, &CreatorClass::create15 ); + + 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; - - p = Factory0::Instance().CreateObject(1); - delete p; - bool test0=p!=NULL; - - p = Factory1::Instance().CreateObject(1,64); - delete p; - bool test1=p!=NULL; + AbstractProduct* p; + + p = Factory0::Instance().CreateObject(1); + delete p; + bool test0=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 = Factory9::Instance().CreateObject(1, 64,64,64,64,64, - 64,64,64,64); - delete p; - bool test9=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 = 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,21 +395,21 @@ 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: + diff --git a/tools/RegressionTest/Test.cpp b/tools/RegressionTest/Test.cpp index 862c8f1..8c6d17e 100644 --- a/tools/RegressionTest/Test.cpp +++ b/tools/RegressionTest/Test.cpp @@ -107,4 +107,5 @@ return result; } -// $Log:@ \ No newline at end of file +// $Log: +