Update of /cvsroot/cppunit/cppunit2/src/cpput
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31558/src/cpput
Modified Files:
registry.cpp
Log Message:
- fixed static registration macro for Registry
- static registration macros must no longer be followed by a semi-colon
(therefore we get compiler error if registry.h was not included)
- allow registration macros to work with class implenting suite() or suite( const std::string &).
Index: registry.cpp
===================================================================
RCS file: /cvsroot/cppunit/cppunit2/src/cpput/registry.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** registry.cpp 8 Nov 2005 21:44:55 -0000 1.3
--- registry.cpp 8 Nov 2005 23:25:31 -0000 1.4
***************
*** 6,9 ****
--- 6,32 ----
namespace CppUT {
+ namespace Impl {
+ struct ThreadSafeSuiteFactory
+ {
+ typedef TestPtr result_type;
+
+ typedef TestPtr (*SuiteFactoryFn)( const std::string &suiteName);
+ ThreadSafeSuiteFactory( SuiteFactoryFn factory,
+ const std::string &suiteName )
+ : factory_( factory )
+ , suiteName_( suiteName )
+ {
+ }
+
+ TestPtr operator()() const
+ {
+ return factory_( suiteName_ );
+ }
+
+ std::string suiteName_;
+ SuiteFactoryFn factory_;
+ };
+ } // namespace Impl
+
std::string
***************
*** 70,73 ****
--- 93,114 ----
+ TestFactoryId
+ Registry::add( const std::string &parentSuiteName,
+ TestPtr (*factory)() )
+ {
+ return add( parentSuiteName, CppTL::cfn0r( factory ) );
+ }
+
+
+ TestFactoryId
+ Registry::add( const std::string &parentSuiteName,
+ TestPtr (*factory)( const std::string &suiteName ),
+ const std::string &suiteName )
+ {
+ return add( parentSuiteName,
+ CppTL::fn0r( Impl::ThreadSafeSuiteFactory( factory, suiteName ) ) );
+ }
+
+
TestFactoryId
Registry::addToDefault( const TestFactory &testFactory )
***************
*** 76,79 ****
--- 117,134 ----
}
+ TestFactoryId
+ Registry::addToDefault( TestPtr (*factory)() )
+ {
+ return addToDefault( CppTL::cfn0r( factory ) );
+ }
+
+ TestFactoryId
+ Registry::addToDefault( TestPtr (*factory)( const std::string &suiteName ),
+ const std::string &suiteName)
+ {
+ return addToDefault( CppTL::fn0r( Impl::ThreadSafeSuiteFactory( factory,
+ suiteName ) ) );
+ }
+
bool
|