OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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, bool bf):
31  dialect(d), strict_hydrogens(sh), quack_mode(qm), fault_tolerant(ft),
32  join_spread_atom_records(js), no_hetatms(nh), calpha_only(co), bond_feasibility_check(bf)
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), bond_feasibility_check(true)
37  { }
38  virtual ~IOProfile() { }
39 
42  bool quack_mode;
45  bool no_hetatms;
48 
49  IOProfile Copy()
50  {
51  return IOProfile(dialect, strict_hydrogens, quack_mode, fault_tolerant,
52  join_spread_atom_records, no_hetatms, calpha_only, bond_feasibility_check);
53  }
54  virtual void PostImport(mol::EntityHandle ent) { }
55 };
56 
57 inline std::ostream& operator<<(std::ostream& stream, const IOProfile& p)
58 {
59  stream << "IOProfile(dialect='" << p.dialect << "', strict_hydrogens="
60  << (p.strict_hydrogens ? "True" : "False") << ", quack_mode="
61  << (p.quack_mode ? "True" : "False") << ", join_spread_atom_records="
62  << (p.join_spread_atom_records ? "True" : "False") << ", no_hetatms="
63  << (p.no_hetatms ? "True" : "False") << ", calpha_only="
64  << (p.calpha_only ? "True" : "False") << ", fault_tolerant="
65  << (p.fault_tolerant ? "True" : "False") << ", bond_feasibility_check="
66  << (p.bond_feasibility_check ? "True" : "False") << ")";
67  return stream;
68 }
69 
71 public:
72  static IOProfileRegistry& Instance();
73 
74  IOProfile& Get(const String& key)
75  {
76  return profiles_[key];
77  }
78 
79  void Set(const String& key, const IOProfile& profile)
80  {
81  profiles_[key]=profile;
82  }
83 
84  IOProfile& GetDefault() { return profiles_["DEFAULT"]; }
85 private:
87  std::map<String, IOProfile> profiles_;
88 };
89 
90 }}
91 
92 #endif