+ GeneralFiller ( std::shared_ptr parFill, std::shared_ptr... parFillList );
+ virtual ~GeneralFiller ( void ) noexcept;
+
+ private:
+ virtual void on_data_fill ( void ) override;
+ virtual T& on_data_get ( void ) override;
+
+ std::vector m_to_fill;
+ };
+
+ template
+ template
+ GeneralFiller::GeneralFiller (std::shared_ptr parFill, std::shared_ptr... parFillList) :
+ m_to_fill { std::move(parFill), std::move(parFillList)... }
+ {
+ }
+
+ template
+ GeneralFiller::~GeneralFiller() noexcept {
+ m_to_fill.clear();
+ }
+
+ template
+ void GeneralFiller::on_data_fill() {
+ for (auto& itm : m_to_fill) {
+ itm->get_or_create();
+ }
+ }
+
+ template
+ T& GeneralFiller::on_data_get() {
+ assert(not m_to_fill.empty());
+ return m_to_fill.front()->get_or_create();
+ }
+ } //namespace scantask
+} //namespace mchlib
+
+#endif
diff --git a/include/dindexer-machinery/scantask/mime.hpp b/include/dindexer-machinery/scantask/mime.hpp
index bb4bd7a..1bccde7 100644
--- a/include/dindexer-machinery/scantask/mime.hpp
+++ b/include/dindexer-machinery/scantask/mime.hpp
@@ -34,7 +34,6 @@ namespace mchlib {
explicit Mime ( DirTreeTaskPtr parDirTree );
virtual ~Mime ( void ) noexcept;
-
private:
virtual void on_data_fill ( void ) override;
virtual std::vector& on_data_get ( void ) override;
diff --git a/src/scan/main.cpp b/src/scan/main.cpp
index e90aafc..4a53468 100644
--- a/src/scan/main.cpp
+++ b/src/scan/main.cpp
@@ -31,6 +31,7 @@
#include "dindexer-machinery/scantask/hashing.hpp"
#include "dindexer-machinery/scantask/contenttype.hpp"
#include "dindexer-machinery/scantask/mime.hpp"
+#include "dindexer-machinery/scantask/generalfiller.hpp"
#include
#include
#include
@@ -52,6 +53,7 @@ int main (int parArgc, char* parArgv[]) {
using std::placeholders::_1;
using std::placeholders::_2;
using boost::program_options::variables_map;
+ using FileRecordDataFiller = mchlib::scantask::GeneralFiller;
variables_map vm;
try {
@@ -84,11 +86,11 @@ int main (int parArgc, char* parArgv[]) {
std::shared_ptr hashing(new mchlib::scantask::Hashing(scan_dirtree, true));
std::shared_ptr content_type(new mchlib::scantask::ContentType(scan_dirtree, media_type));
std::shared_ptr mime(new mchlib::scantask::Mime(scan_dirtree));
+ std::shared_ptr filerecdata(new FileRecordDataFiller(mime, hashing));
std::cout << "Content type: " << mchlib::content_type_to_char(content_type->get_or_create()) << std::endl;
- mime->get_or_create();
- const auto& hashes = hashing->get_or_create();
+ const auto& hashes = filerecdata->get_or_create();
for (const auto& hash : hashes) {
std::cout << '"' << hash.path << "\" -> " << mchlib::tiger_to_string(hash.hash) << " mime: " << hash.mime_type << "\n";
}