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