23#ifndef _TRADATA_READER_HPP_
24#define _TRADATA_READER_HPP_
44 bool accept(
const std::string& filename,
45 const std::string& head)
const
47 return (identify(filename,head).length() != 0);
55 virtual std::string
identify(
const std::string& filename,
56 const std::string& head)
const = 0;
59 virtual void read(
const std::string& filename,
60 const std::string& head,
62 int runIndex = 0)
const = 0;
65 virtual void read(
const std::string& filename,
66 const std::string& head,
67 std::vector<TraDataPtr>& results)
const = 0;
84 :
std::runtime_error((
"[ReaderFail] " + error).c_str()),
88 virtual const std::string&
error()
const {
return error_;}
105 public std::vector<ReaderPtr>
110 virtual std::string
identify(
const std::string& filename)
const;
113 virtual std::string
identify(
const std::string& filename,
114 const std::string& head)
const;
117 virtual void read(
const std::string& filename,
119 int runIndex = 0)
const;
122 virtual void read(
const std::string& filename,
123 const std::string& head,
125 int runIndex = 0)
const;
129 virtual void read(
const std::string& filename,
130 std::vector<TraDataPtr>& results)
const;
134 virtual void read(
const std::string& filename,
135 const std::string& head,
136 std::vector<TraDataPtr>& results)
const;
162 template <
typename reader_type>
165 for (iterator it=begin(); it!=end(); ++it)
167 reader_type* p =
dynamic_cast<reader_type*
>(it->get());
175 template <
typename reader_type>
176 const reader_type*
get()
const
178 return const_cast<ReaderList*
>(
this)->get<reader_type>();
181 virtual const char *
getType()
const {
return "ReaderList";}
interface for file readers
Reader container (composite pattern).
ReaderFail(const std::string &error)
virtual const std::string & error() const
virtual void read(const std::string &filename, const std::string &head, TraData &result, int runIndex=0) const =0
fill in the TraData structure from the first (or only) sample
virtual const char * getType() const =0
fill in a vector of MSData.Id values; provides support for multi-run input files
virtual std::string identify(const std::string &filename, const std::string &head) const =0
return file type iff Reader recognizes the file, else empty;
virtual void read(const std::string &filename, const std::string &head, std::vector< TraDataPtr > &results) const =0
fill in a vector of TraData structures; provides support for multi-run input files
bool accept(const std::string &filename, const std::string &head) const
return true iff Reader recognizes the file as one it should handle
virtual void read(const std::string &filename, const std::string &head, TraData &result, int runIndex=0) const
delegates to first child that identifies
reader_type * get()
returns pointer to Reader of the specified type
const reader_type * get() const
returns const pointer to Reader of the specified type
virtual void read(const std::string &filename, std::vector< TraDataPtr > &results) const
delegates to first child that identifies; provides support for multi-run input files
virtual void read(const std::string &filename, const std::string &head, std::vector< TraDataPtr > &results) const
delegates to first child that identifies; provides support for multi-run input files
virtual const char * getType() const
virtual std::string identify(const std::string &filename, const std::string &head) const
returns child name iff some child identifies, else empty string
virtual void read(const std::string &filename, TraData &result, int runIndex=0) const
delegates to first child that identifies
virtual std::string identify(const std::string &filename) const
returns child name iff some child identifies, else empty string
boost::shared_ptr< Reader > ReaderPtr
PWIZ_API_DECL ReaderList operator+(const ReaderPtr &lhs, const ReaderPtr &rhs)
returns a list containing the lhs and rhs as readers