/*
 * This file is part of the Owl Positioning System (OwlPS) project.
 * It is subject to the copyright notice and license terms in the
 * COPYRIGHT.t2t file found in the top-level directory of this
 * distribution and at
 *   https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
 * No part of the OwlPS Project, including this file, may be copied,
 * modified, propagated, or distributed except according to the terms
 * contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
 * distributed along with this file, either separately or by replacing
 * this notice by the COPYRIGHT.t2t file's contents.
 */


#ifndef _OWLPS_POSITIONING_RESULTLIST_HH_
#define _OWLPS_POSITIONING_RESULTLIST_HH_

class Request ;
#include "result.hh"

#include <vector>
#include <ostream>

/// List of [results](@ref Result) of a single Request, computed by one
/// or more positioning algorithm
class ResultList
{
protected:
  const Request *request ;
  std::vector<Result> results ;

public:
  ResultList(const Request *const _request = nullptr,
             const std::vector<Result> &_results = std::vector<Result>()):
    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 ;
  const Result& get_result_for_algo(const std::string &algo) const ;
  //@}

  /** @name Write accessors */
  //@{
  /// Adds a result to the ResultList
  void add(const Result &res) ;
  /// Sets the Request associated with the ResultList
  void set_request(const Request *const _request) ;
  //@}

  /** @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) ;
}


inline void ResultList::set_request(const Request *const _request)
{
  request = _request ;
}



#endif // _OWLPS_POSITIONING_RESULTLIST_HH_
