/** \file FormatParserStorage.hpp * * date: Jun, 22 2010 * author: heber * */ #ifndef FORMATPARSERSTORAGE_HPP_ #define FORMATPARSERSTORAGE_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "Patterns/Singleton.hpp" #include #include #include class FormatParser; class MpqcParser; class PdbParser; class PcpParser; class TremoloParser; class XyzParser; // enum has to be outside of class for operator++ to be possible enum ParserTypes { mpqc, pcp, pdb, tremolo, xyz, ParserTypes_end, ParserTypes_begin = mpqc }; typedef enum ParserTypes ParserTypes; ParserTypes &operator++(ParserTypes &type); class FormatParserStorage : public Singleton { friend class Singleton; public: void addMpqc(); void addPcp(); void addPdb(); void addTremolo(); void addXyz(); bool add(std::string type); bool add(ParserTypes type); bool get(std::istream &input, std::string suffix); MpqcParser &getMpqc(); PcpParser &getPcp(); PdbParser &getPdb(); TremoloParser &getTremolo(); XyzParser &getXyz(); ParserTypes getTypeFromName(std::string type); ParserTypes getTypeFromSuffix(std::string type); void SetOutputPrefixForAll(std::string &_prefix); void SaveAll(); private: // private constructors as this is a singleton FormatParserStorage(); ~FormatParserStorage(); // list of allocated parsers std::vector ParserList; // list of allocated strams std::vector ParserStream; // which parser is already present std::vector ParserPresent; // default suffix of each parser type std::map ParserSuffixes; std::map ParserLookupSuffixes; // function pointers to each add...() std::map< ParserTypes, void (FormatParserStorage::*)() > ParserAddFunction; // type name of each parser type and reverse lookup std::map ParserNames; std::map ParserLookupNames; // prefix of the filenames to use on save std::string prefix; }; #endif // FORMATPARSERSTORAGE_HPP_