// CompoundDatasetMerger.h #ifndef dset__CompoundDatasetMerger_H #define dset__CompoundDatasetMerger_H // David Adams // February 2005. // // This dataset merger takes a simple compound dataset as input, // splits it into sub-datasets by content label, separately // merges each sub-dataset and then combines the results back into // a simple compound dataset. // // If the input is any other kind of dataset, then it behaves like // a DefaultDatasetMerger. // // All compound datasets returned as results are stored in // the current default dataset repository. // // The merger manages the datasets it returns in its result. // A call to result deletes the dataset returned in the // previous call if it has changed. #include #include "dataset_util/Text.h" #include "dataset_split/DatasetMerger.h" #include "dataset_split/DefaultDatasetMerger.h" namespace dset { class Dataset; class CompoundDatasetMerger : public DatasetMerger { private: // typedefs typedef std::vector MergerList; private: // data std::string m_dir; int m_err; DatasetList m_dsts; DefaultDatasetMerger* m_pmrg; Dataset* m_pdst; MergerList m_mrgs; DatasetMergeResult* m_pres; bool m_open; bool m_update_result; private: // No copy or assignment // Copy. CompoundDatasetMerger(const CompoundDatasetMerger& rhs); // Assignment. CompoundDatasetMerger& operator=(const CompoundDatasetMerger& rhs); public: // constructors and destructor. // Constructor. // Argument is the working directory. CompoundDatasetMerger(std::string dir); // Destructor. ~CompoundDatasetMerger(); public: // inherited functions // Validity. bool is_valid() const; // Open. bool is_open() const; // Append a dataset. int append(const Dataset& dst); // Return the result. // This should not be blocking--if the result will require a long // time to calculate, then this method should quickly return a // (consistent) partial result. DatasetMergeResult result(); // Close. int close(); // Output stream. std::ostream& ostr(std::ostream& str) const; public: // local functions // Set error and return error code. int set_error(int err); // Return the error code. int error() const; }; } // end namespace dset #endif