[52baf9] | 1 | /** \file FormatParserStorage.hpp
|
---|
| 2 | *
|
---|
| 3 | * date: Jun, 22 2010
|
---|
| 4 | * author: heber
|
---|
| 5 | *
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef FORMATPARSERSTORAGE_HPP_
|
---|
| 9 | #define FORMATPARSERSTORAGE_HPP_
|
---|
| 10 |
|
---|
| 11 | // include config.h
|
---|
| 12 | #ifdef HAVE_CONFIG_H
|
---|
| 13 | #include <config.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | #include "Patterns/Singleton.hpp"
|
---|
| 17 |
|
---|
| 18 | #include <string>
|
---|
[5c6946] | 19 | #include <map>
|
---|
[52baf9] | 20 | #include <vector>
|
---|
| 21 |
|
---|
| 22 | class FormatParser;
|
---|
[dc0d21] | 23 | class MpqcParser;
|
---|
[bb6193] | 24 | class PdbParser;
|
---|
[dc0d21] | 25 | class PcpParser;
|
---|
| 26 | class TremoloParser;
|
---|
| 27 | class XyzParser;
|
---|
[52baf9] | 28 |
|
---|
| 29 | // enum has to be outside of class for operator++ to be possible
|
---|
[bb6193] | 30 | enum ParserTypes { mpqc, pcp, pdb, tremolo, xyz, ParserTypes_end, ParserTypes_begin = mpqc };
|
---|
[52baf9] | 31 | typedef enum ParserTypes ParserTypes;
|
---|
| 32 |
|
---|
[dc0d21] | 33 | ParserTypes &operator++(ParserTypes &type);
|
---|
[52baf9] | 34 |
|
---|
| 35 | class FormatParserStorage : public Singleton<FormatParserStorage> {
|
---|
| 36 | friend class Singleton<FormatParserStorage>;
|
---|
| 37 | public:
|
---|
| 38 |
|
---|
[dc0d21] | 39 | void addMpqc();
|
---|
| 40 | void addPcp();
|
---|
[bb6193] | 41 | void addPdb();
|
---|
[dc0d21] | 42 | void addTremolo();
|
---|
| 43 | void addXyz();
|
---|
[5c6946] | 44 | bool add(std::string type);
|
---|
| 45 | bool add(ParserTypes type);
|
---|
[dc0d21] | 46 |
|
---|
[86cff86] | 47 | bool get(std::istream &input, std::string suffix);
|
---|
[dc0d21] | 48 | MpqcParser &getMpqc();
|
---|
| 49 | PcpParser &getPcp();
|
---|
[bb6193] | 50 | PdbParser &getPdb();
|
---|
[dc0d21] | 51 | TremoloParser &getTremolo();
|
---|
| 52 | XyzParser &getXyz();
|
---|
[52baf9] | 53 |
|
---|
[a42054] | 54 | ParserTypes getTypeFromName(std::string type);
|
---|
| 55 | ParserTypes getTypeFromSuffix(std::string type);
|
---|
[5c6946] | 56 |
|
---|
[52baf9] | 57 | void SetOutputPrefixForAll(std::string &_prefix);
|
---|
| 58 | void SaveAll();
|
---|
| 59 |
|
---|
| 60 | private:
|
---|
| 61 | // private constructors as this is a singleton
|
---|
| 62 | FormatParserStorage();
|
---|
| 63 | ~FormatParserStorage();
|
---|
| 64 |
|
---|
| 65 | // list of allocated parsers
|
---|
| 66 | std::vector<FormatParser *> ParserList;
|
---|
| 67 |
|
---|
[60239f] | 68 | // list of allocated strams
|
---|
| 69 | std::vector<std::ofstream *> ParserStream;
|
---|
| 70 |
|
---|
[52baf9] | 71 | // which parser is already present
|
---|
| 72 | std::vector<bool> ParserPresent;
|
---|
| 73 |
|
---|
| 74 | // default suffix of each parser type
|
---|
[a42054] | 75 | std::map<ParserTypes, std::string> ParserSuffixes;
|
---|
| 76 | std::map<std::string, ParserTypes> ParserLookupSuffixes;
|
---|
[52baf9] | 77 |
|
---|
[5c6946] | 78 | // function pointers to each add...()
|
---|
| 79 | std::map< ParserTypes, void (FormatParserStorage::*)() > ParserAddFunction;
|
---|
| 80 |
|
---|
| 81 | // type name of each parser type and reverse lookup
|
---|
| 82 | std::map<ParserTypes, std::string> ParserNames;
|
---|
| 83 | std::map<std::string, ParserTypes> ParserLookupNames;
|
---|
| 84 |
|
---|
| 85 |
|
---|
[52baf9] | 86 | // prefix of the filenames to use on save
|
---|
| 87 | std::string prefix;
|
---|
| 88 | };
|
---|
| 89 |
|
---|
| 90 | #endif // FORMATPARSERSTORAGE_HPP_
|
---|