Update of /cvsroot/mahogany/M/include
In directory sc8-pr-cvs1:/tmp/cvs-serv28494/include
Modified Files:
ConfigSource.h
Log Message:
corrected IMPLEMENT_CONFIG_SOURCE macro
Index: ConfigSource.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/ConfigSource.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -u -2 -r1.3 -r1.4
--- ConfigSource.h 25 Aug 2003 22:49:20 -0000 1.3
+++ ConfigSource.h 25 Aug 2003 23:34:36 -0000 1.4
@@ -408,7 +408,8 @@
This macro is used to create ConfigSourceFactoryModule-derived classes.
- The implementation of classes deriving from ConfigSourceFactoryModule is
- straightforward: we just have to create an object of the specified class in
- Create() and return it so we provide a macro to automate this.
+ For each new ConfigSource implementation you write you also have to write a
+ factory fopr creating it and, if you want to make it a module, a
+ MModule-derived class as well. Doing this is completely straightforward and
+ so we provide a macro to automate this.
This macro relies on cname having a ctor taking the same parameters as our
@@ -422,7 +423,18 @@
*/
#define IMPLEMENT_CONFIG_SOURCE(cname, type, desc, cpyright) \
- class cname##Factory : public ConfigSourceFactoryModule \
+ class cname##Factory : public ConfigSourceFactory \
{ \
public: \
+ cname##Factory(MModule *module) \
+ { \
+ m_module = module; \
+ } \
+ \
+ virtual ~cname##Factory() \
+ { \
+ if ( m_module ) \
+ m_module->DecRef(); \
+ } \
+ \
virtual const char *GetType() const { return type; } \
\
@@ -440,12 +452,26 @@
} \
\
+ private: \
+ MModule *m_module; \
+ }; \
+ \
+ class cname##FactoryModule : public ConfigSourceFactoryModule \
+ { \
+ public: \
+ virtual ConfigSourceFactory *CreateFactory() \
+ { \
+ return new cname##Factory(this); \
+ } \
+ \
MMODULE_DEFINE(); \
DEFAULT_ENTRY_FUNC; \
}; \
- MMODULE_BEGIN_IMPLEMENT(cname##Factory, #cname, \
+ \
+ MMODULE_BEGIN_IMPLEMENT(cname##FactoryModule, #cname, \
CONFIG_SOURCE_INTERFACE, desc, "1.00") \
MMODULE_PROP("author", cpyright) \
- MMODULE_END_IMPLEMENT(cname##Factory) \
- MModule *cname##Factory::Init(int /* version_major */, \
+ MMODULE_END_IMPLEMENT(cname##FactoryModule) \
+ MModule * \
+ cname##FactoryModule::Init(int /* version_major */, \
int /* version_minor */, \
int /* version_release */, \
@@ -453,6 +479,6 @@
int * /* errorCode */) \
{ \
- return new cname##Factory(); \
- }
+ return new cname##FactoryModule(); \
+ } \
#endif // _M_CONFIGSOURCE_H_
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates