Mercurial > malikania
view libclient/malikania/client/line.hpp @ 158:4b292c20124c
Misc: update copyrights
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 09 Jan 2018 13:15:07 +0100 |
parents | 119bcc5a727e |
children |
line wrap: on
line source
/* * line.hpp -- line description * * Copyright (c) 2013-2018 David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef MALIKANIA_CLIENT_LINE_HPP #define MALIKANIA_CLIENT_LINE_HPP /** * \file line.hpp * \brief line description. */ namespace mlk { namespace client { /** * \brief line description. * * A line has an origin (x, y) and a destination (x, y). */ class line { private: int m_x1; int m_y1; int m_x2; int m_y2; public: /** * Construct a line. * * \param x1 the first x * \param y1 the first y * \param x2 the second x * \param y2 the second y */ inline line(int x1 = 0, int y1 = 0, int x2 = 0, int y2 = 0) noexcept : m_x1(x1) , m_y1(y1) , m_x2(x2) , m_y2(y2) { } /** * Get the first x. * * \return the x1 */ inline int x1() const noexcept { return m_x1; } /** * Get the first y. * * \return the y1 */ inline int y1() const noexcept { return m_y1; } /** * Get the second x. * * \return the x2 */ inline int x2() const noexcept { return m_x2; } /** * Get the second y. * * \return the y2 */ inline int y2() const noexcept { return m_y2; } }; /** * Compare equality. * * \param l1 the first line * \param l2 the second line * \return true if they equal */ inline bool operator==(const line& l1, const line& l2) noexcept { return l1.x1() == l2.x1() && l1.x2() == l2.x2() && l1.y1() == l2.y1() && l1.y2() == l2.y2(); } /** * Compare equality. * * \param l1 the first line * \param l2 the second line * \return false if they equal */ inline bool operator!=(const line& l1, const line& l2) noexcept { return !(l1 == l2); } } // !client } // !mlk #endif // !MALIKANIA_CLIENT_LINE_HPP