OpenStructure
io_profile.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_IO_IO_PROFILE_HH
20 #define OST_IO_IO_PROFILE_HH
21 
22 #include <iostream>
23 #include <map>
24 #include <ost/mol/entity_handle.hh>
25 #include <ost/io/module_config.hh>
26 namespace ost { namespace io {
27 
28 struct DLLEXPORT IOProfile {
29 public:
30  IOProfile(String d, bool sh, bool qm, bool ft, bool js, bool nh, bool co):
31  dialect(d), strict_hydrogens(sh), quack_mode(qm), fault_tolerant(ft),
32  join_spread_atom_records(js), no_hetatms(nh), calpha_only(co)
33  { }
34  IOProfile(): dialect("PDB"), strict_hydrogens(true), quack_mode(false),
35  fault_tolerant(false), join_spread_atom_records(false), no_hetatms(false),
36  calpha_only(false)
37  { }
38  virtual ~IOProfile() { }
39 
40  String dialect;
41  bool strict_hydrogens;
42  bool quack_mode;
43  bool fault_tolerant;
44  bool join_spread_atom_records;
45  bool no_hetatms;
46  bool calpha_only;
47 
48  IOProfile Copy()
49  {
50  return IOProfile(dialect, strict_hydrogens, quack_mode, fault_tolerant,
51  join_spread_atom_records, no_hetatms, calpha_only);
52  }
53  virtual void PostImport(mol::EntityHandle ent) { }
54 };
55 
56 inline std::ostream& operator<<(std::ostream& stream, const IOProfile& p)
57 {
58  stream << "IOProfile(dialect='" << p.dialect << "', strict_hydrogens="
59  << (p.strict_hydrogens ? "True" : "False") << ", quack_mode="
60  << (p.quack_mode ? "True" : "False") << ", join_spread_atom_records="
61  << (p.join_spread_atom_records ? "True" : "False") << ", no_hetatms="
62  << (p.no_hetatms ? "True" : "False") << ", calpha_only="
63  << (p.calpha_only ? "True" : "False") << ", fault_tolerant="
64  << (p.fault_tolerant ? "True" : "False") << ")";
65  return stream;
66 }
67 
68 class DLLEXPORT_OST_IO IOProfileRegistry {
69 public:
70  static IOProfileRegistry& Instance();
71 
72  IOProfile& Get(const String& key)
73  {
74  return profiles_[key];
75  }
76 
77  void Set(const String& key, const IOProfile& profile)
78  {
79  profiles_[key]=profile;
80  }
81 
82  IOProfile& GetDefault() { return profiles_["DEFAULT"]; }
83 private:
85  std::map<String, IOProfile> profiles_;
86 };
87 
88 }}
89 
90 #endif