summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-09-26 19:27:50 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-09-26 20:14:19 +0100
commitf8d4460cd0f998f6edf37c0933c5a3438ac452b9 (patch)
tree01ccf4cd8640929db4fb9e9033a7efeddc28a310
parentUse AdHoc plugins for variable implementations (diff)
downloadproject2-f8d4460cd0f998f6edf37c0933c5a3438ac452b9.tar.bz2
project2-f8d4460cd0f998f6edf37c0933c5a3438ac452b9.tar.xz
project2-f8d4460cd0f998f6edf37c0933c5a3438ac452b9.zip
Use AdHoc plugins for decompressors
-rw-r--r--project2/compression/decompressStream.cpp3
-rw-r--r--project2/compression/decompressor.cpp7
-rw-r--r--project2/compression/decompressor.h8
-rw-r--r--project2/compression/gzip.cpp2
-rw-r--r--project2/compression/nocomp.cpp3
5 files changed, 14 insertions, 9 deletions
diff --git a/project2/compression/decompressStream.cpp b/project2/compression/decompressStream.cpp
index c1d52ab..b986a0a 100644
--- a/project2/compression/decompressStream.cpp
+++ b/project2/compression/decompressStream.cpp
@@ -17,7 +17,7 @@ class DecompressStream : public Stream {
void runStream(const Sink & sink, ExecContext * ec) const
{
- DecompressorPtr decomp = DecompressorLoader::getFor(method(ec))->create();
+ DecompressorPtr decomp = DecompressorFactory::createNew(method(ec));
stream->runStream([&](const char * data, size_t len) -> size_t {
decomp->decompress(data, len, sink);
return len;
@@ -29,5 +29,4 @@ class DecompressStream : public Stream {
};
DECLARE_LOADER("decompstream", DecompressStream);
-INSTANTIATESTORE(std::string, DecompressorLoader);
diff --git a/project2/compression/decompressor.cpp b/project2/compression/decompressor.cpp
new file mode 100644
index 0000000..b727aa8
--- /dev/null
+++ b/project2/compression/decompressor.cpp
@@ -0,0 +1,7 @@
+#include "decompressor.h"
+#include <factory.impl.h>
+
+Decompressor::~Decompressor() = default;
+
+INSTANTIATEVOIDFACTORY(Decompressor);
+
diff --git a/project2/compression/decompressor.h b/project2/compression/decompressor.h
index c57ff61..c15fef2 100644
--- a/project2/compression/decompressor.h
+++ b/project2/compression/decompressor.h
@@ -3,15 +3,15 @@
#include "stream.h"
#include "intrusivePtrBase.h"
+#include <factory.h>
class Decompressor : public IntrusivePtrBase {
public:
- virtual ~Decompressor()
- {
- }
+ virtual ~Decompressor();
+
virtual void decompress(const char * dataIn, size_t lengthIn, const Stream::Sink &) = 0;
};
typedef boost::intrusive_ptr<Decompressor> DecompressorPtr;
-typedef GenLoader<Decompressor, std::string> DecompressorLoader;
+typedef AdHoc::Factory<Decompressor> DecompressorFactory;
#endif
diff --git a/project2/compression/gzip.cpp b/project2/compression/gzip.cpp
index 2bf0a8d..653143f 100644
--- a/project2/compression/gzip.cpp
+++ b/project2/compression/gzip.cpp
@@ -49,5 +49,5 @@ class GZip : public Decompressor {
z_stream strm;
int status;
};
-DECLARE_GENERIC_LOADER("gz", DecompressorLoader, GZip);
+NAMEDFACTORY("gz", GZip, DecompressorFactory);
diff --git a/project2/compression/nocomp.cpp b/project2/compression/nocomp.cpp
index 6861171..78f4d4c 100644
--- a/project2/compression/nocomp.cpp
+++ b/project2/compression/nocomp.cpp
@@ -9,6 +9,5 @@ class NoComp : public Decompressor {
sink(data, len);
}
};
-DECLARE_GENERIC_LOADER("nocomp", DecompressorLoader, NoComp);
-
+NAMEDFACTORY("nocomp", NoComp, DecompressorFactory);