| [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);
 | 
|---|
| [cabb46] | 48 |   bool put(std::ostream &output, std::string suffix);
 | 
|---|
| [dc0d21] | 49 |   MpqcParser &getMpqc();
 | 
|---|
 | 50 |   PcpParser &getPcp();
 | 
|---|
| [bb6193] | 51 |   PdbParser &getPdb();
 | 
|---|
| [dc0d21] | 52 |   TremoloParser &getTremolo();
 | 
|---|
 | 53 |   XyzParser &getXyz();
 | 
|---|
| [52baf9] | 54 | 
 | 
|---|
| [a42054] | 55 |   ParserTypes getTypeFromName(std::string type);
 | 
|---|
 | 56 |   ParserTypes getTypeFromSuffix(std::string type);
 | 
|---|
| [5c6946] | 57 | 
 | 
|---|
| [52baf9] | 58 |   void SetOutputPrefixForAll(std::string &_prefix);
 | 
|---|
 | 59 |   void SaveAll();
 | 
|---|
 | 60 | 
 | 
|---|
 | 61 | private:
 | 
|---|
 | 62 |   // private constructors as this is a singleton
 | 
|---|
 | 63 |   FormatParserStorage();
 | 
|---|
 | 64 |   ~FormatParserStorage();
 | 
|---|
 | 65 |   
 | 
|---|
 | 66 |   // list of allocated parsers
 | 
|---|
 | 67 |   std::vector<FormatParser *> ParserList;
 | 
|---|
 | 68 | 
 | 
|---|
| [60239f] | 69 |   // list of allocated strams
 | 
|---|
 | 70 |   std::vector<std::ofstream *> ParserStream;
 | 
|---|
 | 71 | 
 | 
|---|
| [52baf9] | 72 |   // which parser is already present
 | 
|---|
 | 73 |   std::vector<bool> ParserPresent;
 | 
|---|
 | 74 | 
 | 
|---|
 | 75 |   // default suffix of each parser type
 | 
|---|
| [a42054] | 76 |   std::map<ParserTypes, std::string> ParserSuffixes;
 | 
|---|
 | 77 |   std::map<std::string, ParserTypes> ParserLookupSuffixes;
 | 
|---|
| [52baf9] | 78 | 
 | 
|---|
| [5c6946] | 79 |   // function pointers to each add...()
 | 
|---|
 | 80 |   std::map< ParserTypes, void (FormatParserStorage::*)() > ParserAddFunction;
 | 
|---|
 | 81 | 
 | 
|---|
 | 82 |   // type name of each parser type and reverse lookup
 | 
|---|
 | 83 |   std::map<ParserTypes, std::string> ParserNames;
 | 
|---|
 | 84 |   std::map<std::string, ParserTypes> ParserLookupNames;
 | 
|---|
 | 85 | 
 | 
|---|
 | 86 | 
 | 
|---|
| [52baf9] | 87 |   // prefix of the filenames to use on save
 | 
|---|
 | 88 |   std::string prefix;
 | 
|---|
 | 89 | };
 | 
|---|
 | 90 | 
 | 
|---|
 | 91 | #endif // FORMATPARSERSTORAGE_HPP_
 | 
|---|