// Location.h #ifndef dset__Location_H #define dset__Location_H // David Adams // July 2003 // // Class to describe the location of a dataset. For now this is // just a collection of file URL's. In the future the contents // of this class might be extended or it might be abstracted to // support extensions. // // XML representation: // // Location // Url // url=guid:123 // Url // url=guid:456 // ... #include #include #include "dataset_util/Text.h" #include "dataset_util/XmlElement.h" #include "dataset_file/Url.h" class XmlElement; namespace dset { class Location { public: // typedefs typedef std::vector UrlList; private: // data // Error status. int m_error; // List of URL's UrlList m_files; public: // static functions // XML name. static const char* xml_name() { return "Location"; } // DTD. static const Text& dtd(); public: // const functions // Constructor for empty or invalid location. // Invalid if error is nonzero. explicit Location(int error =0); // Constructor from XML. explicit Location(const XmlElement& ele); // Validity. // Valid if error status is zero. bool is_valid() const; // Error status. int error() const; // Is the location empty? // I.e. is valid and holds no files. bool is_empty() const; // Return the const list of files. const UrlList& files() const; // Return the mutable list of files. UrlList& files(); // Size of managed memory in bytes. size_t memsize() const; // XML representation. const XmlElement* xml() const; // Output stream. std::ostream& ostr(std::ostream& lhs, std::string indent, std::string label="Location") const; public: // non-const functions // Add another location. // Result is a combined list of files without duplicates. // Returns 0 for success. int add(const Location& loc); }; // Equality. // Must have the same files in the same order. bool operator==(const Location& lhs, const Location& rhs); // Inequality. bool operator!=(const Location& lhs, const Location& rhs); }; // end namespace dset // Output stream. std::ostream& operator<<(std::ostream& lhs, dset::Location rhs); #endif