OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
entity_io_handler.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_ENTITY_IO_PLUGIN_H
20 #define OST_IO_ENTITY_IO_PLUGIN_H
21 
22 #include <boost/shared_ptr.hpp>
23 #include <boost/filesystem/operations.hpp>
24 
25 
26 #include <ost/io/module_config.hh>
27 #include <ost/io/io_utils.hh>
28 
29 namespace ost {
30 
31 namespace mol {
32 
33 class EntityView;
34 class EntityHandle;
35 
36 }
37 
38 namespace io {
39 
42 public:
43  virtual ~EntityIOHandler() {}
44 
45  // import data from file into provided entity handle
46  /*
47  the handler is expected to convert atom names to IUPAC standard
48  */
49  virtual void Import(mol::EntityHandle& ent,
50  const boost::filesystem::path& loc)=0;
51  // export data from entity view to provided file
52  virtual void Export(const mol::EntityView& ent,
53  const boost::filesystem::path& loc) const = 0;
54  // import data from provided stream
55  virtual void Import(mol::EntityHandle& ent,
56  std::istream& stream)=0;
57  // export data from entity view to provided stream
58  virtual void Export(const mol::EntityView& ent,
59  std::ostream& stream) const=0;
60  virtual bool RequiresProcessor() const=0;
61 };
62 
63 typedef boost::shared_ptr<EntityIOHandler> EntityIOHandlerP;
64 
65 
68 public:
70  virtual bool ProvidesImport(const boost::filesystem::path& loc, const String& type) const = 0;
71  virtual bool ProvidesExport(const boost::filesystem::path& loc, const String& type) const = 0;
72  virtual EntityIOHandlerP Create() const = 0;
73  virtual String GetFormatName() const =0;
74  virtual String GetFormatDescription() const =0;
75 };
76 
77 typedef boost::shared_ptr<EntityIOHandlerFactoryBase> EntityIOHandlerFactoryBaseP;
78 
79 template <class HANDLER>
81 {
82  virtual bool ProvidesImport(const boost::filesystem::path& loc, const String& type) const {
83  return HANDLER::ProvidesImport(loc,type);
84  }
85 
86  virtual bool ProvidesExport(const boost::filesystem::path& loc, const String& type) const {
87  return HANDLER::ProvidesExport(loc,type);
88  }
89 
90  virtual String GetFormatName() const {
91  return HANDLER::GetFormatName();
92  }
93 
94  virtual String GetFormatDescription() const {
95  return HANDLER::GetFormatDescription();
96  }
97 
98  virtual EntityIOHandlerP Create() const {
99  return EntityIOHandlerP(new HANDLER);
100  }
101 };
102 
103 
104 
105 }} // ns
106 
107 #endif
boost::shared_ptr< EntityIOHandler > EntityIOHandlerP
std::string String
Definition: base.hh:54
pure abstract base class for creation of a specfic entity io handle
Protein or molecule.
boost::shared_ptr< EntityIOHandlerFactoryBase > EntityIOHandlerFactoryBaseP
#define DLLEXPORT_OST_IO
definition of EntityView
Definition: entity_view.hh:86
pure abstract base class for entity io handlers