• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef GPS_POSITION_HPP
2 #define GPS_POSITION_HPP
3 
4 // Copyright Matthias Troyer
5 // 2005. Distributed under the Boost Software License, Version
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 
9 #include <boost/mpi/datatype_fwd.hpp>
10 #include <boost/mpl/and.hpp>
11 #include <boost/serialization/export.hpp>
12 #include <boost/shared_ptr.hpp>
13 #include <iostream>
14 
15 class gps_position
16 {
17 private:
18     friend class boost::serialization::access;
19     // When the class Archive corresponds to an output archive, the
20     // & operator is defined similar to <<.  Likewise, when the class Archive
21     // is a type of input archive the & operator is defined similar to >>.
22     template<class Archive>
serialize(Archive & ar,const unsigned int version)23     void serialize(Archive & ar, const unsigned int version)
24     {
25         ar & degrees & minutes & seconds;
26     }
27     int degrees;
28     int minutes;
29     float seconds;
30 public:
gps_position()31     gps_position(){};
gps_position(int d,int m,float s)32     gps_position(int d, int m, float s) :
33         degrees(d), minutes(m), seconds(s)
34     {}
35 
36   friend std::ostream& operator<<(std::ostream& out, const gps_position& g);
37 
operator ==(const gps_position & x,const gps_position & y)38   friend bool operator==(const gps_position& x, const gps_position& y)
39   {
40     return (x.degrees == y.degrees
41             && x.minutes == y.minutes
42             && x.seconds == y.seconds);
43   }
44 
operator !=(const gps_position & x,const gps_position & y)45   inline friend bool operator!=(const gps_position& x, const gps_position& y)
46   {
47     return !(x == y);
48   }
49 };
50 
51 inline
operator <<(std::ostream & out,const gps_position & g)52 std::ostream& operator<<(std::ostream& out,  const gps_position& g) {
53   out << "gps{" << g.degrees << 'd' << g.minutes << 'm' << g.seconds << "s}";
54   return out;
55 }
56 
57 namespace boost { namespace mpi {
58 
59   template <>
60   struct is_mpi_datatype<gps_position>
61    : public mpl::and_
62        <
63                  is_mpi_datatype<int>,
64                  is_mpi_datatype<float>
65            >
66   {};
67 
68 } }
69 #endif
70