feature_maker.h 1.17 KB
#ifndef FEATURE_MAKER
#define FEATURE_MAKER

#include <vector>
#include <thread>
#include <functional>
#include <iostream>

#include "feature_callable.h"
#include "multithread/worker_callable_pool.h"
#include "Importer/entry.h"
#include "constant.h"
#include "feature.h"
#include "data/storage_worker.h"

namespace feature {
	class Feature_maker{

		protected:
			std::thread t;
			std::string id;
			data::Data_Store *storage;
			data::Storage_worker *storage_worker;
			multithread::Worker_callable_pool<data::Data_basic*,data::Data_basic*> pool;

		public:
			Feature_maker(feature::Feature_callable *c,
										multithread::Buffer<data::Data_basic*> *in,
										data::Data_Store *out,
										std::string id):
				id(id),
				storage(out),
				pool(c,in,storage_worker = new data::Storage_worker(out)){
				this->storage_worker->start();
				this->pool.start();
			}

			virtual ~Feature_maker(){
				this->join();
				delete this->storage_worker;
			}

			void join(){
				this->pool.join();
				this->storage_worker->join();
			}

			std::string getId() const{
				return this->id;
			}

			data::Data_Store* getStorage(){
				return this->storage;
			}

	};
}

#endif // FEATURE_MAKER