OpenStructure
surface_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_SURFACE_IO_PLUGIN_H
20 #define OST_IO_SURFACE_IO_PLUGIN_H
21 
22 #include <boost/shared_ptr.hpp>
23 #include <boost/filesystem/operations.hpp>
24 #include <ost/io/module_config.hh>
25 #include <ost/mol/surface.hh>
26 
27 namespace ost { namespace io {
28 
29 class DLLEXPORT_OST_IO SurfaceIOHandler {
30 public:
31  virtual ~SurfaceIOHandler() {}
32  virtual void Import(mol::SurfaceHandle& surf, const boost::filesystem::path& loc) = 0;
33  virtual void Export(const mol::SurfaceHandle& ent, const boost::filesystem::path& loc) const = 0;
34 };
35 
36 typedef boost::shared_ptr<SurfaceIOHandler> SurfaceIOHandlerPtr;
37 
39 public:
41  virtual bool ProvidesImport(const boost::filesystem::path& loc, const String& type) const = 0;
42  virtual bool ProvidesExport(const boost::filesystem::path& loc, const String& type) const = 0;
43  virtual SurfaceIOHandlerPtr Create() const = 0;
44  virtual String GetFormatName() const =0;
45  virtual String GetFormatDescription() const =0;
46 };
47 
48 typedef boost::shared_ptr<SurfaceIOHandlerFactoryBase> SurfaceIOHandlerFactoryBasePtr;
49 
50 template <class HANDLER>
52 {
53  virtual bool ProvidesImport(const boost::filesystem::path& loc, const String& type) const {
54  return HANDLER::ProvidesImport(loc,type);
55  }
56 
57  virtual bool ProvidesExport(const boost::filesystem::path& loc, const String& type) const {
58  return HANDLER::ProvidesExport(loc,type);
59  }
60 
61  virtual SurfaceIOHandlerPtr Create() const {
62  return SurfaceIOHandlerPtr(new HANDLER);
63  }
64 
65  virtual String GetFormatName() const {
66  return HANDLER::GetFormatName();
67  }
68 
69  virtual String GetFormatDescription() const {
70  return HANDLER::GetFormatDescription();
71  }
72 
73 };
74 
75 
76 }} // ns
77 
78 #endif
virtual String GetFormatDescription() const =0
virtual bool ProvidesExport(const boost::filesystem::path &loc, const String &type) const =0
virtual String GetFormatName() const =0
virtual bool ProvidesImport(const boost::filesystem::path &loc, const String &type) const =0
virtual SurfaceIOHandlerPtr Create() const =0
virtual void Export(const mol::SurfaceHandle &ent, const boost::filesystem::path &loc) const =0
virtual void Import(mol::SurfaceHandle &surf, const boost::filesystem::path &loc)=0
#define DLLEXPORT_OST_IO
std::string String
Definition: base.hh:54
boost::shared_ptr< SurfaceIOHandler > SurfaceIOHandlerPtr
boost::shared_ptr< SurfaceIOHandlerFactoryBase > SurfaceIOHandlerFactoryBasePtr
Definition: base.dox:1