// DatasetCreator.h #ifndef DatasetCreator_H #define DatasetCreator_H // David Adams // July 2002 // // Class which creates datasets from XML elements. // The dataset subclass must be registered before datasets of that // type are produced. #include #include #include #include "dataset_util/Text.h" class XmlElement; namespace dset { class Dataset; class DatasetRepository; class DatasetCreator { public: // typedefs // Pointer to a function which creates a dataset from an XML element // and a database to resolve dataset references. typedef const Dataset* (*FunPtr) (const XmlElement&, DatasetRepository*); // List of class names. typedef std::vector NameList; public: // static functions // Register a class. // The function pointed to by pfun will called when the an element // with name name is encountered. // Returns nonzero for error (e.g. same name already used for a // differenct function). static int insert(std::string name, FunPtr pfun); // Create a dataset using the appropriate function. // First tries the attribute "fulltype" and then the element name. // Caller is responsible for managing (deleting) the dataset. // Returns 0 if the element has an unknown name. static const Dataset* create(const XmlElement& ele, DatasetRepository* prep =0); // Return the list of names for which functions have been registered. static NameList names(); // Return if a specified name is registered. static bool has(std::string name); // Display the names for which functions have been registered. static void display(std::ostream& lhs); }; } // end namespace dset #endif