owlps/owlps-positioning/src/resultlist.hh

100 lines
2.0 KiB
C++

/*
* This file is part of the Owl Positioning System (OwlPS).
* OwlPS is a project of the University of Franche-Comté
* (Université de Franche-Comté), France.
*/
#ifndef _OWLPS_POSITIONING_RESULTLIST_HH_
#define _OWLPS_POSITIONING_RESULTLIST_HH_
class Request ;
#include "result.hh"
#include <vector>
#include <ostream>
/// \brief List of \link Result results \endlink of a single Request,
/// computed by one or more positioning algorithm
class ResultList
{
protected:
Request *request ;
std::vector<Result> results ;
public:
ResultList(const Request *_request = NULL,
const std::vector<Result> &_results = std::vector<Result>()):
request(const_cast<Request*>(_request)), results(_results) {}
ResultList(const ResultList &source):
request(source.request), results(source.results) {}
~ResultList(void) ;
/** @name Read accessors */
//@{
/// Checks if there is at least one Result in the list
bool empty(void) const ;
const Request* get_request(void) const ;
const std::vector<Result>& get_results(void) const ;
//@}
/** @name Write accessors */
//@{
void add(const Result &res) ;
//@}
/** @name Operators */
//@{
ResultList& operator=(const ResultList &source) ;
bool operator==(const ResultList &source) const ;
bool operator!=(const ResultList &source) const ;
//@}
/** @name Conversion accessors */
//@{
/// Converts to a CSV string
const std::string to_csv(void) const ;
//@}
/// Displays a ResultList
friend std::ostream& operator<<(std::ostream &os,
const ResultList &r) ;
} ;
/* *** Read accessors *** */
inline bool ResultList::empty() const
{
return results.empty() ;
}
inline const Request* ResultList::get_request() const
{
return request ;
}
inline const std::vector<Result>& ResultList::get_results(void) const
{
return results ;
}
/* *** Write accessors *** */
inline void ResultList::add(const Result &res)
{
results.push_back(res) ;
}
#endif // _OWLPS_POSITIONING_RESULTLIST_HH_