LOOS  v2.3.2
tinkerxyz.hpp
1 /*
2  This file is part of LOOS.
3 
4  LOOS (Lightweight Object-Oriented Structure library)
5  Copyright (c) 2008, Tod D. Romo, Alan Grossfield
6  Department of Biochemistry and Biophysics
7  School of Medicine & Dentistry, University of Rochester
8 
9  This package (LOOS) is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation under version 3 of the License.
12 
13  This package is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 
23 
24 #if !(defined LOOS_TINKERXYZ_HPP)
25 #define LOOS_TINKERXYZ_HPP
26 
27 #include <ios>
28 #include <fstream>
29 #include <sstream>
30 #include <iostream>
31 
32 #include <stdexcept>
33 
34 #include <loos_defs.hpp>
35 #include <AtomicGroup.hpp>
36 
37 
38 namespace loos {
39 
41 
47  class TinkerXYZ : public AtomicGroup {
48  public:
49  TinkerXYZ() : _max_index(0) { }
50  virtual ~TinkerXYZ() {}
51 
52  explicit TinkerXYZ(const std::string& fname) : _max_index(0), _filename(fname) {
53  std::ifstream ifs(fname.c_str());
54  if (!ifs)
55  throw(FileOpenError(fname));
56  read(ifs);
57  }
58 
59  explicit TinkerXYZ(std::istream &ifs) : _max_index(0), _filename("stream") {
60  read(ifs);
61  }
62 
63 
64  static pAtomicGroup create(const std::string& fname) {
65  return(pAtomicGroup(new TinkerXYZ(fname)));
66  }
67 
69  virtual TinkerXYZ* clone(void) const;
70 
72  TinkerXYZ copy(void) const;
73 
74  void read(std::istream& is);
75 
76 
77  private:
78 
79  TinkerXYZ(const AtomicGroup& grp) : AtomicGroup(grp) { }
80 
81 
82  void parseAtomRecord(const std::string&);
83 
85 
88  bool parseBoxRecord(const std::string& s);
89 
90  uint _max_index;
91  std::string _filename;
92  };
93 
94 
95 }
96 
97 #endif
Error while opening a file.
Definition: exceptions.hpp:170
TinkerXYZ copy(void) const
Creates a deep copy (see AtomicGroup::copy() for more info)
Definition: tinkerxyz.cpp:32
Class for reading a subset of the TinkerXYZ format.
Definition: tinkerxyz.hpp:47
virtual TinkerXYZ * clone(void) const
Clones an object for polymorphism (see AtomicGroup::clone() for more info)
Definition: tinkerxyz.cpp:28
Class for handling groups of Atoms (pAtoms, actually)
Definition: AtomicGroup.hpp:87
Namespace for most things not already encapsulated within a class.