p2d.hpp
Go to the documentation of this file.
00001 /*
00002 **    TP 4ETI CPE Lyon
00003 **    Copyright (C) 2012 Damien Rohmer
00004 **
00005 **    This program is free software: you can redistribute it and/or modify
00006 **    it under the terms of the GNU General Public License as published by
00007 **    the Free Software Foundation, either version 3 of the License, or
00008 **    (at your option) any later version.
00009 **
00010 **   This program is distributed in the hope that it will be useful,
00011 **    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 **    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 **    GNU General Public License for more details.
00014 **
00015 **    You should have received a copy of the GNU General Public License
00016 **    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 
00021 
00022 #ifndef P2D_HPP
00023 #define P2D_HPP
00024 
00025 #include <iostream>
00026 #include <exception_cpe.hpp>
00027 
00028 namespace cpe
00029 {
00031     class p2d
00032     {
00033     public:
00034 
00035         // ********************************************* //
00036         // ********************************************* //
00037         //  CONSTRUCTOR
00038         // ********************************************* //
00039         // ********************************************* //
00040 
00042         p2d();
00047         p2d(const int& x0,const int& y0);
00048 
00049         // ********************************************* //
00050         // ********************************************* //
00051         //  Coordinate access
00052         // ********************************************* //
00053         // ********************************************* //
00054 
00056         void set(const int& x,const int& y);
00057 
00059         const int& x() const;
00061         int& x();
00063         const int& y() const;
00065         int& y();
00066 
00067 
00068         // ********************************************* //
00069         // ********************************************* //
00070         //  Operators
00071         // ********************************************* //
00072         // ********************************************* //
00073 
00075         friend p2d operator+(const p2d& u1,const p2d& u2);
00077         friend p2d operator-(const p2d& u1,const p2d& u2);
00079         p2d& operator+=(const p2d& u);
00081         p2d& operator-=(const p2d& u);
00082 
00083         // ********************************************* //
00084         // ********************************************* //
00085         //  I/O
00086         // ********************************************* //
00087         // ********************************************* //
00088 
00090         friend std::ostream& operator<<(std::ostream& stream,const p2d& u);
00091 
00092 
00093     private:
00094 
00095         // ********************************************* //
00096         // ********************************************* //
00097         //  Internal storage
00098         // ********************************************* //
00099         // ********************************************* //
00100 
00102         int internal_x;
00104         int internal_y;
00105 
00106     };
00107 
00109     class exception_p2d : public exception_cpe
00110     {
00111     public:
00113         exception_p2d():exception_cpe(){}
00115         exception_p2d(const std::string& msg,const std::string& file,const std::string& caller,const int& line):exception_cpe(msg,file,caller,line){}
00116     };
00117 }
00118 
00119 
00120 #endif