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 #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,
35  dialect(d), quack_mode(qm), fault_tolerant(ft), join_spread_atom_records(js),
36  no_hetatms(nh), calpha_only(co), 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), processor()
43  { }
44 
45  String dialect;
46  bool quack_mode;
47  bool fault_tolerant;
48  bool join_spread_atom_records;
49  bool no_hetatms;
50  bool calpha_only;
53  {
54  return IOProfile(dialect, quack_mode, fault_tolerant, join_spread_atom_records,
55  no_hetatms, calpha_only,
57  }
58 };
59 
60 
61 inline std::ostream& operator<<(std::ostream& stream, const IOProfile& p)
62 {
63  stream << "IOProfile(dialect='" << p.dialect
64  << "', quack_mode=" << (p.quack_mode ? "True" : "False") << ", "
65  << "join_spread_atom_records=" << (p.join_spread_atom_records ? "True" : "False") << ", "
66  << "calpha_only=" << (p.calpha_only ? "True" : "False") << ", "
67  << "fault_tolerant=" << (p.fault_tolerant ? "True" : "False") << ", "
68  << "no_hetatms=" << (p.no_hetatms ? "True" : "False") << ", "
69  << "processor=" << (p.processor ? p.processor->ToString() : "None") << ")";
70  return stream;
71 }
72 
73 class DLLEXPORT_OST_IO IOProfileRegistry {
74 public:
75  static IOProfileRegistry& Instance();
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
std::string String
Definition: base.hh:54
tuple processor
Definition: __init__.py:48
IOProfile & GetDefault()
Definition: io_profile.hh:87
IOProfile Copy()
Definition: io_profile.hh:52
boost::shared_ptr< Processor > ProcessorPtr
Definition: processor.hh:42
static void RemoveProfiles()
Definition: io_profile.hh:88
void Set(const String &key, const IOProfile &profile)
Definition: io_profile.hh:82
#define DLLEXPORT_OST_IO
tuple quack_mode
Definition: __init__.py:52
IOProfile(String d, bool qm, bool ft, bool js, bool nh, bool co, conop::ProcessorPtr proc=conop::ProcessorPtr())
Definition: io_profile.hh:33
IOProfile & Get(const String &key)
Definition: io_profile.hh:77
std::ostream & operator<<(std::ostream &stream, const FormattedLine &line)
static IOProfileRegistry & Instance()