diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-09-30 23:48:05 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-09-30 23:48:05 +0100 |
commit | d10b8914aeb4f297d6b6deca2408cd81b1adad08 (patch) | |
tree | 25fb41739387671e8e7a183778686ffdc5a29b4c /project2/files | |
parent | Remove NoOutputExecute for not being a thing (diff) | |
download | project2-d10b8914aeb4f297d6b6deca2408cd81b1adad08.tar.bz2 project2-d10b8914aeb4f297d6b6deca2408cd81b1adad08.tar.xz project2-d10b8914aeb4f297d6b6deca2408cd81b1adad08.zip |
Use AdHoc plugins for scriptable things and remove legacy plugin support
Diffstat (limited to 'project2/files')
-rw-r--r-- | project2/files/fileStream.cpp | 6 | ||||
-rw-r--r-- | project2/files/fsFilterMaxDepth.cpp | 3 | ||||
-rw-r--r-- | project2/files/fsFilterName.cpp | 3 | ||||
-rw-r--r-- | project2/files/fsFilterType.cpp | 4 | ||||
-rw-r--r-- | project2/files/fsRows.cpp | 11 | ||||
-rw-r--r-- | project2/files/fsRows.h | 19 | ||||
-rw-r--r-- | project2/files/presenterCache.cpp | 5 | ||||
-rw-r--r-- | project2/files/writeStream.cpp | 4 |
8 files changed, 24 insertions, 31 deletions
diff --git a/project2/files/fileStream.cpp b/project2/files/fileStream.cpp index 62bfa5b..ddfa30b 100644 --- a/project2/files/fileStream.cpp +++ b/project2/files/fileStream.cpp @@ -7,7 +7,6 @@ #include "exceptions.h" #include <boost/algorithm/string/predicate.hpp> - class FileStream : public Stream { public: FileStream(ScriptNodePtr p) : @@ -22,7 +21,7 @@ class FileStream : public Stream { throw NotSupported(__PRETTY_FUNCTION__); } - void runStream(const Sink & sink, ExecContext * ec) const + void runStream(const Sink & sink, ExecContext * ec) const override { FILE * file = fopen(path(ec), "r"); if (!file) { @@ -46,4 +45,5 @@ class FileStream : public Stream { const Variable contentType; const Variable path; }; -DECLARE_LOADER("filestream", FileStream); +NAMEDFACTORY("filestream", FileStream, StreamFactory); + diff --git a/project2/files/fsFilterMaxDepth.cpp b/project2/files/fsFilterMaxDepth.cpp index 089737a..d55b0d1 100644 --- a/project2/files/fsFilterMaxDepth.cpp +++ b/project2/files/fsFilterMaxDepth.cpp @@ -19,4 +19,5 @@ class FsRowSpecMaxDepth : public FsRows::SpecBase { Variable maxDepth; }; -DECLARE_COMPONENT_LOADER("maxdepth", FsRowSpecMaxDepth, FsRows::SpecBaseLoader); +NAMEDFACTORY("maxdepth", FsRowSpecMaxDepth, FsRows::SpecBaseFactory); +NAMEDFACTORY("maxdepth", FsRowSpecMaxDepth, FsRows::SpecBaseStringFactory); diff --git a/project2/files/fsFilterName.cpp b/project2/files/fsFilterName.cpp index 92279c2..62ca04b 100644 --- a/project2/files/fsFilterName.cpp +++ b/project2/files/fsFilterName.cpp @@ -54,4 +54,5 @@ class FsRowSpecName : public FsRows::SpecBase { const Variable pattern; }; -DECLARE_COMPONENT_LOADER("name", FsRowSpecName, FsRows::SpecBaseLoader); +NAMEDFACTORY("name", FsRowSpecName, FsRows::SpecBaseFactory); +NAMEDFACTORY("name", FsRowSpecName, FsRows::SpecBaseStringFactory); diff --git a/project2/files/fsFilterType.cpp b/project2/files/fsFilterType.cpp index ba9ad72..2aecfee 100644 --- a/project2/files/fsFilterType.cpp +++ b/project2/files/fsFilterType.cpp @@ -40,4 +40,6 @@ class FsRowSpecType : public FsRows::SpecBase { const Variable typelist; }; -DECLARE_COMPONENT_LOADER("type", FsRowSpecType, FsRows::SpecBaseLoader); +NAMEDFACTORY("type", FsRowSpecType, FsRows::SpecBaseFactory); +NAMEDFACTORY("type", FsRowSpecType, FsRows::SpecBaseStringFactory); + diff --git a/project2/files/fsRows.cpp b/project2/files/fsRows.cpp index d22b6ea..c67c02f 100644 --- a/project2/files/fsRows.cpp +++ b/project2/files/fsRows.cpp @@ -14,11 +14,11 @@ #include <grp.h> #include <stdio.h> #include <boost/date_time/posix_time/posix_time.hpp> -#include "instanceStore.impl.h" +#include <factory.impl.h> typedef boost::filesystem::directory_iterator DirEnt; -DECLARE_LOADER("fsrows", FsRows); +NAMEDFACTORY("fsrows", FsRows, RowSetFactory); const Glib::ustring field_absPath("absPath"); const Glib::ustring field_relPath("relPath"); @@ -50,7 +50,7 @@ FsRows::FsRows(ScriptNodePtr p) : spec(p, "spec", ""), ignoreErrors(p, "ignoreerrors", true) { - p->script->loader.addLoadTarget(p, Storer::into<SpecBaseLoader>(&specs)); + p->script->loader.addLoadTarget(p, Storer::into<SpecBaseFactory>(&specs)); } FsRows::~FsRows() @@ -81,7 +81,7 @@ FsRows::execute(const Glib::ustring &, const RowProcessorCallback & rp, ExecCont for (SpecSpec::const_iterator sf = s.begin(); sf != s.end(); ) { const Glib::ustring & name = (*sf++); if (name[0] == '-') { - ss.specs.insert(InstanceMap<SpecBaseLoader, std::string>::Get<NotSupported>(name.substr(1))->createWith(*sf++)); + ss.specs.insert(SpecBaseStringFactory::createNew(name.substr(1), *sf++)); } else { throw NotSupported(name); @@ -237,5 +237,6 @@ FsRows::SearchState::fileType() const throw NotSupported(__PRETTY_FUNCTION__); } -INSTANTIATESTORE(std::string, FsRows::SpecBaseLoader); +INSTANTIATEFACTORY(FsRows::SpecBase, ScriptNodePtr); +INSTANTIATEFACTORY(FsRows::SpecBase, const Glib::ustring &); diff --git a/project2/files/fsRows.h b/project2/files/fsRows.h index 2e44750..897f274 100644 --- a/project2/files/fsRows.h +++ b/project2/files/fsRows.h @@ -8,6 +8,7 @@ #include "rowSet.h" #include "scriptStorage.h" #include "scriptLoader.h" +#include <factory.h> class CommonObjects; @@ -25,22 +26,8 @@ class FsRows : public RowSet { const struct stat & curStat(const SearchState * fs) const; }; typedef boost::intrusive_ptr<SpecBase> SpecBasePtr; - template <class X> - class SpecBaseLoaderX : public GenLoader<SpecBase, std::string, ScriptNodePtr> { - public: - virtual SpecBase * createWith(const Glib::ustring &) const = 0; - template <class T, class BaseLoader = SpecBaseLoaderX<X>> - class For : public BaseLoader { - public: - inline SpecBase * create(const ScriptNodePtr & v) const { - return new T(v); - } - inline SpecBase * createWith(const Glib::ustring & v) const { - return new T(v); - } - }; - }; - typedef SpecBaseLoaderX<void> SpecBaseLoader; + typedef AdHoc::Factory<SpecBase, ScriptNodePtr> SpecBaseFactory; + typedef AdHoc::Factory<SpecBase, const Glib::ustring &> SpecBaseStringFactory; 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 9e3c8ad..87d1223 100644 --- a/project2/files/presenterCache.cpp +++ b/project2/files/presenterCache.cpp @@ -247,7 +247,7 @@ DECLARE_OPTIONS(FilePresenterCache, "File Presenter Cache options") "The name of the component used to provide a unique request ID") END_OPTIONS(FilePresenterCache) -class FilePresenterCacheLoader : public ElementLoader::For<FilePresenterCache> { +class FilePresenterCacheLoader : public ComponentLoader { public: FilePresenterCacheLoader() { @@ -299,4 +299,5 @@ class FilePresenterCacheLoader : public ElementLoader::For<FilePresenterCache> { return files; } }; -DECLARE_CUSTOM_LOADER("filecache", FilePresenterCacheLoader); +NAMEDFACTORY("filecache", FilePresenterCache, PresenterCacheFactory); + diff --git a/project2/files/writeStream.cpp b/project2/files/writeStream.cpp index 9946ec6..485c138 100644 --- a/project2/files/writeStream.cpp +++ b/project2/files/writeStream.cpp @@ -14,7 +14,7 @@ class WriteStream : public Task { Task(s), path(s, "path") { - s->script->loader.addLoadTarget(s, Storer::into<ElementLoader>(&stream)); + s->script->loader.addLoadTarget(s, Storer::into<StreamFactory>(&stream)); } void execute(ExecContext * ec) const @@ -33,5 +33,5 @@ class WriteStream : public Task { StreamPtr stream; }; -DECLARE_LOADER("writestream", WriteStream); +NAMEDFACTORY("writestream", WriteStream, TaskFactory); |