OpenStructure
Loading...
Searching...
No Matches
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-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
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
31#include <ost/io/io_utils.hh>
33
34namespace ost { namespace io {
35
37class DLLEXPORT_OST_IO ProfileIOHandler {
38public:
39 virtual ~ProfileIOHandler() {}
40
41 virtual void Import(seq::ProfileHandle& prof,
42 const boost::filesystem::path& loc) = 0;
43
45 const String& data) = 0;
46
47 virtual void Export(const seq::ProfileHandle& prof,
48 const boost::filesystem::path& loc) const = 0;
49};
50
51typedef boost::shared_ptr<ProfileIOHandler> ProfileIOHandlerPtr;
52
55public:
57 virtual bool ProvidesImport(const boost::filesystem::path& loc,
58 const String& format="auto") const = 0;
59 virtual bool ProvidesExport(const boost::filesystem::path& loc,
60 const String& format="auto") const = 0;
61 virtual ProfileIOHandlerPtr Create() const = 0;
62 virtual String GetFormatName() const =0;
63 virtual String GetFormatDescription() const =0;
64};
65
66typedef boost::shared_ptr<ProfileIOHandlerFactoryBase> ProfileIOHandlerFactoryBasePtr;
67
68template <class HANDLER>
70 virtual bool ProvidesImport(const boost::filesystem::path& loc,
71 const String& format="auto") const {
72 return HANDLER::ProvidesImport(loc, format);
73 }
74
75 virtual bool ProvidesExport(const boost::filesystem::path& loc,
76 const String& format="auto") const {
77 return HANDLER::ProvidesExport(loc, format);
78 }
79
80 virtual ProfileIOHandlerPtr Create() const {
81 return ProfileIOHandlerPtr(new HANDLER);
82 }
83
84 virtual String GetFormatName() const {
85 return HANDLER::GetFormatName();
86 }
87
88 virtual String GetFormatDescription() const {
89 return HANDLER::GetFormatDescription();
90 }
91
92};
93
94}} // ns
95
96#endif
pure abstract base class for creation of a specfic io handler
virtual bool ProvidesExport(const boost::filesystem::path &loc, const String &format="auto") const =0
virtual String GetFormatDescription() const =0
virtual ProfileIOHandlerPtr Create() const =0
virtual String GetFormatName() const =0
virtual bool ProvidesImport(const boost::filesystem::path &loc, const String &format="auto") const =0
virtual void Import(seq::ProfileHandle &prof, const boost::filesystem::path &loc)=0
virtual void Export(const seq::ProfileHandle &prof, const boost::filesystem::path &loc) const =0
virtual void ImportFromString(seq::ProfileHandle &prof, const String &data)=0
Provides a profile for a sequence.
#define DLLEXPORT_OST_IO
std::string String
Definition base.hh:54
boost::shared_ptr< ProfileIOHandler > ProfileIOHandlerPtr
boost::shared_ptr< ProfileIOHandlerFactoryBase > ProfileIOHandlerFactoryBasePtr
Definition base.dox:1