diff --git a/owlps-positioning/Makefile b/owlps-positioning/Makefile index 247ea3c..183793d 100644 --- a/owlps-positioning/Makefile +++ b/owlps-positioning/Makefile @@ -18,15 +18,14 @@ CPPCHECK = cppcheck --enable=all DOXYGEN = doxygen GXX = g++-4.4 -DEBUG = -g -STLPORTGXXFLAGS = -I/usr/include/stlport -pthread -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +#DEBUG = -g GXXFLAGS = $(DEBUG) -Wall -Wextra $(STLPORTGXXFLAGS) LD = $(GXX) -LDFLAGS = -lm -lstlport +LDFLAGS = -lm -lrt LIBS = -lpq -lboost_program_options-mt TARGET = owlps-positioning -HEADER = owlps-positioning.hh +#HEADER = owlps-positioning.hh OBJ = posutil.o point3d.o referencepoint.o waypoint.o building.o \ area.o wifidevice.o accesspoint.o mobile.o measurement.o \ calibrationmeasurement.o request.o inputcsv.o stock.o @@ -35,6 +34,7 @@ all: $(TARGET) %: %.o $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) + %.o: %.cc $(HEADER) $(GXX) $(GXXFLAGS) -c $< @@ -81,7 +81,10 @@ uninstall: @$(RM) $(INSTALL_DIR)/$(TARGET) style: - @$(STYLE) $(OBJ:.o=.hh) $(OBJ:.o=.cc) inputmedium.hh + @$(STYLE) \ + $(OBJ:.o=.hh) \ + $(OBJ:.o=.cc) \ + inputmedium.hh check: @$(CPPCHECK) $(OBJ:.o=.hh) $(OBJ:.o=.cc) inputmedium.hh diff --git a/owlps-positioning/TODO b/owlps-positioning/TODO index a1ad98f..f8b4370 100644 --- a/owlps-positioning/TODO +++ b/owlps-positioning/TODO @@ -33,9 +33,6 @@ les Waypoint. Si oui, faut-il aussi les enlever des listes dans Stock ? (Pour l'instant ils ne sont pas dans Stock.) -- Request - Constructeur par recopie, operator==(), etc. - - PosUtil Remplacer timespec_equals() par operator==(timespec, timespec) ? diff --git a/owlps-positioning/inputcsv.cc b/owlps-positioning/inputcsv.cc index 4cfc131..1fb0751 100644 --- a/owlps-positioning/inputcsv.cc +++ b/owlps-positioning/inputcsv.cc @@ -5,7 +5,7 @@ #include #include -#include +#include using namespace std ; using std::tr1::unordered_map ; diff --git a/owlps-positioning/request.cc b/owlps-positioning/request.cc index 07a85b7..cb89133 100644 --- a/owlps-positioning/request.cc +++ b/owlps-positioning/request.cc @@ -36,6 +36,14 @@ Request::Request(const Mobile *_mobile, const struct timespec &_timestamp, } +Request::Request(const Request &source) +{ + mobile = source.mobile ; + timestamp = source.timestamp ; + measurements = source.measurements ; +} + + /** * Note that the value pointed by #mobile is not deleted. @@ -68,6 +76,32 @@ void Request::clear() /* *** Operators *** */ +const Request& Request::operator=(const Request &source) +{ + if (this == &source) + return *this ; + + mobile = source.mobile ; + timestamp = source.timestamp ; + measurements = source.measurements ; + + return *this ; +} + + +bool Request::operator==(const Request &comp) const +{ + if (this == &comp) + return true ; + + return + mobile == comp.mobile && + PosUtil::timespec_equals(timestamp, comp.timestamp) && + measurements == comp.measurements ; +} + + + ostream &operator<<(ostream &os, const Request &r) { // Timestamp diff --git a/owlps-positioning/request.hh b/owlps-positioning/request.hh index dda88c7..b64c3e7 100644 --- a/owlps-positioning/request.hh +++ b/owlps-positioning/request.hh @@ -6,7 +6,7 @@ class Mobile ; #include "measurement.hh" #include -#include +#include #include /// Represents a request sent by a Mobile @@ -35,6 +35,8 @@ public: Request(const Mobile *_mobile, const struct timespec &_timestamp, const std::tr1::unordered_map &_measurements = std::tr1::unordered_map()) ; + /// Copy constructor + Request(const Request &source) ; ~Request(void) ; ///< Destructor @@ -61,6 +63,9 @@ public: /** @name Operators */ //@{ + const Request& operator=(const Request &source) ; + bool operator==(const Request &comp) const ; + bool operator!=(const Request &comp) const ; operator bool(void) const ; ///< Cast to bool operator //@} @@ -112,6 +117,12 @@ inline void Request::set_measurements(const std::tr1::unordered_map /* *** Operators *** */ +inline bool Request::operator!=(const Request &comp) const +{ + return !(*this == comp) ; +} + + /** * @return \em false if the Request is empty. * @return \em true if at least one attribute is initialised. diff --git a/owlps-positioning/stock.hh b/owlps-positioning/stock.hh index 194a040..b43ef5d 100644 --- a/owlps-positioning/stock.hh +++ b/owlps-positioning/stock.hh @@ -4,7 +4,7 @@ #include "mobile.hh" #include "accesspoint.hh" -#include +#include /// Storage class class Stock