OpenStructure
Loading...
Searching...
No Matches
sequence_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_SEQUENCE_IO_HANDLER_HH
20#define OST_IO_SEQUENCE_IO_HANDLER_HH
21
22#include <boost/shared_ptr.hpp>
23#include <boost/filesystem/operations.hpp>
24
25
28#include <ost/io/io_utils.hh>
29
30namespace ost { namespace io {
31
34public:
35 virtual ~SequenceIOHandler() {}
36
37
38 virtual void Import(seq::SequenceList& sequences,
39 const boost::filesystem::path& loc) = 0;
40
41 virtual void Export(const seq::ConstSequenceList& ent,
42 const boost::filesystem::path& loc) const = 0;
43
44 virtual void Import(seq::SequenceList& ent,
45 std::istream& instream)=0;
46
47 virtual void Export(const seq::ConstSequenceList& ent,
48 std::ostream& ostream) const=0;
49};
50
51typedef boost::shared_ptr<SequenceIOHandler> SequenceIOHandlerPtr;
52
53
56public:
58 virtual bool ProvidesImport(const boost::filesystem::path& loc,
59 const String& type) const = 0;
60 virtual bool ProvidesExport(const boost::filesystem::path& loc,
61 const String& type) const = 0;
62 virtual SequenceIOHandlerPtr Create() const = 0;
63 virtual String GetFormatName() const =0;
64 virtual String GetFormatDescription() const =0;
65};
66
67typedef boost::shared_ptr<SequenceIOHandlerFactoryBase> SequenceIOHandlerFactoryBasePtr;
68
69template <class HANDLER>
71 virtual bool ProvidesImport(const boost::filesystem::path& loc,
72 const String& type) const {
73 return HANDLER::ProvidesImport(loc,type);
74 }
75
76 virtual bool ProvidesExport(const boost::filesystem::path& loc,
77 const String& type) const {
78 return HANDLER::ProvidesExport(loc,type);
79 }
80
81 virtual SequenceIOHandlerPtr Create() const {
82 return SequenceIOHandlerPtr(new HANDLER);
83 }
84
85 virtual String GetFormatName() const {
86 return HANDLER::GetFormatName();
87 }
88
89 virtual String GetFormatDescription() const {
90 return HANDLER::GetFormatDescription();
91 }
92
93};
94
95
96
97}} // ns
98
99#endif
pure abstract base class for creation of a specfic alignment io handler
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 SequenceIOHandlerPtr Create() const =0
pure abstract base class for entity io handlers
virtual void Import(seq::SequenceList &sequences, const boost::filesystem::path &loc)=0
virtual void Export(const seq::ConstSequenceList &ent, std::ostream &ostream) const =0
virtual void Import(seq::SequenceList &ent, std::istream &instream)=0
virtual void Export(const seq::ConstSequenceList &ent, const boost::filesystem::path &loc) const =0
list of immutable sequences.
list of sequences.
#define DLLEXPORT_OST_IO
std::string String
Definition base.hh:54
boost::shared_ptr< SequenceIOHandler > SequenceIOHandlerPtr
boost::shared_ptr< SequenceIOHandlerFactoryBase > SequenceIOHandlerFactoryBasePtr
Definition base.dox:1