summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project2/cgi/cgiAppEngine.cpp2
-rw-r--r--project2/cgi/cgiOutputOptions.cpp2
-rw-r--r--project2/cgi/cgiOutputOptions.h2
-rw-r--r--project2/cgi/cgiStagePresent.cpp2
-rw-r--r--project2/common/genericLoader.h27
-rw-r--r--project2/common/library.cpp2
-rw-r--r--project2/common/memoryCache.cpp2
-rw-r--r--project2/common/optionsSource.h15
-rw-r--r--project2/common/presenter.h16
-rw-r--r--project2/common/scriptLoader.h39
-rw-r--r--project2/common/scriptStorage.h8
-rw-r--r--project2/common/scripts.h6
-rw-r--r--project2/common/scripts_fwd.h11
-rw-r--r--project2/common/sessionContainer.h17
-rw-r--r--project2/common/sourceObject.cpp2
-rw-r--r--project2/common/sourceObject.h6
-rw-r--r--project2/common/transform.cpp2
-rw-r--r--project2/common/transform.h26
-rw-r--r--project2/common/variables-modconfig.cpp2
-rw-r--r--project2/common/variables-modliteral.cpp2
-rw-r--r--project2/common/variables.h14
-rw-r--r--project2/compression/Jamfile.jam2
-rw-r--r--project2/compression/decompressor.h1
-rw-r--r--project2/files/fsRows.cpp2
-rw-r--r--project2/files/fsRows.h28
-rw-r--r--project2/files/presenterCache.cpp2
-rw-r--r--project2/json/couchSession.cpp2
-rw-r--r--project2/json/presenter.cpp2
-rw-r--r--project2/mail/sendmailTask.cpp2
-rw-r--r--project2/sql/connectionLoader.h16
-rw-r--r--project2/sql/rdbmsDataSource.cpp4
-rw-r--r--project2/sql/rdbmsDataSource.h3
-rw-r--r--project2/sql/sql-modODBC.cpp2
-rw-r--r--project2/sql/sql-modPQ.cpp2
-rw-r--r--project2/sql/sqlCache.cpp2
-rw-r--r--project2/xml/sessionXml.cpp2
-rw-r--r--project2/xml/transformText.cpp2
-rw-r--r--project2/xml/xmlCache.cpp2
-rw-r--r--project2/xml/xmlPresenter.cpp2
39 files changed, 91 insertions, 192 deletions
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp
index a503f3d..c7ee3e6 100644
--- a/project2/cgi/cgiAppEngine.cpp
+++ b/project2/cgi/cgiAppEngine.cpp
@@ -18,7 +18,7 @@ SimpleMessageException(UnknownDomain);
CgiApplicationEngine::CgiApplicationEngine(const CgiEnvironment * e, std::ostream & io) :
_env(e),
- sessionsContainer(LoaderBase::getLoader<SessionContainerLoader, NotSupported>(e->sessionModule)->open()),
+ sessionsContainer(SessionContainerLoader::getFor(e->sessionModule)->create()),
IO(io),
outputCachingActive(false)
{
diff --git a/project2/cgi/cgiOutputOptions.cpp b/project2/cgi/cgiOutputOptions.cpp
index e18a0b8..ba4d621 100644
--- a/project2/cgi/cgiOutputOptions.cpp
+++ b/project2/cgi/cgiOutputOptions.cpp
@@ -32,7 +32,7 @@ OutputOptionsLoader::OutputOptionsLoader() :
}
OutputOptionsPtr
-OutputOptionsLoader::createFrom(ScriptNodePtr e) const {
+OutputOptionsLoader::create(ScriptNodePtr e) const {
return new OutputOptions(e);
}
diff --git a/project2/cgi/cgiOutputOptions.h b/project2/cgi/cgiOutputOptions.h
index 4a4f1c8..faace67 100644
--- a/project2/cgi/cgiOutputOptions.h
+++ b/project2/cgi/cgiOutputOptions.h
@@ -31,7 +31,7 @@ typedef boost::intrusive_ptr<OutputOptions> OutputOptionsPtr;
class OutputOptionsLoader : public ComponentLoader {
public:
OutputOptionsLoader();
- OutputOptionsPtr createFrom(ScriptNodePtr e) const;
+ OutputOptionsPtr create(ScriptNodePtr e) const;
const Options * options() const;
private:
diff --git a/project2/cgi/cgiStagePresent.cpp b/project2/cgi/cgiStagePresent.cpp
index 9c7ab7f..98031e4 100644
--- a/project2/cgi/cgiStagePresent.cpp
+++ b/project2/cgi/cgiStagePresent.cpp
@@ -52,7 +52,7 @@ MultiRowSetPresenterPtr
CgiApplicationEngine::PresentStage::getPresenter() const
{
if (!presenter) {
- presenter = LoaderBase::getLoader<PresenterLoader, NotSupported>(env()->defaultPresenter)->createFrom(root);
+ presenter = PresenterLoader::getFor(env()->defaultPresenter)->create(root);
}
return presenter;
}
diff --git a/project2/common/genericLoader.h b/project2/common/genericLoader.h
deleted file mode 100644
index cd129f0..0000000
--- a/project2/common/genericLoader.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef GENERICLOADER_H
-#define GENERICLOADER_H
-
-#include "scriptLoader.h"
-
-template <class Impl, typename... Params>
-class GenLoader : public ComponentLoader {
- public:
- template <class T>
- class For : public GenLoader<Impl, Params...> {
- public:
- inline Impl * create(const Params & ... p) const
- {
- return new T(p...);
- }
- };
- virtual Impl * create(const Params & ...) const = 0;
- inline static boost::shared_ptr<GenLoader<Impl, Params...>> getFor(const char * n)
- {
- return LoaderBase::getLoader<GenLoader<Impl, Params...>, NotSupported>(n);
- }
-};
-#define DECLARE_GENERIC_LOADER(N, B, T) \
- DECLARE_CUSTOM_COMPONENT_LOADER(N, T, B::For<T>, B);
-
-#endif
-
diff --git a/project2/common/library.cpp b/project2/common/library.cpp
index f7cc51c..b53a6b0 100644
--- a/project2/common/library.cpp
+++ b/project2/common/library.cpp
@@ -25,7 +25,7 @@ Library::~Library()
}
STORAGEOF(Library) libraries;
-class LibraryLoader : public ElementLoaderImpl<Library> {
+class LibraryLoader : public ElementLoader::For<Library> {
public:
void onIteration()
{
diff --git a/project2/common/memoryCache.cpp b/project2/common/memoryCache.cpp
index a24abb3..cd13930 100644
--- a/project2/common/memoryCache.cpp
+++ b/project2/common/memoryCache.cpp
@@ -145,7 +145,7 @@ class MemoryCache : public Cache {
time_t MemoryCache::CacheLife;
MemoryCache::CacheStore MemoryCache::Store;
-class CustomMemoryCacheLoader : public ElementLoaderImpl<MemoryCache> {
+class CustomMemoryCacheLoader : public ElementLoader::For<MemoryCache> {
public:
CustomMemoryCacheLoader() :
opts("Memory Cache options")
diff --git a/project2/common/optionsSource.h b/project2/common/optionsSource.h
index f238a66..208e5ff 100644
--- a/project2/common/optionsSource.h
+++ b/project2/common/optionsSource.h
@@ -22,20 +22,7 @@ class OptionsSource : public IntrusivePtrBase {
typedef boost::intrusive_ptr<OptionsSource> OptionsSourcePtr;
/// Base class to implement presenter modules
-class OptionsSourceLoader : public ComponentLoader {
- public:
- virtual OptionsSourcePtr create() const = 0;
-};
-
-/// Helper implemention for specific presenters
-template <class OptionsSourceType>
-class OptionsSourceLoaderImpl : public OptionsSourceLoader {
- public:
- virtual OptionsSourcePtr create() const
- {
- return new OptionsSourceType();
- }
-};
+typedef GenLoader<OptionsSource> OptionsSourceLoader;
#endif
diff --git a/project2/common/presenter.h b/project2/common/presenter.h
index a16b32b..e1a78dd 100644
--- a/project2/common/presenter.h
+++ b/project2/common/presenter.h
@@ -76,21 +76,7 @@ typedef boost::intrusive_ptr<RowSetPresenter> RowSetPresenterPtr;
typedef boost::intrusive_ptr<MultiRowSetPresenter> MultiRowSetPresenterPtr;
typedef boost::intrusive_ptr<NameValuePairPresenter> NameValuePairPresenterPtr;
-/// Base class to implement presenter modules
-class PresenterLoader : public ComponentLoader {
- public:
- virtual MultiRowSetPresenterPtr createFrom(ScriptNodePtr e) const = 0;
-};
-
-/// Helper implemention for specific presenters
-template <class PresenterType>
-class PresenterLoaderImpl : public PresenterLoader {
- public:
- virtual MultiRowSetPresenterPtr createFrom(ScriptNodePtr e) const
- {
- return new PresenterType(e);
- }
-};
+typedef GenLoader<MultiRowSetPresenter, ScriptNodePtr> PresenterLoader;
#endif
diff --git a/project2/common/scriptLoader.h b/project2/common/scriptLoader.h
index b2faecd..ccc7afb 100644
--- a/project2/common/scriptLoader.h
+++ b/project2/common/scriptLoader.h
@@ -8,16 +8,18 @@
#include <boost/shared_ptr.hpp>
#include "intrusivePtrBase.h"
#include "sourceObject.h"
+#include "scripts_fwd.h"
#include "exceptions.h"
#include <glibmm/ustring.h>
#include <map>
#include <vector>
-class ElementLoader;
class ComponentLoader;
class CommonObjects;
class Storer;
class ScriptReader;
+class SourceObject;
+typedef boost::intrusive_ptr<SourceObject> SourceObjectPtr;
class LoaderBase {
public:
@@ -90,7 +92,7 @@ class LoaderBase {
static ScriptNodePtr getSub(ScriptNodePtr root, const Glib::ustring & name, bool required);
Targets targets;
static unsigned int depth;
- template <class X> friend class ElementLoaderImpl;
+ friend class SourceObject;
static std::set<SourceObjectPtr> loadedObjects;
const bool recursive;
@@ -107,9 +109,11 @@ class LoaderBase {
#define DECLARE_CUSTOM_LOADER(N, T) \
DECLARE_CUSTOM_COMPONENT_LOADER(N, T, T, ElementLoader)
#define DECLARE_COMPONENT_LOADER(N, T, B) \
- DECLARE_CUSTOM_COMPONENT_LOADER(N, T, B##Impl<T>, B)
+ DECLARE_CUSTOM_COMPONENT_LOADER(N, T, B::For<T>, B)
#define DECLARE_LOADER(N, T) \
DECLARE_COMPONENT_LOADER(N, T, ElementLoader)
+#define DECLARE_GENERIC_LOADER(N, B, T) \
+ DECLARE_CUSTOM_COMPONENT_LOADER(N, T, B::For<T>, B);
/// Helper for loading and maintaining Project2 components
class Options;
@@ -123,22 +127,27 @@ class ComponentLoader {
virtual void onPeriodic(); // When the app engine feels like it
virtual const Options * options() const; // Options to be populated from the common config file/env/etc
};
-/// Helper for loading and maintaining Project2 script components
-class ElementLoader : public ComponentLoader {
- public:
- virtual SourceObjectPtr createFrom(ScriptNodePtr) const = 0;
-};
-/// Helper for loading and maintaining Project2 script components (typed implementation)
-template <class X>
-class ElementLoaderImpl : public ElementLoader {
+template <class Impl, typename... Params>
+class GenLoader : public ComponentLoader {
public:
- SourceObjectPtr createFrom(ScriptNodePtr sn) const
+ template <class T>
+ class For : public GenLoader<Impl, Params...> {
+ public:
+ inline Impl * create(const Params & ... p) const
+ {
+ return new T(p...);
+ }
+ };
+ virtual Impl * create(const Params & ...) const = 0;
+ inline static boost::shared_ptr<GenLoader<Impl, Params...>> getFor(const std::string & n)
{
- SourceObjectPtr sop = new X(sn);
- LoaderBase::loadedObjects.insert(sop);
- return sop;
+ return LoaderBase::getLoader<GenLoader<Impl, Params...>, NotSupported>(n);
}
};
+
+/// Helper for loading and maintaining Project2 script components
+typedef GenLoader<SourceObject, ScriptNodePtr> ElementLoader;
+
#endif
diff --git a/project2/common/scriptStorage.h b/project2/common/scriptStorage.h
index c58711b..63ee71c 100644
--- a/project2/common/scriptStorage.h
+++ b/project2/common/scriptStorage.h
@@ -132,25 +132,25 @@ class StorerImpl<X, ANONORDEREDSTORAGEOF(X), L> : public StorerBase<X, L> {
template <class L, class X, typename... C>
boost::intrusive_ptr<StorerBase<X, L> >
Storer::into(SINGLE(X) * obj, const C & ... c) {
- return new StorerImpl<X, SINGLE(X), L>(obj, boost::bind(&L::createFrom, _1, _2, c...));
+ return new StorerImpl<X, SINGLE(X), L>(obj, boost::bind(&L::create, _1, _2, c...));
}
template <class L, class X, typename... C>
boost::intrusive_ptr<StorerBase<X, L> >
Storer::into(STORAGEOF(X) * map, const C & ... c) {
- return new StorerImpl<X, STORAGEOF(X), L>(map, boost::bind(&L::createFrom, _1, _2, c...));
+ return new StorerImpl<X, STORAGEOF(X), L>(map, boost::bind(&L::create, _1, _2, c...));
}
template <class L, class X, typename... C>
boost::intrusive_ptr<StorerBase<X, L> >
Storer::into(ANONSTORAGEOF(X) * set, const C & ... c) {
- return new StorerImpl<X, ANONSTORAGEOF(X), L>(set, boost::bind(&L::createFrom, _1, _2, c...));
+ return new StorerImpl<X, ANONSTORAGEOF(X), L>(set, boost::bind(&L::create, _1, _2, c...));
}
template <class L, class X, typename... C>
boost::intrusive_ptr<StorerBase<X, L> >
Storer::into(ANONORDEREDSTORAGEOF(X) * list, const C & ... c) {
- return new StorerImpl<X, ANONORDEREDSTORAGEOF(X), L>(list, boost::bind(&L::createFrom, _1, _2, c...));
+ return new StorerImpl<X, ANONORDEREDSTORAGEOF(X), L>(list, boost::bind(&L::create, _1, _2, c...));
}
#endif
diff --git a/project2/common/scripts.h b/project2/common/scripts.h
index 972c23f..ba5a8e9 100644
--- a/project2/common/scripts.h
+++ b/project2/common/scripts.h
@@ -6,6 +6,7 @@
#include <boost/function.hpp>
#include <boost/optional.hpp>
#include "scriptLoader.h"
+#include "scripts_fwd.h"
#include "exceptions.h"
#include "variables.h"
#include <vector>
@@ -14,11 +15,6 @@ SimpleMessageException(ValueNotFound);
SimpleMessage2Exception(ScriptNotFound);
SimpleMessage2Exception(DependencyNotFound);
-class ScriptNode;
-class ScriptReader;
-typedef boost::intrusive_ptr<const ScriptNode> ScriptNodePtr;
-typedef boost::intrusive_ptr<const ScriptReader> ScriptReaderPtr;
-
class ScriptNode : public IntrusivePtrBase {
public:
ScriptNode(ScriptReaderPtr);
diff --git a/project2/common/scripts_fwd.h b/project2/common/scripts_fwd.h
new file mode 100644
index 0000000..7d5ed00
--- /dev/null
+++ b/project2/common/scripts_fwd.h
@@ -0,0 +1,11 @@
+#ifndef SCRIPTS_FWD_H
+#define SCRIPTS_FWD_H
+
+#include <boost/intrusive_ptr.hpp>
+
+class ScriptNode;
+class ScriptReader;
+typedef boost::intrusive_ptr<const ScriptNode> ScriptNodePtr;
+typedef boost::intrusive_ptr<const ScriptReader> ScriptReaderPtr;
+
+#endif
diff --git a/project2/common/sessionContainer.h b/project2/common/sessionContainer.h
index ffbc5ed..2a20085 100644
--- a/project2/common/sessionContainer.h
+++ b/project2/common/sessionContainer.h
@@ -17,22 +17,7 @@ class SessionContainer : public IntrusivePtrBase {
virtual SessionPtr getSession(const UUID & sid) const = 0;
};
typedef boost::intrusive_ptr<SessionContainer> SessionContainerPtr;
-
-/// Base class to implement session container imlpementations
-class SessionContainerLoader : public ComponentLoader {
- public:
- virtual SessionContainerPtr open() const = 0;
-};
-
-/// Helper implemention for specific container types
-template <class SCType>
-class SessionContainerLoaderImpl : public SessionContainerLoader {
- public:
- virtual SessionContainerPtr open() const
- {
- return new SCType();
- }
-};
+typedef GenLoader<SessionContainer> SessionContainerLoader;
#endif
diff --git a/project2/common/sourceObject.cpp b/project2/common/sourceObject.cpp
index ccc1034..e66e9ee 100644
--- a/project2/common/sourceObject.cpp
+++ b/project2/common/sourceObject.cpp
@@ -7,12 +7,14 @@ SourceObject::SourceObject(ScriptNodePtr p) :
name(p ? p->value("name", "anon").as<std::string>() : "anon"),
order(loadOrder++)
{
+ LoaderBase::loadedObjects.insert(this);
}
SourceObject::SourceObject(const std::string & n) :
name(n),
order(loadOrder++)
{
+ LoaderBase::loadedObjects.insert(this);
}
SourceObject::~SourceObject()
diff --git a/project2/common/sourceObject.h b/project2/common/sourceObject.h
index 4d10dd4..8cf75ad 100644
--- a/project2/common/sourceObject.h
+++ b/project2/common/sourceObject.h
@@ -4,12 +4,10 @@
#include <boost/intrusive_ptr.hpp>
#include <string>
#include "intrusivePtrBase.h"
+#include "scriptLoader.h"
+#include "scripts_fwd.h"
class CommonObjects;
-class SourceObject;
-class ScriptNode;
-typedef boost::intrusive_ptr<SourceObject> SourceObjectPtr;
-typedef boost::intrusive_ptr<const ScriptNode> ScriptNodePtr;
/// Base class for all Project2 components that can be placed in a Project2 script
class SourceObject : public virtual IntrusivePtrBase {
public:
diff --git a/project2/common/transform.cpp b/project2/common/transform.cpp
index 9a53107..874ced3 100644
--- a/project2/common/transform.cpp
+++ b/project2/common/transform.cpp
@@ -12,7 +12,7 @@ class TransformTargetStorer : public Storer {
}
boost::intrusive_ptr<IntrusivePtrBase> create(ScriptNodePtr p) const
{
- return LoaderBase::getLoader<TransformTargetLoader, NotSupported>(p->get_name())->createFrom(p);
+ return LoaderBase::getLoader<TransformTargetLoader, NotSupported>(p->get_name())->create(p);
}
bool save(boost::intrusive_ptr<IntrusivePtrBase> o, ScriptNodePtr s)
{
diff --git a/project2/common/transform.h b/project2/common/transform.h
index e2216d7..2355195 100644
--- a/project2/common/transform.h
+++ b/project2/common/transform.h
@@ -45,32 +45,10 @@ class Transform : public virtual IntrusivePtrBase {
virtual void configure(ScriptNodePtr) { };
};
-class TransformLoader : public ComponentLoader {
- public:
- virtual boost::intrusive_ptr<Transform> create() const = 0;
-};
-
-template <class T>
-class TransformLoaderImpl : public TransformLoader {
- public:
- boost::intrusive_ptr<Transform> create() const {
- return new T();
- }
-};
+typedef GenLoader<Transform> TransformLoader;
#define DECLARE_TRANSFORM(T) DECLARE_COMPONENT_LOADER(#T, T, TransformLoader)
-class TransformTargetLoader : public ComponentLoader {
- public:
- virtual boost::intrusive_ptr<TransformChainLink> createFrom(ScriptNodePtr) const = 0;
-};
-
-template <class T>
-class TransformTargetLoaderImpl : public TransformTargetLoader {
- public:
- boost::intrusive_ptr<TransformChainLink> createFrom(ScriptNodePtr s) const {
- return new T(s);
- }
-};
+typedef GenLoader<TransformChainLink, ScriptNodePtr> TransformTargetLoader;
#define DECLARE_TRANSFORMTARGET(N, T) DECLARE_COMPONENT_LOADER(N, T, TransformTargetLoader)
template <class Source, class Destination>
diff --git a/project2/common/variables-modconfig.cpp b/project2/common/variables-modconfig.cpp
index 3f5e25a..4d9553a 100644
--- a/project2/common/variables-modconfig.cpp
+++ b/project2/common/variables-modconfig.cpp
@@ -33,7 +33,7 @@ class VariableConfig : public VariableImplDyn {
const Glib::ustring name;
};
-class VariableConfigLoader : public VariableLoaderImpl<VariableConfig> {
+class VariableConfigLoader : public VariableLoader::For<VariableConfig> {
public:
class AppSettings : public Options::Option {
public:
diff --git a/project2/common/variables-modliteral.cpp b/project2/common/variables-modliteral.cpp
index 8c165ee..33c9ad5 100644
--- a/project2/common/variables-modliteral.cpp
+++ b/project2/common/variables-modliteral.cpp
@@ -73,6 +73,6 @@ VariableLiteral::VarPart::operator VariableType() const
}
DECLARE_COMPONENT_LOADER("literal", VariableLiteral, VariableLoader);
-DECLARE_CUSTOM_COMPONENT_LOADER("", VariableLiteralDef, VariableLoaderImpl<VariableLiteral>, VariableLoader);
+DECLARE_CUSTOM_COMPONENT_LOADER("", VariableLiteralDef, VariableLoader::For<VariableLiteral>, VariableLoader);
diff --git a/project2/common/variables.h b/project2/common/variables.h
index ca2cdc7..932da90 100644
--- a/project2/common/variables.h
+++ b/project2/common/variables.h
@@ -136,19 +136,7 @@ class VariableImplDyn : public VariableImpl {
};
/// Base class to create variables
-class VariableLoader : public ComponentLoader {
- public:
- virtual VariableImpl * create(ScriptNodePtr) const = 0;
-};
-/// Helper implementation of VariableLoader for specific variable types
-template <class VarType>
-class VariableLoaderImpl : public VariableLoader {
- public:
- virtual VariableImpl * create(ScriptNodePtr e) const
- {
- return new VarType(e);
- }
-};
+typedef GenLoader<VariableImpl, ScriptNodePtr> VariableLoader;
#endif
diff --git a/project2/compression/Jamfile.jam b/project2/compression/Jamfile.jam
index 99d3b75..b1715cb 100644
--- a/project2/compression/Jamfile.jam
+++ b/project2/compression/Jamfile.jam
@@ -12,6 +12,6 @@ lib p2compression :
<library>glibmm
<library>libz
<library>../common//p2common
- <library>../files//p2files
+ <library>../streams//p2streams
;
diff --git a/project2/compression/decompressor.h b/project2/compression/decompressor.h
index dfa1db7..32be53a 100644
--- a/project2/compression/decompressor.h
+++ b/project2/compression/decompressor.h
@@ -2,7 +2,6 @@
#define DECOMPRESSOR
#include "stream.h"
-#include "genericLoader.h"
#include "intrusivePtrBase.h"
class Decompressor : public IntrusivePtrBase {
diff --git a/project2/files/fsRows.cpp b/project2/files/fsRows.cpp
index 9dfa3f8..72a2055 100644
--- a/project2/files/fsRows.cpp
+++ b/project2/files/fsRows.cpp
@@ -80,7 +80,7 @@ FsRows::execute(const Glib::ustring &, const RowProcessor * rp) const
for (SpecSpec::const_iterator sf = s.begin(); sf != s.end(); ) {
const Glib::ustring & name = (*sf++);
if (name[0] == '-') {
- ss.specs.insert(LoaderBase::getLoader<SpecBaseLoader, NotSupported>(name.substr(1))->create(*sf++));
+ ss.specs.insert(LoaderBase::getLoader<SpecBaseLoader, NotSupported>(name.substr(1))->createWith(*sf++));
}
else {
throw NotSupported(name);
diff --git a/project2/files/fsRows.h b/project2/files/fsRows.h
index acbce0d..6b689d3 100644
--- a/project2/files/fsRows.h
+++ b/project2/files/fsRows.h
@@ -7,6 +7,7 @@
#include "variables.h"
#include "rowSet.h"
#include "scriptStorage.h"
+#include "scriptLoader.h"
class CommonObjects;
@@ -24,21 +25,22 @@ class FsRows : public RowSet {
const struct stat & curStat(const SearchState * fs) const;
};
typedef boost::intrusive_ptr<SpecBase> SpecBasePtr;
- class SpecBaseLoader : public ComponentLoader {
+ template <class X>
+ class SpecBaseLoaderX : public GenLoader<SpecBase, ScriptNodePtr> {
public:
- virtual SpecBasePtr createFrom(ScriptNodePtr) const = 0;
- virtual SpecBasePtr create(const Glib::ustring &) const = 0;
- };
- template <class T>
- class SpecBaseLoaderImpl : public SpecBaseLoader {
- public:
- SpecBasePtr createFrom(ScriptNodePtr s) const {
- return new T(s);
- }
- SpecBasePtr create(const Glib::ustring & v) const {
- return new T(v);
- }
+ virtual SpecBase * createWith(const Glib::ustring &) const = 0;
+ template <class T>
+ class For : public SpecBaseLoaderX<X> {
+ public:
+ SpecBase * create(const ScriptNodePtr & v) const {
+ return new T(v);
+ }
+ SpecBase * createWith(const Glib::ustring & v) const {
+ return new T(v);
+ }
+ };
};
+ typedef SpecBaseLoaderX<void> SpecBaseLoader;
typedef ANONSTORAGEOF(SpecBase) SpecBases;
typedef std::list<Glib::ustring> SpecSpec;
typedef boost::filesystem::path Path;
diff --git a/project2/files/presenterCache.cpp b/project2/files/presenterCache.cpp
index 789dd95..8d189b5 100644
--- a/project2/files/presenterCache.cpp
+++ b/project2/files/presenterCache.cpp
@@ -139,7 +139,7 @@ boost::filesystem::path FilePresenterCache::Store;
std::string FilePresenterCache::FileName;
time_t FilePresenterCache::CacheLife;
-class FilePresenterCacheLoader : public ElementLoaderImpl<FilePresenterCache> {
+class FilePresenterCacheLoader : public ElementLoader::For<FilePresenterCache> {
public:
FilePresenterCacheLoader() :
opts("XML Cache options")
diff --git a/project2/json/couchSession.cpp b/project2/json/couchSession.cpp
index 5d964aa..a6c49e9 100644
--- a/project2/json/couchSession.cpp
+++ b/project2/json/couchSession.cpp
@@ -105,7 +105,7 @@ class CouchSessionContainer : public SessionContainer {
std::vector<std::string> CouchSessionContainer::baseUrls;
const Glib::ustring CouchSessionContainer::ExpiryKey("project2:expires");
-class CustomCouchSessionLoader : public SessionContainerLoaderImpl<CouchSessionContainer> {
+class CustomCouchSessionLoader : public SessionContainerLoader::For<CouchSessionContainer> {
public:
CustomCouchSessionLoader() :
opts("Session CouchDB options")
diff --git a/project2/json/presenter.cpp b/project2/json/presenter.cpp
index 0eb484b..b76f232 100644
--- a/project2/json/presenter.cpp
+++ b/project2/json/presenter.cpp
@@ -97,4 +97,4 @@ class JsonPresenter : public MultiRowSetPresenter, public ContentPresenter, publ
mutable std::stack<json::Object *> curRowSet;
mutable std::stack<json::Array *> curRowArray;
};
-DECLARE_COMPONENT_LOADER("json", JsonPresenter, PresenterLoader)
+DECLARE_GENERIC_LOADER("json", PresenterLoader, JsonPresenter)
diff --git a/project2/mail/sendmailTask.cpp b/project2/mail/sendmailTask.cpp
index f8bc879..f70fe64 100644
--- a/project2/mail/sendmailTask.cpp
+++ b/project2/mail/sendmailTask.cpp
@@ -14,7 +14,7 @@
std::string SendMailTask::defaultMailServer;
std::string SendMailTask::defaultMailEncoding;
-class CustomSendMailTaskLoader : public ElementLoaderImpl<SendMailTask> {
+class CustomSendMailTaskLoader : public ElementLoader::For<SendMailTask> {
public:
CustomSendMailTaskLoader() :
opts("Send Email Task options")
diff --git a/project2/sql/connectionLoader.h b/project2/sql/connectionLoader.h
index 3dc5f93..89de76b 100644
--- a/project2/sql/connectionLoader.h
+++ b/project2/sql/connectionLoader.h
@@ -4,21 +4,7 @@
#include "scriptLoader.h"
#include "../libdbpp/connection.h"
-/// Base class to implement DB connection type modules
-class ConnectionLoader : public ComponentLoader {
- public:
- virtual DB::Connection * connect(const std::string & dsn) const = 0;
-};
-
-/// Helper implemention for specific DB types
-template <class DBType>
-class ConnectionLoaderImpl : public ConnectionLoader {
- public:
- virtual DB::Connection * connect(const std::string & dsn) const
- {
- return new DBType(dsn);
- }
-};
+typedef GenLoader<DB::Connection, std::string> ConnectionLoader;
#endif
diff --git a/project2/sql/rdbmsDataSource.cpp b/project2/sql/rdbmsDataSource.cpp
index 6f3cedb..8bdacdf 100644
--- a/project2/sql/rdbmsDataSource.cpp
+++ b/project2/sql/rdbmsDataSource.cpp
@@ -9,7 +9,7 @@
SimpleMessageException(UnknownConnectionProvider);
/// Specialized ElementLoader for instances of RdbmsDataSource; handles persistent DB connections
-class RdbmsDataSourceLoader : public ElementLoaderImpl<RdbmsDataSource> {
+class RdbmsDataSourceLoader : public ElementLoader::For<RdbmsDataSource> {
public:
void onIdle()
{
@@ -201,7 +201,7 @@ RdbmsDataSource::ConnectionInfo::ConnectionInfo(ScriptNodePtr node) :
DB::Connection *
RdbmsDataSource::ConnectionInfo::connect() const
{
- return typeId->connect(dsn);
+ return typeId->create(dsn);
}
bool
diff --git a/project2/sql/rdbmsDataSource.h b/project2/sql/rdbmsDataSource.h
index c0345a0..6d3b184 100644
--- a/project2/sql/rdbmsDataSource.h
+++ b/project2/sql/rdbmsDataSource.h
@@ -8,8 +8,7 @@
#include "../libdbpp/connection.h"
#include "../libdbpp/error.h"
#include "scriptLoader.h"
-
-class ConnectionLoader;
+#include "connectionLoader.h"
/// Project2 component to provide access to transactional RDBMS data sources
class RdbmsDataSource : public DataSource {
diff --git a/project2/sql/sql-modODBC.cpp b/project2/sql/sql-modODBC.cpp
index 1703cb6..284d02e 100644
--- a/project2/sql/sql-modODBC.cpp
+++ b/project2/sql/sql-modODBC.cpp
@@ -1,4 +1,4 @@
#include "connectionLoader.h"
#include "../libodbcpp/connection.h"
typedef ODBC::Connection ODBCConnection;
-DECLARE_COMPONENT_LOADER("odbc", ODBCConnection, ConnectionLoader)
+DECLARE_GENERIC_LOADER("odbc", ConnectionLoader, ODBCConnection)
diff --git a/project2/sql/sql-modPQ.cpp b/project2/sql/sql-modPQ.cpp
index 5991754..cb753e0 100644
--- a/project2/sql/sql-modPQ.cpp
+++ b/project2/sql/sql-modPQ.cpp
@@ -1,4 +1,4 @@
#include "connectionLoader.h"
#include "../libpqpp/connection.h"
typedef PQ::Connection PQConnection;
-DECLARE_COMPONENT_LOADER("postgresql", PQConnection, ConnectionLoader)
+DECLARE_GENERIC_LOADER("postgresql", ConnectionLoader, PQConnection)
diff --git a/project2/sql/sqlCache.cpp b/project2/sql/sqlCache.cpp
index e94e345..08d2831 100644
--- a/project2/sql/sqlCache.cpp
+++ b/project2/sql/sqlCache.cpp
@@ -257,7 +257,7 @@ std::string SqlCache::DataSource;
std::string SqlCache::HeaderTable;
time_t SqlCache::CacheLife;
-class CustomSqlCacheLoader : public ElementLoaderImpl<SqlCache> {
+class CustomSqlCacheLoader : public ElementLoader::For<SqlCache> {
public:
CustomSqlCacheLoader() :
opts("SQL Cache options")
diff --git a/project2/xml/sessionXml.cpp b/project2/xml/sessionXml.cpp
index a3455f6..db34b52 100644
--- a/project2/xml/sessionXml.cpp
+++ b/project2/xml/sessionXml.cpp
@@ -8,7 +8,7 @@
#include <boost/lexical_cast.hpp>
#include "options.h"
-class CustomSessionContainerLoaderXml : public SessionContainerLoaderImpl<SessionContainerXml> {
+class CustomSessionContainerLoaderXml : public SessionContainerLoader::For<SessionContainerXml> {
public:
CustomSessionContainerLoaderXml() :
opts("SessionXML options")
diff --git a/project2/xml/transformText.cpp b/project2/xml/transformText.cpp
index efe0c0b..02c12e3 100644
--- a/project2/xml/transformText.cpp
+++ b/project2/xml/transformText.cpp
@@ -35,7 +35,7 @@ TextDocument::getContentClass() const {
}
class TransformHtmlToText;
-class TransformHtmlToTextLoader : public TransformLoaderImpl<TransformHtmlToText> {
+class TransformHtmlToTextLoader : public TransformLoader::For<TransformHtmlToText> {
public:
TransformHtmlToTextLoader() :
opts("Transform HTML to text options")
diff --git a/project2/xml/xmlCache.cpp b/project2/xml/xmlCache.cpp
index 0ec745b..abe56ab 100644
--- a/project2/xml/xmlCache.cpp
+++ b/project2/xml/xmlCache.cpp
@@ -84,7 +84,7 @@ boost::filesystem::path XmlCache::Store;
std::string XmlCache::FileName;
time_t XmlCache::CacheLife;
-class CustomXmlCacheLoader : public ElementLoaderImpl<XmlCache> {
+class CustomXmlCacheLoader : public ElementLoader::For<XmlCache> {
public:
CustomXmlCacheLoader() :
opts("XML Cache options")
diff --git a/project2/xml/xmlPresenter.cpp b/project2/xml/xmlPresenter.cpp
index 02ec82d..a6d6f40 100644
--- a/project2/xml/xmlPresenter.cpp
+++ b/project2/xml/xmlPresenter.cpp
@@ -7,7 +7,7 @@
#include <boost/date_time/posix_time/time_formatters.hpp>
#include <boost/date_time/gregorian/formatters.hpp>
-class XmlPresenterLoader : public PresenterLoaderImpl<XmlPresenter> {
+class XmlPresenterLoader : public PresenterLoader::For<XmlPresenter> {
public:
XmlPresenterLoader() :
opts("XML Cache options")