From ee0499afadc536b78b86947a2e664cfc43ae8f22 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 5 Mar 2010 17:24:18 +0100 Subject: [PATCH] [Positioning] Code and comments clean-up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Where possible, use initialisation lists in class definition instead of explicit variable initialisations in source file. - Rename some variables (use of "source" in copy constructors and operators…). - Suppress useless Doxygen comments, allow non-documented members in Doxyfile. --- owlps-positioning/Doxyfile | 2 +- owlps-positioning/Makefile | 2 +- owlps-positioning/TODO | 16 +++++-- owlps-positioning/src/accesspoint.cc | 20 ++++----- owlps-positioning/src/accesspoint.hh | 47 ++++++++------------- owlps-positioning/src/area.cc | 38 ++++++----------- owlps-positioning/src/area.hh | 32 +++++++------- owlps-positioning/src/building.cc | 36 +++++----------- owlps-positioning/src/building.hh | 30 ++++++------- owlps-positioning/src/calibrationrequest.hh | 10 +---- owlps-positioning/src/direction.cc | 4 +- owlps-positioning/src/direction.hh | 3 -- owlps-positioning/src/input.cc | 5 ++- owlps-positioning/src/inputcsv.hh | 11 +---- owlps-positioning/src/inputlogcsv.cc | 5 +-- owlps-positioning/src/inputlogcsv.hh | 2 +- owlps-positioning/src/inputlogmedium.hh | 2 +- owlps-positioning/src/inputmedium.cc | 5 ++- owlps-positioning/src/inputmedium.hh | 3 -- owlps-positioning/src/measurement.cc | 23 ++-------- owlps-positioning/src/measurement.hh | 20 +++------ owlps-positioning/src/mobile.hh | 8 ++-- owlps-positioning/src/output.hh | 2 +- owlps-positioning/src/outputmedium.hh | 2 +- owlps-positioning/src/point3d.cc | 27 ------------ owlps-positioning/src/point3d.hh | 31 ++++++++------ owlps-positioning/src/referencepoint.hh | 8 ++-- owlps-positioning/src/request.cc | 35 +-------------- owlps-positioning/src/request.hh | 29 ++++++++----- owlps-positioning/src/timestamp.hh | 4 +- owlps-positioning/src/userinterface.cc | 19 +++++++-- owlps-positioning/src/waypoint.cc | 16 +++---- owlps-positioning/src/waypoint.hh | 15 +++---- owlps-positioning/src/wifidevice.cc | 25 ----------- owlps-positioning/src/wifidevice.hh | 25 +++++------ 35 files changed, 210 insertions(+), 352 deletions(-) diff --git a/owlps-positioning/Doxyfile b/owlps-positioning/Doxyfile index 7e324e1..f867e76 100644 --- a/owlps-positioning/Doxyfile +++ b/owlps-positioning/Doxyfile @@ -297,7 +297,7 @@ SYMBOL_CACHE_SIZE = 0 # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES -EXTRACT_ALL = NO +EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. diff --git a/owlps-positioning/Makefile b/owlps-positioning/Makefile index 61a4cb1..59bb5e3 100644 --- a/owlps-positioning/Makefile +++ b/owlps-positioning/Makefile @@ -20,7 +20,7 @@ MKDIR = mkdir -pv # Other tools STYLE = astyle --style=gnu --formatted CPPCHECK = cppcheck --enable=all -DOXYGEN = doxygen +DOXYGEN = doxygen >/dev/null # Compilation tools and flags GXX = g++-4.4 diff --git a/owlps-positioning/TODO b/owlps-positioning/TODO index 5f5d1ad..a4deaa0 100644 --- a/owlps-positioning/TODO +++ b/owlps-positioning/TODO @@ -16,18 +16,28 @@ Stock ? (Pour l'instant ils ne sont pas dans Stock.) - AccessPoint - Attribut float friis_index ? + ° Attribut float friis_index ? + ° Lancer une exception si le canal Wi-Fi est mauvais (ou + directement dans PosUtil::channel_to_frequency() ?). - ReferencePoint ° La liste des requêtes devrait être un unordered_set (et pas un vector), pour garantir l'unicité des entrées. + ° Faire quelque chose pour le code commenté (idem dans + Measurement). - Mobile Attributs Viterbi ? (Cf. l'ancien clientinfo.hh.) +- Renommages de membres + ° Request : timestamp −> date_sent + ° InputMedium : + °° current_line_nb et get_current_line_nb() + °° get_next_request() −> read_next_request() + ° Input : get_next_request() −> read_next_request() + ° Area : p_min et p_max ? + - Doxygen - ° Supprimer les commentaires inutiles et autoriser les membres non - documentés dans Doxyfile. ° Pourquoi une description détaillée placée dans un .cc ne s'affiche pas pour operator<<() ? diff --git a/owlps-positioning/src/accesspoint.cc b/owlps-positioning/src/accesspoint.cc index 6ff8e15..9d09876 100644 --- a/owlps-positioning/src/accesspoint.cc +++ b/owlps-positioning/src/accesspoint.cc @@ -8,28 +8,28 @@ using namespace std ; /* *** Operators *** */ -const AccessPoint& AccessPoint::operator=(const AccessPoint &ap) +const AccessPoint& AccessPoint::operator=(const AccessPoint &source) { - if (this == &ap) + if (this == &source) return *this ; - this->WifiDevice::operator=(ap) ; - coordinates = ap.coordinates ; - frequency = ap.frequency ; + this->WifiDevice::operator=(source) ; + coordinates = source.coordinates ; + frequency = source.frequency ; return *this ; } -bool AccessPoint::operator==(const AccessPoint &ap) const +bool AccessPoint::operator==(const AccessPoint &source) const { - if (this == &ap) + if (this == &source) return true ; return - this->WifiDevice::operator==(ap) && - coordinates == ap.coordinates && - frequency == ap.frequency ; + this->WifiDevice::operator==(source) && + coordinates == source.coordinates && + frequency == source.frequency ; } diff --git a/owlps-positioning/src/accesspoint.hh b/owlps-positioning/src/accesspoint.hh index b1d3a63..c053434 100644 --- a/owlps-positioning/src/accesspoint.hh +++ b/owlps-positioning/src/accesspoint.hh @@ -12,19 +12,15 @@ class AccessPoint: public WifiDevice { protected: - Point3D coordinates ; ///< Coordinates of the AccessPoint + Point3D coordinates ; unsigned int frequency ; ///< Frequency (channel) in Hz public: - /// \brief Constructs an AccessPoint by defining all of its - /// attributes (or default constructor) /** - * @param _coordinates Coordinates. - * @param _ip_addr IP address. - * @param _mac_addr MAC address. - * @param _antenna_gain Antenna gain in dBi. - * @param _trx_power Transmit power in dBm. - * @param channel Wi-Fi channel the AP is listening to (integer + * Special parameters: + * - \em _antenna_gain Antenna gain in dBi. + * - \em _trx_power Transmit power in dBm. + * - \em channel Wi-Fi channel the AP is listening to (integer * between 1 and 14). It will be converted to a frequency in Hz. */ AccessPoint(const Point3D &_coordinates = Point3D(), @@ -37,46 +33,39 @@ public: coordinates(_coordinates), frequency(PosUtil::channel_to_frequency(channel)) {} - /// Constructs an AccessPoint from a WifiDevice, a Point3D and a frequency - AccessPoint(const WifiDevice &wd, + AccessPoint(const WifiDevice &source, const Point3D &_coordinates, const unsigned int &channel = AP_DEFAULT_CHANNEL): - WifiDevice(wd), coordinates(_coordinates), + WifiDevice(source), coordinates(_coordinates), frequency(PosUtil::channel_to_frequency(channel)) {} - /// Constructs an AccessPoint from a WifiDevice - AccessPoint(const WifiDevice &wd): - WifiDevice(wd), coordinates(Point3D()), frequency(0) {} + AccessPoint(const WifiDevice &source): + WifiDevice(source), coordinates(Point3D()), frequency(0) {} - /// Copy constructor - AccessPoint(const AccessPoint &ap): - WifiDevice(ap), coordinates(ap.coordinates), frequency(ap.frequency) {} + AccessPoint(const AccessPoint &source): + WifiDevice(source), coordinates(source.coordinates), + frequency(source.frequency) {} - ~AccessPoint(void) {} ///< Destructor (do nothing) + ~AccessPoint(void) {} /** @name Read accessors */ //@{ - /// #coordinates read accessor const Point3D& get_coordinates(void) const ; - /// #frequency read accessor unsigned int get_frequency(void) const ; //@} /** @name Write accessors */ //@{ - /// #coordinates write accessor void set_coordinates(const Point3D &_coordinates) ; - /// Set #frequency with a Wi-Fi channel void set_channel(const unsigned int channel) ; - /// #frequency write accessor void set_frequency(const unsigned int _frequency) ; //@} /** @name Operators */ //@{ - const AccessPoint& operator=(const AccessPoint &ap) ; - bool operator==(const AccessPoint &ap) const ; - bool operator!=(const AccessPoint &ap) const ; + const AccessPoint& operator=(const AccessPoint &source) ; + bool operator==(const AccessPoint &source) const ; + bool operator!=(const AccessPoint &source) const ; //@} /// Displays an AccessPoint @@ -138,9 +127,9 @@ inline void AccessPoint::set_frequency(const unsigned int _frequency) /* *** Operators *** */ -inline bool AccessPoint::operator!=(const AccessPoint &ap) const +inline bool AccessPoint::operator!=(const AccessPoint &source) const { - return !(*this == ap) ; + return !(*this == source) ; } diff --git a/owlps-positioning/src/area.cc b/owlps-positioning/src/area.cc index 3a9c1e9..afb7f57 100644 --- a/owlps-positioning/src/area.cc +++ b/owlps-positioning/src/area.cc @@ -9,23 +9,13 @@ using namespace std ; Area::Area(const Building *_building, const string &_name, - const Point3D &p1, const Point3D &p2) + const Point3D &p1, const Point3D &p2): + building(const_cast(_building)), name(_name) { - building = const_cast(_building) ; - name = _name ; set_coordinates(p1, p2) ; } -Area::Area(const Area &a) -{ - building = a.building ; - name = a.name ; - p_min = a.p_min ; - p_max = a.p_max ; -} - - /* *** Operations *** */ @@ -128,30 +118,30 @@ void Area::reorder_coordinates() /* *** Operators *** */ -const Area& Area::operator=(const Area &a) +const Area& Area::operator=(const Area &source) { - if (this == &a) + if (this == &source) return *this ; - building = a.building ; - name = a.name ; - p_min = a.p_min ; - p_max = a.p_max ; + building = source.building ; + name = source.name ; + p_min = source.p_min ; + p_max = source.p_max ; return *this ; } -bool Area::operator==(const Area &a) const +bool Area::operator==(const Area &source) const { - if (this == &a) + if (this == &source) return true ; return - building == a.building && - name == a.name && - p_min == a.p_min && - p_max == a.p_max ; + building == source.building && + name == source.name && + p_min == source.p_min && + p_max == source.p_max ; } diff --git a/owlps-positioning/src/area.hh b/owlps-positioning/src/area.hh index 25a723f..2f15513 100644 --- a/owlps-positioning/src/area.hh +++ b/owlps-positioning/src/area.hh @@ -13,37 +13,35 @@ class Area { protected: Building *building ; ///< The Building in which the Area is - std::string name ; ///< Name of the Area + std::string name ; Point3D p_min ; ///< First coordinate of the Area Point3D p_max ; ///< Second coordinate of the Area void reorder_coordinates(void) ; ///< Reorders #p_min and #p_max public: - /// \brief Constructs an Area from a Building, a name and two 3-float - /// defined points (or default constructor) Area(const Building *_building = NULL, const std::string &_name = "Unnamed area", const Point3D &p1 = Point3D(0,0,0), const Point3D &p2 = Point3D(0,0,0)) ; - /// Copy constructor - Area(const Area &a) ; - ~Area(void) {} ///< Destructor (do nothing) + Area(const Area &source): + building(source.building), name(source.name), + p_min(source.p_min), p_max(source.p_max) {} + + ~Area(void) {} /** @name Read accessors */ //@{ - Building* get_building(void) const ; ///< #building read accessor - const std::string& get_name(void) const ; ///< #name read accessor - const Point3D& get_p_min(void) const ; ///< #p_min read accessor - const Point3D& get_p_max(void) const ; ///< #p_max read accessor + Building* get_building(void) const ; + const std::string& get_name(void) const ; + const Point3D& get_p_min(void) const ; + const Point3D& get_p_max(void) const ; //@} /** @name Write accessors */ //@{ - /// #building write accessor void set_building(const Building *_building) ; - /// #name write accessor void set_name(const std::string &_name) ; /// Sets the coordinates of the Area and reorder them void set_coordinates(const Point3D &p1, const Point3D &p2) ; @@ -57,9 +55,9 @@ public: /** @name Operators */ //@{ - const Area& operator=(const Area &a) ; - bool operator==(const Area &a) const ; - bool operator!=(const Area &a) const ; + const Area& operator=(const Area &source) ; + bool operator==(const Area &source) const ; + bool operator!=(const Area &source) const ; //@} /// Displays an Area @@ -123,9 +121,9 @@ inline void Area::set_coordinates(const Point3D &p1, const Point3D &p2) /* *** Operators *** */ -inline bool Area::operator!=(const Area &a) const +inline bool Area::operator!=(const Area &source) const { - return !(*this == a) ; + return !(*this == source) ; } diff --git a/owlps-positioning/src/building.cc b/owlps-positioning/src/building.cc index 293629b..83e63a7 100644 --- a/owlps-positioning/src/building.cc +++ b/owlps-positioning/src/building.cc @@ -10,22 +10,6 @@ using namespace std ; /* *** Constructors *** */ -Building::Building(const string &_name) -{ - name = _name ; -} - - - -Building::Building(const Building &b) -{ - name = b.name ; - areas = b.areas ; - waypoints = b.waypoints ; -} - - - /** * Note: deletes (unallocates) all elements in #areas; deletes elements * in #waypoints that belong only to this Building (waypoints that link @@ -55,28 +39,28 @@ Building::~Building() /* *** Operators *** */ -const Building& Building::operator=(const Building &b) +const Building& Building::operator=(const Building &source) { - if (this == &b) + if (this == &source) return *this ; - name = b.name ; - areas = b.areas ; - waypoints = b.waypoints ; + name = source.name ; + areas = source.areas ; + waypoints = source.waypoints ; return *this; } -bool Building::operator==(const Building &b) const +bool Building::operator==(const Building &source) const { - if (this == &b) + if (this == &source) return true ; return - name == b.name && - areas == b.areas && - waypoints == b.waypoints ; + name == source.name && + areas == source.areas && + waypoints == source.waypoints ; } diff --git a/owlps-positioning/src/building.hh b/owlps-positioning/src/building.hh index 6ba9567..34796bd 100644 --- a/owlps-positioning/src/building.hh +++ b/owlps-positioning/src/building.hh @@ -12,31 +12,31 @@ class Waypoint ; class Building { protected: - std::string name ; ///< Name of the Building - std::vector areas ; ///< List of Area contained in the Building - std::vector waypoints ; ///< List of Waypoint in the Building + std::string name ; + /// List of Area contained in the Building + std::vector areas ; + /// List of Waypoint in the Building + std::vector waypoints ; public : - /// Constructs a Building from its name (or default constructor) - Building(const std::string &_name = "Unnamed building") ; - /// Copy constructor - Building(const Building &b) ; + Building(const std::string &_name = "Unnamed building"): + name(_name) {} - ~Building(void) ; ///< Destructor + Building(const Building &source): + name(source.name), areas(source.areas), + waypoints(source.waypoints) {} + + ~Building(void) ; /** @name Read accessors */ //@{ - /// #name read accessor const std::string& get_name(void) const ; - /// #areas read accessor const std::vector& get_areas(void) const ; - /// #waypoints read accessor const std::vector& get_waypoints(void) const ; //@} /** @name Write accessors */ //@{ - /// #name write accessor void set_name(const std::string &_name) ; /// Adds an Area to the \link #areas list of areas\endlink void add_area(const Area *a) ; @@ -46,9 +46,9 @@ public : /** @name Operators */ //@{ - const Building& operator=(const Building &p) ; - bool operator==(const Building &p) const ; - bool operator!=(const Building &p) const ; + const Building& operator=(const Building &source) ; + bool operator==(const Building &source) const ; + bool operator!=(const Building &source) const ; //@} /// Displays a Building diff --git a/owlps-positioning/src/calibrationrequest.hh b/owlps-positioning/src/calibrationrequest.hh index de4b102..96461d0 100644 --- a/owlps-positioning/src/calibrationrequest.hh +++ b/owlps-positioning/src/calibrationrequest.hh @@ -18,12 +18,11 @@ protected: public: CalibrationRequest(void): reference_point(NULL), direction(Direction()) {} - /// Copy constructor + CalibrationRequest(const CalibrationRequest &source): Request(source), reference_point(source.reference_point), direction(source.direction) {} - /// \brief Constructs a CalibrationRequest from a Request and - /// possibly a ReferencePoint and a Direction) + CalibrationRequest(const Request &source, ReferencePoint *_reference_point = NULL, const Direction &_direction = Direction()): @@ -34,21 +33,16 @@ public: /** @name Read accessors */ //@{ - /// #direction read accessor const Direction& get_direction(void) const ; - /// #reference_point read accessor ReferencePoint* get_reference_point(void) const ; //@} /** @name Write accessors */ //@{ - /// #direction write accessor void set_direction(const Direction &_direction) ; - /// #reference_point write accessor void set_reference_point(const ReferencePoint *_rp) ; /// Add the CalibrationRequest to the #reference_point list of requests void reference_point_backward_link(void) const ; - /// Reinitialises all attributes void clear(void) ; //@} diff --git a/owlps-positioning/src/direction.cc b/owlps-positioning/src/direction.cc index 06fd254..d033248 100644 --- a/owlps-positioning/src/direction.cc +++ b/owlps-positioning/src/direction.cc @@ -6,9 +6,9 @@ /* *** Constructors *** */ -Direction::Direction(const char source) +Direction::Direction(const char source): + direction(source) { - direction = source ; assert_valid() ; } diff --git a/owlps-positioning/src/direction.hh b/owlps-positioning/src/direction.hh index bc24a01..2c89796 100644 --- a/owlps-positioning/src/direction.hh +++ b/owlps-positioning/src/direction.hh @@ -10,11 +10,8 @@ class Direction protected: char direction ; - /** @name Operations */ - //@{ void assert_valid(void) const ; bool is_valid(void) const ; - //@} public: enum {north = 1, east, south, west} ; diff --git a/owlps-positioning/src/input.cc b/owlps-positioning/src/input.cc index 91886c8..c72a236 100644 --- a/owlps-positioning/src/input.cc +++ b/owlps-positioning/src/input.cc @@ -11,12 +11,13 @@ using namespace std ; + /* *** Constructors *** */ -Input::Input() +Input::Input(): + medium(NULL) { - medium = NULL ; initialise_input_medium() ; initialise_log_media() ; } diff --git a/owlps-positioning/src/inputcsv.hh b/owlps-positioning/src/inputcsv.hh index 3c1b1e8..b8a9512 100644 --- a/owlps-positioning/src/inputcsv.hh +++ b/owlps-positioning/src/inputcsv.hh @@ -6,28 +6,22 @@ #include #include -/// Reads requests (Request) from a CSV file +/// Reads \link Request requests \endlink from a CSV file class InputCSV: public InputMedium { protected: - /// Name of the input CSV file std::string input_file_name ; - /// Stream corresponding to the input CSV file std::ifstream input_file ; /// Current line contents std::string current_line ; - /** @name Operations */ - //@{ /// Checks if the file is readable and closes it if not bool eof_close(void) ; - /// Reads the next line void read_next_line(void) ; - //@} public: - /// Constructs an InputCSV from a CSV input file name InputCSV(const std::string &filename) ; + ~InputCSV(void) ; /** @name Read accessors */ @@ -44,7 +38,6 @@ public: /** @name Operators */ //@{ - /// Cast to bool operator operator bool(void) const ; //@} } ; diff --git a/owlps-positioning/src/inputlogcsv.cc b/owlps-positioning/src/inputlogcsv.cc index 7b85a59..6bb04c9 100644 --- a/owlps-positioning/src/inputlogcsv.cc +++ b/owlps-positioning/src/inputlogcsv.cc @@ -19,10 +19,9 @@ using std::tr1::unordered_map ; * @param filename The name of the file to open. * @throw error_opening_input_file if the file cannot be opened. */ -InputLogCSV::InputLogCSV(const string &filename) +InputLogCSV::InputLogCSV(const string &filename): + log_file_name(filename) { - log_file_name = filename ; - log_file.open(log_file_name.c_str()) ; if (! log_file) throw error_opening_input_file(log_file_name) ; diff --git a/owlps-positioning/src/inputlogcsv.hh b/owlps-positioning/src/inputlogcsv.hh index 3356cab..88a814b 100644 --- a/owlps-positioning/src/inputlogcsv.hh +++ b/owlps-positioning/src/inputlogcsv.hh @@ -6,7 +6,7 @@ #include #include -/// Log Request to a CSV file +/// Log \link Request requests \endlink to a CSV file class InputLogCSV: public InputLogMedium { protected: diff --git a/owlps-positioning/src/inputlogmedium.hh b/owlps-positioning/src/inputlogmedium.hh index a086db4..d1a85e8 100644 --- a/owlps-positioning/src/inputlogmedium.hh +++ b/owlps-positioning/src/inputlogmedium.hh @@ -16,7 +16,7 @@ public: /** @name Operations */ //@{ virtual bool log_request(const Request &request) = 0 ; - //@} // End Operations + //@} } ; #endif // _OWLPS_POSITIONING_INPUTLOGMEDIUM_HH_ diff --git a/owlps-positioning/src/inputmedium.cc b/owlps-positioning/src/inputmedium.cc index 5eee7cb..cb62e20 100644 --- a/owlps-positioning/src/inputmedium.cc +++ b/owlps-positioning/src/inputmedium.cc @@ -6,10 +6,10 @@ /* *** Constructors *** */ -InputMedium::InputMedium() +InputMedium::InputMedium(): + current_line_nb(0) { current_request = new Request() ; - current_line_nb = 0 ; } @@ -22,6 +22,7 @@ InputMedium::~InputMedium() /* *** Operations *** */ + void InputMedium::current_request_to_calibration_request() { if (dynamic_cast(current_request) != NULL) diff --git a/owlps-positioning/src/inputmedium.hh b/owlps-positioning/src/inputmedium.hh index 6fc5afa..0bdc3cb 100644 --- a/owlps-positioning/src/inputmedium.hh +++ b/owlps-positioning/src/inputmedium.hh @@ -11,7 +11,6 @@ class InputMedium { protected: - /// The Request just read Request *current_request ; /// Number of the current line proceeded unsigned long current_line_nb ; @@ -24,10 +23,8 @@ public: /** @name Read accessors */ //@{ - /// #current_request read accessor const Request& get_current_request(void) const ; - /// #current_line_nb read accessor unsigned int get_current_line_nb(void) const ; /// Checks if the last request has been reached diff --git a/owlps-positioning/src/measurement.cc b/owlps-positioning/src/measurement.cc index 331a100..a10b2d4 100644 --- a/owlps-positioning/src/measurement.cc +++ b/owlps-positioning/src/measurement.cc @@ -8,32 +8,22 @@ using namespace std ; /* *** Constructors *** */ -Measurement::Measurement(const AccessPoint *_ap) +Measurement::Measurement(const AccessPoint *_ap): + ap(const_cast(_ap)), average_ss(0) { - ap = const_cast(_ap) ; ss_list.reserve(10) ; - average_ss = 0 ; } Measurement::Measurement(const AccessPoint *_ap, - const vector &_ss_list) + const vector &_ss_list): + ap(const_cast(_ap)), ss_list(_ss_list) { - ap = const_cast(_ap) ; - ss_list = _ss_list ; ss_list.reserve(10) ; update_average_ss() ; } -Measurement::Measurement(const Measurement &m) -{ - ap = m.ap ; - ss_list = m.ss_list ; - average_ss = m.average_ss ; -} - - /** * Note that values pointed by #ap are not deleted. @@ -49,7 +39,6 @@ Measurement::~Measurement() /** - * #average_ss is updated to include the new value. * @param ss_dbm The signal strength to add to #ss_list (in dBm). */ void Measurement::add_ss(const int &ss_dbm) @@ -65,10 +54,6 @@ void Measurement::add_ss(const int &ss_dbm) } -/** - * update_average_ss() is automatically called to recalculate - * #average_ss. - */ void Measurement::set_ss_list(const std::vector &_ss_list) { ss_list = _ss_list ; diff --git a/owlps-positioning/src/measurement.hh b/owlps-positioning/src/measurement.hh index 10e700b..58df437 100644 --- a/owlps-positioning/src/measurement.hh +++ b/owlps-positioning/src/measurement.hh @@ -26,37 +26,31 @@ protected: public: - /// Constructs a Measurement from an AccessPoint (or default constructor) Measurement(const AccessPoint *_ap = NULL) ; - /// \brief Constructs a Measurement from an AccessPoint and a list - /// of signal strengths + Measurement(const AccessPoint *_ap, const std::vector &_ss_list) ; - /// Copy constructor - Measurement(const Measurement &m) ; - ~Measurement(void) ; ///< Destructor + Measurement(const Measurement &source): + ap(source.ap), ss_list(source.ss_list), + average_ss(source.average_ss) {} + + ~Measurement(void) ; /** @name Read accessors */ //@{ - /// #ap read accessor AccessPoint* get_ap() const ; - /// #ss_list read accessor const std::vector& get_ss_list() const ; - /// #average_ss read accessor double get_average_ss() const ; //float get_ss_square_distance(const float &ss) const ; //@} /** @name Write accessors */ //@{ - /// #ap write accessor void set_ap(const AccessPoint *_ap) ; /// Adds a signal strength to #ss_list void add_ss(const int &ss_dbm) ; - /// #ss_list write accessor void set_ss_list(const std::vector &_ss_list) ; - /// Reinitialises the Measurement void clear(void) ; //@} @@ -65,7 +59,7 @@ public: const Measurement& operator=(const Measurement &m) ; bool operator==(const Measurement &m) const ; bool operator!=(const Measurement &m) const ; - operator bool(void) const ; ///< Cast to bool operator + operator bool(void) const ; //@} /// Displays a Measurement diff --git a/owlps-positioning/src/mobile.hh b/owlps-positioning/src/mobile.hh index faa4294..b235a4d 100644 --- a/owlps-positioning/src/mobile.hh +++ b/owlps-positioning/src/mobile.hh @@ -12,21 +12,19 @@ class Mobile: public WifiDevice { public: - /// Constructs a Mobile by defining all (or none) of its attributes - /** This constructor is just a mapping of WifiDevice(). */ Mobile(const std::string &_ip_addr = "", const std::string &_mac_addr = "", const float &_antenna_gain = MOBILE_DEFAULT_ANTENNA_GAIN, const float &_trx_power = WIFIDEVICE_DEFAULT_TRX_POWER): WifiDevice(_ip_addr, _mac_addr, _antenna_gain, _trx_power) {} - /// Constructs a Mobile from a WifiDevice + Mobile(const WifiDevice &wd): WifiDevice(wd) {} - /// Copy constructor + Mobile(const Mobile &m): WifiDevice(m) {} - ~Mobile(void) {} ///< Destructor (do nothing) + ~Mobile(void) {} /** @name Operators */ //@{ diff --git a/owlps-positioning/src/output.hh b/owlps-positioning/src/output.hh index e3a0b4b..6f694e7 100644 --- a/owlps-positioning/src/output.hh +++ b/owlps-positioning/src/output.hh @@ -13,7 +13,7 @@ protected: /// List of output media used std::vector output_media ; - /** @name Internal operations */ + /** @name Operations */ //@{ void initialise_output_media(void) ; void initialise_output_terminal(void) ; diff --git a/owlps-positioning/src/outputmedium.hh b/owlps-positioning/src/outputmedium.hh index 88354ce..e162afa 100644 --- a/owlps-positioning/src/outputmedium.hh +++ b/owlps-positioning/src/outputmedium.hh @@ -18,7 +18,7 @@ public: /** @name Operations */ //@{ virtual void write(const Result &result) = 0 ; - //@} // End Operations + //@} } ; #endif // _OWLPS_POSITIONING_OUTPUTMEDIUM_HH_ diff --git a/owlps-positioning/src/point3d.cc b/owlps-positioning/src/point3d.cc index 09fab5c..31f0899 100644 --- a/owlps-positioning/src/point3d.cc +++ b/owlps-positioning/src/point3d.cc @@ -3,33 +3,6 @@ #include -/* *** Constructors *** */ - - -Point3D::Point3D(const float &_x, const float &_y, const float &_z) -{ - x = _x ; - y = _y ; - z = _z ; -} - - -Point3D::Point3D(const Point3D &source) -{ - x = source.x ; - y = source.y ; - z = source.z ; -} - - -Point3D::Point3D(const float source[3]) -{ - x = source[0] ; - y = source[1] ; - z = source[2] ; -} - - /* *** Distance operations *** */ diff --git a/owlps-positioning/src/point3d.hh b/owlps-positioning/src/point3d.hh index 242c5c1..ef63bd9 100644 --- a/owlps-positioning/src/point3d.hh +++ b/owlps-positioning/src/point3d.hh @@ -13,28 +13,31 @@ protected: float z ; ///< Vertical coordinate public: - /// 3 float constructor or default constructor - Point3D(const float &_x = 0, const float &_y = 0, const float &_z = 0) ; - /// Copy constructor - Point3D(const Point3D &source) ; - /// 3-float array constructor - Point3D(const float source[3]) ; + Point3D(const float &_x = 0, const float &_y = 0, const float &_z = 0): + x(_x), y(_y), z(_z) {} - virtual ~Point3D(void) {} ///< Destructor (do nothing) + Point3D(const Point3D &source): + x(source.x), y(source.y), z(source.z) {} + + Point3D(const float source[3]): + x(source[0]), y(source[1]), z(source[2]) {} + + virtual ~Point3D(void) {} /** @name Read accessors */ //@{ - float get_x(void) const ; ///< #x read accessor - float get_y(void) const ; ///< #y read accessor - float get_z(void) const ; ///< #z read accessor + float get_x(void) const ; + float get_y(void) const ; + float get_z(void) const ; //@} /** @name Write accessors */ //@{ - void set_x(const float &_x) ; ///< #x write accessor - void set_y(const float &_y) ; ///< #y write accessor - void set_z(const float &_z) ; ///< #z write accessor - void set_coordinates(const Point3D &source) ; ///< Sets all coordinates + void set_x(const float &_x) ; + void set_y(const float &_y) ; + void set_z(const float &_z) ; + /// Sets all coordinates + void set_coordinates(const Point3D &source) ; //@} /** @name Distance operations */ diff --git a/owlps-positioning/src/referencepoint.hh b/owlps-positioning/src/referencepoint.hh index 4d10945..9fba926 100644 --- a/owlps-positioning/src/referencepoint.hh +++ b/owlps-positioning/src/referencepoint.hh @@ -18,20 +18,18 @@ protected: std::vector requests ; public: - /// 3-float constructor or default constructor ReferencePoint(const float &_x = 0, const float &_y = 0, const float &_z = 0): Point3D(_x, _y, _z) {} - /// Constructs a ReferencePoint from a Point3D + ReferencePoint(const Point3D &p): Point3D(p) {} - /// Copy constructor + ReferencePoint(const ReferencePoint &source): Point3D(source), requests(source.requests) {} - ~ReferencePoint(void) ; ///< Destructor + ~ReferencePoint(void) ; /** @name Read accessors */ //@{ - /// #requests read accessor const std::vector& get_requests(void) const ; //@} diff --git a/owlps-positioning/src/request.cc b/owlps-positioning/src/request.cc index 48f041b..bf828a9 100644 --- a/owlps-positioning/src/request.cc +++ b/owlps-positioning/src/request.cc @@ -9,40 +9,6 @@ using std::tr1::unordered_map ; /* *** Constructors *** */ -Request::Request(const unordered_map &_measurements) -{ - mobile = NULL ; - measurements = _measurements ; -} - - -Request::Request(const Timestamp &_timestamp, - const unordered_map &_measurements) -{ - mobile = NULL ; - timestamp = _timestamp ; - measurements = _measurements ; -} - - -Request::Request(const Mobile *_mobile, const Timestamp &_timestamp, - const unordered_map &_measurements) -{ - mobile = const_cast(_mobile) ; - timestamp = _timestamp ; - measurements = _measurements ; -} - - -Request::Request(const Request &source) -{ - mobile = source.mobile ; - timestamp = source.timestamp ; - measurements = source.measurements ; -} - - - /** * Note that the value pointed by #mobile is not deleted. */ @@ -56,6 +22,7 @@ Request::~Request() /* *** Write accessors *** */ +/// Reinitialises all attributes /** * - #mobile is NULLified, but the value it pointed to is not deleted. * - The fields of #timestamp are initialised to 0. diff --git a/owlps-positioning/src/request.hh b/owlps-positioning/src/request.hh index 532eb69..9ba836c 100644 --- a/owlps-positioning/src/request.hh +++ b/owlps-positioning/src/request.hh @@ -24,18 +24,28 @@ protected: std::tr1::unordered_map measurements ; public: - Request(const std::tr1::unordered_map + Request(const Mobile *_mobile = NULL, + const Timestamp &_timestamp = Timestamp(), + const std::tr1::unordered_map &_measurements = - std::tr1::unordered_map()) ; + std::tr1::unordered_map()): + mobile(const_cast(_mobile)), timestamp(_timestamp), + measurements(_measurements) {} + + Request(const std::tr1::unordered_map + &_measurements): + mobile(NULL), measurements(_measurements) {} + Request(const Timestamp &_timestamp, const std::tr1::unordered_map &_measurements = - std::tr1::unordered_map()) ; - Request(const Mobile *_mobile, const Timestamp &_timestamp, - const std::tr1::unordered_map - &_measurements = - std::tr1::unordered_map()) ; - Request(const Request &source) ; + std::tr1::unordered_map()): + mobile(NULL), timestamp(_timestamp), + measurements(_measurements) {} + + Request(const Request &source): + mobile(source.mobile), timestamp(source.timestamp), + measurements(source.measurements) {} virtual ~Request(void) ; @@ -53,7 +63,6 @@ public: void set_timestamp(const Timestamp &_timestamp) ; void set_measurements(const std::tr1::unordered_map &_measurements) ; - /// Reinitialises all attributes void clear(void) ; //@} @@ -62,7 +71,7 @@ public: 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 + operator bool(void) const ; //@} /// Displays a Request diff --git a/owlps-positioning/src/timestamp.hh b/owlps-positioning/src/timestamp.hh index 1dc1706..fc39205 100644 --- a/owlps-positioning/src/timestamp.hh +++ b/owlps-positioning/src/timestamp.hh @@ -7,8 +7,8 @@ /// Represents a timestamp with a millisecond precision /** - * This class boxes struct timespec from to integrate - * time manipulation functions. + * This class boxes struct timespec from ctime (time.h) to + * integrate time manipulation functions. */ class Timestamp { diff --git a/owlps-positioning/src/userinterface.cc b/owlps-positioning/src/userinterface.cc index cc45a97..dfb6642 100644 --- a/owlps-positioning/src/userinterface.cc +++ b/owlps-positioning/src/userinterface.cc @@ -20,10 +20,17 @@ namespace po = boost::program_options ; /* *** Constructors *** */ +/** + * \em argc and \em argv are (normally) the ones passed to the main() + * function. + * @param argc Number of arguments passed to the program. + * @param argv Values of the arguments. + */ UserInterface::UserInterface(const int argc, char **argv) { - cli_argument_count = argc ; + assert(argv) ; cli_argument_values = argv ; + cli_argument_count = argc ; config_file_name = DEFAULT_CONFIG_FILE_NAME ; try @@ -68,22 +75,25 @@ void UserInterface::fill_cli_options() ("help,h", "Print help") ("config-file,f", po::value(), "Alternative configuration file") - ; + ; // End of options } void UserInterface::fill_file_options() { file_options->add_options() + // Server options ("server.port,l", po::value() ->default_value(DEFAULT_LISTENING_PORT), "Server listening port.") + // Input options ("input.medium,I", po::value(), "Medium from which requests are read. Allowed: CSV.") ("input.csv-file,C", po::value(), "CSV file to use for input (when input.medium = CSV).") + // Log options ("log.medium,L", po::value< vector >()->composing(), "Medium to which the requests will be logged. You can specify \ @@ -91,16 +101,19 @@ this option more than once. Allowed: none, CSV. The `none` value \ completely disables logging.") ("log.csv-file", po::value(), "CSV file to use for logging (when log.medium = CSV).") + // Positioning algorithm options ("positioning.algorithm,A", po::value< vector >()->composing(), "Algorithms used to compute positions. You can specify \ this option more than once (but at least once). Allowed: Real.") + // Output options ("output.medium,O", po::value< vector >()->composing(), "Medium to which the results will be wrote. You can specify \ this option more than once. Allowed: Terminal. If this option is \ absent, results will be printed on the terminal.") - ; + + ; // End of options } diff --git a/owlps-positioning/src/waypoint.cc b/owlps-positioning/src/waypoint.cc index 6a5783b..7ebcd86 100644 --- a/owlps-positioning/src/waypoint.cc +++ b/owlps-positioning/src/waypoint.cc @@ -11,9 +11,13 @@ using namespace std ; /** * @param _b A pointer to the (first) Building to add to #buildings. * If it is NULL, #buildings will remain empty. - * @param p Coordinates of the Waypoint. + * @param _x X coordinate. + * @param _y Y coordinate. + * @param _z Z coordinate. */ -Waypoint::Waypoint(const Building *_b, const Point3D &p): Point3D(p) +Waypoint::Waypoint(const Building *_b, + const float &_x, const float &_y, const float &_z + ): Point3D(_x, _y, _z) { if (_b != NULL) buildings.push_back(const_cast(_b)) ; @@ -23,13 +27,9 @@ Waypoint::Waypoint(const Building *_b, const Point3D &p): Point3D(p) /** * @param _b A pointer to the (first) Building to add to #buildings. * If it is NULL, #buildings will remain empty. - * @param _x X coordinate. - * @param _y Y coordinate. - * @param _z Z coordinate. + * @param p Coordinates of the Waypoint. */ -Waypoint::Waypoint(const Building *_b, - const float &_x, const float &_y, const float &_z - ): Point3D(_x, _y, _z) +Waypoint::Waypoint(const Building *_b, const Point3D &p): Point3D(p) { if (_b != NULL) buildings.push_back(const_cast(_b)) ; diff --git a/owlps-positioning/src/waypoint.hh b/owlps-positioning/src/waypoint.hh index baf62ff..f726804 100644 --- a/owlps-positioning/src/waypoint.hh +++ b/owlps-positioning/src/waypoint.hh @@ -20,29 +20,24 @@ class Waypoint: public Point3D { protected: /// List of Building associated with the Waypoint - /** Note that \em buildings is a \em pointer list: only pointers - are stored, not values. */ std::vector buildings ; public: - /// Constructs a Waypoint from a Building pointer and a Point3D - Waypoint(const Building *_b, const Point3D &p) ; - /// \brief Constructs a Waypoint from a Building pointer and a - /// 3-float defined point (or default constructor) Waypoint(const Building *_b = NULL, const float &_x = 0, const float &_y = 0, const float &_z = 0) ; - /// Constructs a Waypoint from a Point3D + + Waypoint(const Building *_b, const Point3D &p) ; + Waypoint(const Point3D &p): Point3D(p) {} - /// Copy constructor + Waypoint(const Waypoint &wp): Point3D(wp), buildings(wp.buildings) {} - ~Waypoint(void) ; ///< Destructor + ~Waypoint(void) ; /** @name Read accessors */ //@{ /// #buildings's first element read accessor Building* get_1st_building(void) const ; - /// #buildings read accessor const std::vector& get_buildings(void) const ; //@} diff --git a/owlps-positioning/src/wifidevice.cc b/owlps-positioning/src/wifidevice.cc index 1d697f9..1b0ffd6 100644 --- a/owlps-positioning/src/wifidevice.cc +++ b/owlps-positioning/src/wifidevice.cc @@ -4,31 +4,6 @@ using namespace std ; -/* *** Constructors *** */ - - -WifiDevice::WifiDevice(const string &_ip_addr, - const string &_mac_addr, - const float _antenna_gain, - const float _trx_power) -{ - ip_addr = _ip_addr ; - mac_addr = _mac_addr ; - antenna_gain = _antenna_gain ; - trx_power = _trx_power ; -} - - -WifiDevice::WifiDevice(const WifiDevice &wd) -{ - ip_addr = wd.ip_addr ; - mac_addr = wd.mac_addr ; - antenna_gain = wd.antenna_gain ; - trx_power = wd.trx_power ; -} - - - /* *** Operators *** */ diff --git a/owlps-positioning/src/wifidevice.hh b/owlps-positioning/src/wifidevice.hh index 10b8401..3ee0b41 100644 --- a/owlps-positioning/src/wifidevice.hh +++ b/owlps-positioning/src/wifidevice.hh @@ -15,43 +15,38 @@ class WifiDevice { protected: - std::string ip_addr ; ///< IP address - std::string mac_addr ; ///< MAC address + std::string ip_addr ; + std::string mac_addr ; float antenna_gain ; ///< Antenna gain in dBi float trx_power ; ///< Transmit power in dBm public: - /// Constructs a WifiDevice by defining all (or none) of its attributes WifiDevice(const std::string &_ip_addr = "", const std::string &_mac_addr = "", const float _antenna_gain = WIFIDEVICE_DEFAULT_ANTENNA_GAIN, - const float _trx_power = WIFIDEVICE_DEFAULT_TRX_POWER) ; - /// Copy constructor - WifiDevice(const WifiDevice &wd) ; + const float _trx_power = WIFIDEVICE_DEFAULT_TRX_POWER): + ip_addr(_ip_addr), mac_addr(_mac_addr), + antenna_gain(_antenna_gain), trx_power(_trx_power) {} - virtual ~WifiDevice(void) {} ///< Destructor (do nothing) + WifiDevice(const WifiDevice &source): + ip_addr(source.ip_addr), mac_addr(source.mac_addr), + antenna_gain(source.antenna_gain), trx_power(source.trx_power) {} + + virtual ~WifiDevice(void) {} /** @name Read accessors */ //@{ - /// #ip_addr read accessor const std::string& get_ip_addr(void) const ; - /// #mac_addr read accessor const std::string& get_mac_addr(void) const ; - /// #antenna_gain read accessor float get_antenna_gain(void) const ; - /// #trx_power read accessor float get_trx_power(void) const ; //@} /** @name Write accessors */ //@{ - /// #ip_addr write accessor void set_ip_addr(const std::string &_ip_addr) ; - /// #mac_addr write accessor void set_mac_addr(const std::string &_mac_addr) ; - /// #antenna_gain write accessor void set_antenna_gain(float _antenna_gain) ; - /// #trx_power write accessor void set_trx_power(float _trx_power) ; //@}