libSDL2pp/SDL2pp/Point.hh
2015-01-19 00:47:25 +03:00

239 lines
7.3 KiB
C++

/*
libSDL2pp - C++11 bindings/wrapper for SDL2
Copyright (C) 2013-2015 Dmitry Marakasov <amdmi3@amdmi3.ru>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL2PP_POINT_HH
#define SDL2PP_POINT_HH
#include <SDL2/SDL_rect.h>
namespace SDL2pp {
////////////////////////////////////////////////////////////
/// \brief 2D point
///
/// \ingroup geometry
///
/// \headerfile SDL2pp/Point.hh
///
/// This class is public-derived from SDL_Point structure,
/// may generally used as it if passed via pointer or
/// reference. It also supports direct access to x and y
/// members.
///
/// \see http://wiki.libsdl.org/SDL_Point
///
////////////////////////////////////////////////////////////
class Point : public SDL_Point {
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// Creates a Point(0, 0)
///
////////////////////////////////////////////////////////////
Point();
////////////////////////////////////////////////////////////
/// \brief Construct a point from existing SDL_Point
///
/// \param[in] point Existing SDL_Point
///
////////////////////////////////////////////////////////////
Point(const SDL_Point& point);
////////////////////////////////////////////////////////////
/// \brief Construct the point from given coordinates
///
/// \param[in] nx X coordinate
/// \param[in] ny Y coordinate
///
////////////////////////////////////////////////////////////
Point(int nx, int ny);
////////////////////////////////////////////////////////////
/// \brief Copy constructor
///
////////////////////////////////////////////////////////////
Point(const Point&) noexcept = default;
////////////////////////////////////////////////////////////
/// \brief Move constructor
///
////////////////////////////////////////////////////////////
Point(Point&&) noexcept = default;
////////////////////////////////////////////////////////////
/// \brief Assignment operator
///
/// \returns Reference to self
///
////////////////////////////////////////////////////////////
Point& operator=(const Point&) noexcept = default;
////////////////////////////////////////////////////////////
/// \brief Move assignment operator
///
/// \returns Reference to self
///
////////////////////////////////////////////////////////////
Point& operator=(Point&&) noexcept = default;
////////////////////////////////////////////////////////////
/// \brief Equality operator
///
/// \param[in] other Point to compare to
///
/// \returns True if two points are identical
///
////////////////////////////////////////////////////////////
bool operator==(const Point& other) const;
////////////////////////////////////////////////////////////
/// \brief Inequality operator
///
/// \param[in] other Point to compare to
///
/// \returns True if two points are not identical
///
////////////////////////////////////////////////////////////
bool operator!=(const Point& other) const;
////////////////////////////////////////////////////////////
/// \brief Get X coordinate of the point
///
/// \returns X coordinate of the point
///
////////////////////////////////////////////////////////////
int GetX() const;
////////////////////////////////////////////////////////////
/// \brief Set X coordinate of the point
///
/// \param[in] nx New X coordinate value
///
/// \returns Reference to self
///
////////////////////////////////////////////////////////////
Point& SetX(int nx);
////////////////////////////////////////////////////////////
/// \brief Get Y coordinate of the point
///
/// \returns Y coordinate of the point
///
////////////////////////////////////////////////////////////
int GetY() const;
////////////////////////////////////////////////////////////
/// \brief Set Y coordinate of the point
///
/// \param[in] ny New Y coordinate value
///
/// \returns Reference to self
///
////////////////////////////////////////////////////////////
Point& SetY(int ny);
////////////////////////////////////////////////////////////
/// \brief Get point's memberwise addition with another point
///
/// \param[in] other Point to add
///
/// \returns New Point representing memberwise addition with another point
///
////////////////////////////////////////////////////////////
Point operator+(const Point& other) const;
////////////////////////////////////////////////////////////
/// \brief Get point's memberwise subtraction with another point
///
/// \param[in] other Point to subtract
///
/// \returns New Point representing memberwise subtraction of another point
///
////////////////////////////////////////////////////////////
Point operator-(const Point& other) const;
////////////////////////////////////////////////////////////
/// \brief Get point's memberwise division by an integer
///
/// \param[in] value Divisor
///
/// \returns New Point representing memberwise division of point by and integer
///
////////////////////////////////////////////////////////////
Point operator/(int value) const;
////////////////////////////////////////////////////////////
/// \brief Get point's memberwise multiplication by an integer
///
/// \param[in] value Multiplier
///
/// \returns New Point representing memberwise multiplication of point by an integer
///
////////////////////////////////////////////////////////////
Point operator*(int value) const;
////////////////////////////////////////////////////////////
/// \brief Memberwise add another point
///
/// \param[in] other Point to add to the current one
///
/// \returns Reference to self
///
////////////////////////////////////////////////////////////
Point& operator+=(const Point& other);
////////////////////////////////////////////////////////////
/// \brief Memberwise subtract another point
///
/// \param[in] other Point to subtract from the current one
///
/// \returns Reference to self
///
////////////////////////////////////////////////////////////
Point& operator-=(const Point& other);
////////////////////////////////////////////////////////////
/// \brief Memberwise divide by an integer
///
/// \param[in] value Divisor
///
/// \returns Reference to self
///
////////////////////////////////////////////////////////////
Point& operator/=(int value);
////////////////////////////////////////////////////////////
/// \brief Memberwise multiply by an integer
///
/// \param[in] value Multiplier
///
/// \returns Reference to self
///
////////////////////////////////////////////////////////////
Point& operator*=(int value);
};
}
#endif