Go to the documentation of this file.
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";}
194 #endif // _TRADATA_READER_HPP_
bool accept(const std::string &filename, const std::string &head) const
return true iff Reader recognizes the file as one it should handle
Reader container (composite pattern).
virtual void read(const std::string &filename, const std::string &head, TraData &result, int runIndex=0) const
delegates to first child that identifies
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 const char * getType() const =0
fill in a vector of MSData.Id values; provides support for multi-run input files
PWIZ_API_DECL double & operator+=(double &d, const MZTolerance &tolerance)
interface for file readers
reader_type * get()
returns pointer to Reader of the specified type
virtual const std::string & error() const
PWIZ_API_DECL ReaderList operator+(const ReaderPtr &lhs, const ReaderPtr &rhs)
returns a list containing the lhs and rhs as readers
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
virtual std::string identify(const std::string &filename) 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 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
const reader_type * get() const
returns const pointer to Reader of the specified type
ReaderFail(const std::string &error)
boost::shared_ptr< Reader > ReaderPtr
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 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 std::string identify(const std::string &filename, const std::string &head) const =0
return file type iff Reader recognizes the file, else empty;