source: src/Parser/PdbAtomInfoContainer.hpp@ 440ac3

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 440ac3 was 765f16, checked in by Frederik Heber <heber@…>, 13 years ago

Huge Refactoring of FormatParserStorage and all FormatParser's.

FormatParser:

FormatParserStorage:

  • We construct all lookup tables and alikes via boost preprocessor magic from a list of all available parser (enums).
  • we use the templated getParser() and addParser() functions to serve parsers to the outside. Instances are as usual created only once.

Tests:

  • tests only had to be changed because of the "renaming" of the Parsers.
  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 * PdbAtomInfoContainer.hpp
3 *
4 * Created on: Dec 4, 2010
5 * Author: heber
6 */
7
8#ifndef PDBATOMINFOCONTAINER_HPP_
9#define PDBATOMINFOCONTAINER_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <string>
17#include <typeinfo>
18
19#include "LinearAlgebra/Vector.hpp"
20#include "PdbKey.hpp"
21
22#include "ParserTypes.hpp"
23
24//template <class T> class FormatParser;
25//template<> class FormatParser< pdb >;
26
27/**
28 * Holds tremolo-specific information which is not store in the atom class.
29 */
30class PdbAtomInfoContainer {
31 //!> Grant all FormatParser specializations access, otherwise we have to fully define FormatParser<pdb>
32 template<enum ParserTypes> friend class FormatParser;
33public:
34 PdbAtomInfoContainer();
35 ~PdbAtomInfoContainer();
36
37 // getter and setter
38 template <class T> T get(const PdbKey::PdbDataKey key) const {
39 switch (key) {
40 default :
41 std::cout << "Unknown key or not representable as " << typeid(T).name() << ": " << key << std::endl;
42 break;
43 }
44 return (T)NULL;
45 }
46 void set(const PdbKey::PdbDataKey key, std::string value);
47
48 /** Scans a value from a short string and checks whether its empty.
49 *
50 * @param value value to set
51 * @param _piece short string
52 */
53 template <class T> static void ScanKey(T& value, std::string _piece)
54 {
55 ConvertTo<T> toValue;
56 // scan all empty chars ' ' and skip
57 std::string::iterator iter = _piece.begin();
58 for (;iter != _piece.end();++iter)
59 if ((*iter != ' ') && (*iter != '\t'))
60 break;
61 // only set if there is something contained in the string
62 if (iter != _piece.end()) {
63 _piece.erase(_piece.begin(), iter);
64 value = toValue(_piece);
65 }
66 }
67
68 const std::string& getDataKey(PdbKey::PdbDataKey key) const;
69
70private:
71
72 static void fillknownDataKeys();
73 static void clearknownDataKeys();
74
75 typedef std::map<PdbKey::PdbDataKey, std::string> knownDataKeysMap;
76 static knownDataKeysMap knownDataKeys;
77 static bool knownDataKeys_Filled;
78
79 std::string token;
80 int serial;
81 std::string name;
82 char altLoc;
83 std::string resName;
84 char chainID;
85 int resSeq;
86 char iCode;
87 Vector XYZ;
88 float occupancy;
89 float tempFactor;
90 std::string element;
91 int charge;
92};
93
94std::ostream& operator<<(std::ostream &ost, const PdbAtomInfoContainer& m);
95
96template <>
97std::string PdbAtomInfoContainer::get<std::string>(const PdbKey::PdbDataKey key) const;
98template <>
99int PdbAtomInfoContainer::get<int>(const PdbKey::PdbDataKey key) const;
100template <>
101double PdbAtomInfoContainer::get<double>(const PdbKey::PdbDataKey key) const;
102
103#endif /* PDBATOMINFOCONTAINER_HPP_ */
Note: See TracBrowser for help on using the repository browser.