OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
profile_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-2015 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 
20 /*
21  Author: Gerardo Tauriello
22  */
23 
24 #ifndef OST_IO_PROFILE_IO_HANDLER_HH
25 #define OST_IO_PROFILE_IO_HANDLER_HH
26 
27 #include <boost/shared_ptr.hpp>
28 #include <boost/filesystem/operations.hpp>
29 
30 #include <ost/io/module_config.hh>
31 #include <ost/io/io_utils.hh>
33 
34 namespace ost { namespace io {
35 
38 public:
39  virtual ~ProfileIOHandler() {}
40 
41  virtual void Import(seq::ProfileHandle& prof,
42  const boost::filesystem::path& loc) = 0;
43 
44  virtual void Export(const seq::ProfileHandle& prof,
45  const boost::filesystem::path& loc) const = 0;
46 };
47 
48 typedef boost::shared_ptr<ProfileIOHandler> ProfileIOHandlerPtr;
49 
52 public:
54  virtual bool ProvidesImport(const boost::filesystem::path& loc,
55  const String& format="auto") const = 0;
56  virtual bool ProvidesExport(const boost::filesystem::path& loc,
57  const String& format="auto") const = 0;
58  virtual ProfileIOHandlerPtr Create() const = 0;
59  virtual String GetFormatName() const =0;
60  virtual String GetFormatDescription() const =0;
61 };
62 
63 typedef boost::shared_ptr<ProfileIOHandlerFactoryBase> ProfileIOHandlerFactoryBasePtr;
64 
65 template <class HANDLER>
67  virtual bool ProvidesImport(const boost::filesystem::path& loc,
68  const String& format="auto") const {
69  return HANDLER::ProvidesImport(loc, format);
70  }
71 
72  virtual bool ProvidesExport(const boost::filesystem::path& loc,
73  const String& format="auto") const {
74  return HANDLER::ProvidesExport(loc, format);
75  }
76 
77  virtual ProfileIOHandlerPtr Create() const {
78  return ProfileIOHandlerPtr(new HANDLER);
79  }
80 
81  virtual String GetFormatName() const {
82  return HANDLER::GetFormatName();
83  }
84 
85  virtual String GetFormatDescription() const {
86  return HANDLER::GetFormatDescription();
87  }
88 
89 };
90 
91 }} // ns
92 
93 #endif
pure abstract base class for creation of a specfic io handler
std::string String
Definition: base.hh:54
pure abstract base class for profile io handlers
boost::shared_ptr< ProfileIOHandlerFactoryBase > ProfileIOHandlerFactoryBasePtr
Provides a profile for a sequence.
#define DLLEXPORT_OST_IO
boost::shared_ptr< ProfileIOHandler > ProfileIOHandlerPtr