Update of /cvsroot/mahogany/M/include
In directory sc8-pr-cvs1:/tmp/cvs-serv21616/include
Modified Files:
ConfigSource.h
Log Message:
fixed ConfigSource stuff compilation
Index: ConfigSource.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/ConfigSource.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -u -2 -r1.2 -r1.3
--- ConfigSource.h 24 Aug 2003 22:48:24 -0000 1.2
+++ ConfigSource.h 25 Aug 2003 22:49:20 -0000 1.3
@@ -137,5 +137,5 @@
@param value pointer to the result, must not be NULL!
*/
- virtual bool Read(const String& name, String *value) = 0;
+ virtual bool Read(const String& name, String *value) const = 0;
/**
@@ -145,5 +145,5 @@
@param value pointer to the result, must not be NULL!
*/
- virtual bool Read(const String& name, long *value) = 0;
+ virtual bool Read(const String& name, long *value) const = 0;
//@}
@@ -247,6 +247,6 @@
virtual bool IsOk() const;
virtual bool IsLocal() const;
- virtual bool Read(const String& name, String *value);
- virtual bool Read(const String& name, long *value);
+ virtual bool Read(const String& name, String *value) const;
+ virtual bool Read(const String& name, long *value) const;
virtual bool Write(const String& name, const String& value);
virtual bool Write(const String& name, long value);
@@ -267,12 +267,57 @@
This class is used to create config sources from their types.
-
- It derives from MModule which means that config source factories can be
- loaded during run-time as/if needed.
*/
-class ConfigSourceFactory : public MModule
+class ConfigSourceFactory : public MObjectRC
{
public:
/**
+ This class is used by GetFirst() and GetNext() internally.
+
+ To enumerate all config source factories you should simply do something
+ like this:
+ @code
+ ConfigSourceFactory::EnumData data;
+ for ( ConfigSourceFactory *fact = ConfigSourceFactory::GetFirst(data);
+ fact;
+ fact = ConfigSourceFactory::GetNext(data) )
+ {
+ ... do whatever with fact ...
+
+ fact->DecRef();
+ }
+ @endcode
+ */
+ class EnumData
+ {
+ public:
+ EnumData();
+ ~EnumData();
+
+ private:
+ // for ConfigSourceFactory::GetFirst() only: resets the object ot the
+ // initial state
+ void Reset();
+
+ // for ConfigSourceFactory::GetNext() only: returns the next listing
+ // entry or NULL if no more
+ const MModuleListingEntry *GetNext();
+
+
+ // the listing containing all config source factory modules
+ MModuleListing *m_listing;
+
+ // the index of the next element to be returned
+ size_t m_current;
+
+
+ // we can't be copied
+ EnumData(const EnumData&);
+ EnumData& operator=(const EnumData&);
+
+ friend class ConfigSourceFactory;
+ };
+
+
+ /**
Finds the factory for creating the config sources of given type.
@@ -283,4 +328,42 @@
/**
+ Get the first factory.
+
+ This function and the next one allow to enumerate all available config
+ sources factories.
+
+ The caller is responsible for calling DecRef() on the returned pointer if
+ it is not NULL.
+
+ @param cookie the enumeration data, should be passed to GetNext() later
+ @return the first factory in the list or NULL
+ */
+ static ConfigSourceFactory *GetFirst(EnumData& cookie);
+
+ /**
+ Get the next factory.
+
+ This function is used together with GetFirst() to enumerate all avilable
+ factories.
+
+ The caller is responsible for calling DecRef() on the returned pointer if
+ it is not NULL.
+
+ @param cookie the same cookie as used with GetFirst() previously
+ @return the next factory in the list or NULL
+ */
+ static ConfigSourceFactory *GetNext(EnumData& cookie);
+
+
+ /**
+ Get the string identifying this config source factory.
+
+ The factory types are case-insensitive.
+
+ @return string uniquely identifying this factory.
+ */
+ virtual const char *GetType() const = 0;
+
+ /**
Creates the config source object.
@@ -300,4 +383,19 @@
/**
+ ConfigSourceFactoryModule is used to load ConfigSourceFactory from shared
+ libraries during run-time.
+ */
+class ConfigSourceFactoryModule : public MModule
+{
+public:
+ /**
+ Creates the config factory implemented by this module.
+
+ @return pointer to the factory to be DecRef()'d by the caller or NULL
+ */
+ virtual ConfigSourceFactory *CreateFactory() = 0;
+};
+
+/**
The config source module interface name.
@@ -305,10 +403,10 @@
ConfigSourceFactory implementations.
*/
-#define CONIFG_SOURCE_INTERFACE _T("ConfigSource")
+#define CONFIG_SOURCE_INTERFACE _T("ConfigSource")
/**
- This macro is used to create ConfigSourceFactory-derived classes.
+ This macro is used to create ConfigSourceFactoryModule-derived classes.
- The implementation of classes deriving from ConfigSourceFactory is
+ 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.
@@ -324,5 +422,5 @@
*/
#define IMPLEMENT_CONFIG_SOURCE(cname, type, desc, cpyright) \
- class cname##Factory : public ConfigSourceFactory \
+ class cname##Factory : public ConfigSourceFactoryModule \
{ \
public: \
@@ -330,10 +428,10 @@
\
virtual ConfigSource *Create(const ConfigSource& config, \
- const St& name) \
+ const String& name) \
{ \
cname *configNew = new cname(config, name); \
if ( !configNew->IsOk() ) \
{ \
- delete configNew; \
+ configNew->DecRef(); \
configNew = NULL; \
} \
@@ -346,5 +444,5 @@
}; \
MMODULE_BEGIN_IMPLEMENT(cname##Factory, #cname, \
- CONIFG_SOURCE_INTERFACE, desc, "1.00") \
+ CONFIG_SOURCE_INTERFACE, desc, "1.00") \
MMODULE_PROP("author", cpyright) \
MMODULE_END_IMPLEMENT(cname##Factory) \
-------------------------------------------------------
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