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-2020 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 #include <ost/conop/processor.hh>
27 
28 namespace ost { namespace io {
29 
30 
31 struct DLLEXPORT IOProfile {
32 public:
33  IOProfile(String d, bool ft, bool js, bool nh,
34  bool co, bool rc, conop::ProcessorPtr proc=conop::ProcessorPtr()):
35  dialect(d), fault_tolerant(ft), join_spread_atom_records(js),
36  no_hetatms(nh), calpha_only(co), read_conect(rc), processor(proc)
37  {
38  }
39 
40  IOProfile(): dialect("PDB"), fault_tolerant(false),
41  join_spread_atom_records(false), no_hetatms(false),
42  calpha_only(false), read_conect(false), processor()
43  { }
44 
45  String dialect;
46  bool fault_tolerant;
47  bool join_spread_atom_records;
48  bool no_hetatms;
49  bool calpha_only;
50  bool read_conect;
53  {
54  return IOProfile(dialect, fault_tolerant, join_spread_atom_records,
55  no_hetatms, calpha_only, read_conect,
57  }
58 };
59 
60 
61 inline std::ostream& operator<<(std::ostream& stream, const IOProfile& p)
62 {
63  stream << "IOProfile(dialect='" << p.dialect << ", "
64  << "join_spread_atom_records=" << (p.join_spread_atom_records ? "True" : "False") << ", "
65  << "calpha_only=" << (p.calpha_only ? "True" : "False") << ", "
66  << "fault_tolerant=" << (p.fault_tolerant ? "True" : "False") << ", "
67  << "no_hetatms=" << (p.no_hetatms ? "True" : "False") << ", "
68  << "read_conect=" << (p.read_conect ? "True" : "False") << ", "
69  << "processor=" << (p.processor ? p.processor->ToString() : "None") << ")";
70  return stream;
71 }
72 
73 class DLLEXPORT_OST_IO IOProfileRegistry {
74 public:
76 
77  IOProfile& Get(const String& key)
78  {
79  return profiles_[key];
80  }
81 
82  void Set(const String& key, const IOProfile& profile)
83  {
84  profiles_[key]=profile;
85  }
86 
87  IOProfile& GetDefault() { return profiles_["DEFAULT"]; }
88  static void RemoveProfiles() {
89  if (IOProfileRegistry::alive) {
90  IOProfileRegistry::Instance().profiles_.clear();
91  }
92  }
94  alive = false;
95  }
96 private:
98  std::map<String, IOProfile> profiles_;
99  static bool alive;
100 };
101 
102 }}
103 
104 #endif
static void RemoveProfiles()
Definition: io_profile.hh:88
IOProfile & Get(const String &key)
Definition: io_profile.hh:77
IOProfile & GetDefault()
Definition: io_profile.hh:87
static IOProfileRegistry & Instance()
void Set(const String &key, const IOProfile &profile)
Definition: io_profile.hh:82
#define DLLEXPORT_OST_IO
std::string String
Definition: base.hh:54
boost::shared_ptr< Processor > ProcessorPtr
Definition: processor.hh:42
std::ostream & operator<<(std::ostream &stream, const FormattedLine &line)
Definition: base.dox:1
IOProfile(String d, bool ft, bool js, bool nh, bool co, bool rc, conop::ProcessorPtr proc=conop::ProcessorPtr())
Definition: io_profile.hh:33
IOProfile Copy()
Definition: io_profile.hh:52