[Positioning] Result::operator<< and minor fixes
Result: add operator<<(). Input: delete log media in destructor. Request: typo, suppress some useless Doxygen comments.
This commit is contained in:
parent
9a334ad028
commit
7c8038edc2
|
@ -6,6 +6,8 @@
|
|||
#include "posexcept.hh"
|
||||
#include "stock.hh"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
|
@ -23,6 +25,11 @@ Input::Input()
|
|||
Input::~Input()
|
||||
{
|
||||
delete medium ;
|
||||
|
||||
for (vector<InputLogMedium*>::const_iterator i = log_media.begin() ;
|
||||
i != log_media.end() ; ++i)
|
||||
delete *i ;
|
||||
log_media.clear() ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ class InputMedium ;
|
|||
class InputLogMedium ;
|
||||
class Request ;
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/// Handles the inputs
|
||||
|
|
|
@ -99,7 +99,7 @@ bool Request::operator==(const Request &comp) const
|
|||
|
||||
|
||||
|
||||
ostream &operator<<(ostream &os, const Request &r)
|
||||
ostream& operator<<(ostream &os, const Request &r)
|
||||
{
|
||||
// Timestamp
|
||||
os
|
||||
|
|
|
@ -24,44 +24,33 @@ protected:
|
|||
std::tr1::unordered_map<std::string, Measurement> measurements ;
|
||||
|
||||
public:
|
||||
/// Constructs a Request from a list of Measurement (or default constructor)
|
||||
Request(const std::tr1::unordered_map<std::string, Measurement>
|
||||
&_measurements =
|
||||
std::tr1::unordered_map<std::string, Measurement>()) ;
|
||||
/// Constructs a Request from a timestamp and (possibly) a Measurement list
|
||||
Request(const Timestamp &_timestamp,
|
||||
const std::tr1::unordered_map<std::string, Measurement>
|
||||
&_measurements =
|
||||
std::tr1::unordered_map<std::string, Measurement>()) ;
|
||||
/// \brief Constructs a request from a mobile and a timestamp and (possibly)
|
||||
/// a Measurement list
|
||||
Request(const Mobile *_mobile, const Timestamp &_timestamp,
|
||||
const std::tr1::unordered_map<std::string, Measurement>
|
||||
&_measurements =
|
||||
std::tr1::unordered_map<std::string, Measurement>()) ;
|
||||
/// Copy constructor
|
||||
Request(const Request &source) ;
|
||||
|
||||
virtual ~Request(void) ;
|
||||
|
||||
/** @name Read accessors */
|
||||
//@{
|
||||
/// #mobile read accessor
|
||||
Mobile* get_mobile(void) const ;
|
||||
/// #timestamp read accessor
|
||||
const Timestamp& get_timestamp(void) const ;
|
||||
/// #measurements read accessor
|
||||
const std::tr1::unordered_map<std::string, Measurement>&
|
||||
get_measurements(void) const ;
|
||||
//@}
|
||||
|
||||
/** @name Write accessors */
|
||||
//@{
|
||||
/// #mobile write accessor
|
||||
void set_mobile(const Mobile *_mobile) ;
|
||||
/// #timestamp write accessor
|
||||
void set_timestamp(const Timestamp &_timestamp) ;
|
||||
/// #measurements write accessor
|
||||
void set_measurements(const std::tr1::unordered_map
|
||||
<std::string, Measurement> &_measurements) ;
|
||||
/// Reinitialises all attributes
|
||||
|
@ -77,7 +66,7 @@ public:
|
|||
//@}
|
||||
|
||||
/// Displays a Request
|
||||
friend std::ostream &operator<<(std::ostream &os, const Request &r) ;
|
||||
friend std::ostream& operator<<(std::ostream &os, const Request &r) ;
|
||||
} ;
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "result.hh"
|
||||
#include "request.hh"
|
||||
|
||||
|
||||
|
||||
|
@ -23,3 +24,18 @@ bool Result::operator==(const Result &source)
|
|||
position == source.position &&
|
||||
request == source.request ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::ostream& operator<<(std::ostream &os, const Result &r)
|
||||
{
|
||||
if (r.request == NULL)
|
||||
os << "For an unknown request, the result is: " ;
|
||||
else
|
||||
os
|
||||
<< "For the following request: "
|
||||
<< *(r.request)
|
||||
<< "\nThe result is: " ;
|
||||
os << r.position ;
|
||||
return os ;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@ public:
|
|||
bool operator==(const Result &source) ;
|
||||
bool operator!=(const Result &source) ;
|
||||
//@}
|
||||
|
||||
/// Displays a Result
|
||||
friend std::ostream& operator<<(std::ostream &os, const Result &r) ;
|
||||
} ;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue