// DatasetMergeResult.h #ifndef dset__DatasetMergeResult_H #define dset__DatasetMergeResult_H // David Adams // April 2004 // // This class holds the reult of a dataset merge. // // None of the datasets are managed here. #include #include #include #include "dataset_base/Dataset.h" class XmlElement; namespace dset { class DatasetMergeResult { private: // data bool m_valid; int m_err; DatasetList m_input_dsts; DatasetList m_merged_dsts; DatasetList m_rejected_dsts; const Dataset* m_pdst; public: // Constructors and destructor. // Constructor for invalid state. explicit DatasetMergeResult(int err =0); // Constructor for a valid result. DatasetMergeResult(const DatasetList& input_dsts, const DatasetList& merged_datasets, const DatasetList& rejected_datasets, const Dataset* pdst); public: // Const methods // Validity. bool is_valid() const { return m_valid; } // Error code for invalid result. int error() const { return m_err; } // Is up to date. bool is_up_to_date() const { return merged_datasets().size() == input_datasets().size(); } // Return the list of input datasets. // Does not include those rejected by append(...). const DatasetList& input_datasets() const { return m_input_dsts; } // Return the list of datasets included in the last call to dataset(). const DatasetList& merged_datasets() const { return m_merged_dsts; } // Return the list of datasets rejected after their append(...). const DatasetList& rejected_datasets() const { return m_rejected_dsts; } // Return the merged dataset. // This dataset should not change and should not be deleted // until the next call to update(). After that, all bets are off. // It is not required that all input datasets be merged; instead // this corresponds to the list of merged datasets. const Dataset* dataset() const { return m_pdst; } }; } // end namespace dset // Free functions. std::ostream& operator<<(std::ostream& lhs, const dset::DatasetMergeResult& rhs); // Equality. bool operator==(const dset::DatasetMergeResult& lhs, const dset::DatasetMergeResult& rhs); // Inequality. bool operator!=(const dset::DatasetMergeResult& lhs, const dset::DatasetMergeResult& rhs); #endif