Update of /cvsroot/pclasses/pclasses2/include/pclasses
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21068/include/pclasses
Modified Files:
FactoryReg.h
Log Message:
Added support for setting the factory context.
Index: FactoryReg.h
===================================================================
RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/FactoryReg.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- FactoryReg.h 24 Dec 2004 00:57:25 -0000 1.1
+++ FactoryReg.h 24 Dec 2004 21:17:35 -0000 1.2
@@ -33,6 +33,10 @@
# error "You must define PFACREG_TYPE_NAME before including this file."
#endif
+#ifndef PFACREG_CONTEXT
+# define PFACREG_CONTEXT ::P::Sharing::FactoryContext
+#endif
+
#ifndef PFACREG_TYPE_INTERFACE
# define PFACREG_TYPE_INTERFACE PFACREG_TYPE
#endif
@@ -40,10 +44,7 @@
# ifdef PFACREG_TYPE_IS_ABSTRACT
// install a specialization of Factory's default factory type,
-// so that we won't try to instantiation a PFACREG_TYPE object.
-// Remember that this code will only happen when
-// ( PFACREG_TYPE_INTERFACE == PFACREG_TYPE )
-// assuming the user doesn't mis-use the supermacro API.
+// so that we won't try to instantiate a PFACREG_TYPE object.
namespace P { namespace Hook {
template <>
struct FactoryCreateHook< PFACREG_TYPE_INTERFACE , PFACREG_TYPE >
@@ -78,10 +79,11 @@
# endif // !p_FACTORY_REG_CONTEXT_DEFINED
# define FACTORY_FUNCTION_ ::P::Hook::FactoryCreateHook< PFACREG_TYPE_INTERFACE , PFACREG_TYPE >::create
+# define FACTORY_INSTANCE_ ::P::Factory< PFACREG_TYPE_INTERFACE, std::string, PFACREG_CONTEXT >::instance()
////////////////////////////////////////////////////////////////////////
// Register a factory with the classloader:
bool pfactory_reg_context< PFACREG_TYPE >::placeholder= (
- P::NamedTypeFactory< PFACREG_TYPE_INTERFACE >::instance().registerFactory( PFACREG_TYPE_NAME, FACTORY_FUNCTION_ ),
+ FACTORY_INSTANCE_.registerFactory( PFACREG_TYPE_NAME, FACTORY_FUNCTION_ ),
true);
# undef FACTORY_FUNCTION_
} // anon namespace
@@ -92,3 +94,4 @@
#undef PFACREG_TYPE
#undef PFACREG_TYPE_INTERFACE
#undef PFACREG_TYPE_NAME
+#undef PFACREG_CONTEXT
|