m2etis  0.4
Position.h
Go to the documentation of this file.
1 /*
2  Copyright (2016) Michael Baer, Daniel Bonrath, All rights reserved.
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15  */
16 
22 #ifndef __M2ETIS_PUBSUB_FILTER_POSITIONEVENT_H__
23 #define __M2ETIS_PUBSUB_FILTER_POSITIONEVENT_H__
24 
25 #include <iterator>
26 
27 #include "boost/serialization/export.hpp"
28 #include "boost/serialization/base_object.hpp"
29 #include "boost/serialization/list.hpp"
30 #include "boost/serialization/map.hpp"
31 #include "boost/serialization/variant.hpp"
32 #include "boost/serialization/shared_ptr.hpp"
33 #include "boost/serialization/vector.hpp"
34 
35 namespace m2etis {
36 namespace pubsub {
37 namespace filter {
38 
39  class Position {
40  public:
41  bool operator==(const Position & rhs) const {
42  return (rhs.x == this->x && rhs.y == this->y && rhs.region == this->region);
43  }
44 
45  Position(const std::vector<unsigned char> & payload, int _x = 0, int _y = 0) : region(std::string(payload.begin(), payload.end())), x(_x), y(_y) {}
46 
47  Position(const std::string & payload, int _x = 0, int _y = 0) : region(payload), x(_x), y(_y) {}
48 
49  Position() {}
50 
51  std::string toStr() const {
52  return region + ";" + std::to_string(x) + ";" + std::to_string(y);
53  }
54 
55  std::string get_region () const { return region; }
56  int get_x () const { return x; }
57  int get_y () const { return y; }
58 
59  std::string issuer = "";
60  std::string region = "";
61  int x = 0;
62  int y = 0;
63  std::string direction = "";
64  float velocity = 0;
65  float acceleration = 0;
66 
67  private:
69  template<class Archive>
70  void serialize(Archive & ar, const unsigned int) {
71  ar & issuer;
72  ar & region;
73  ar & x;
74  ar & y;
75  ar & direction;
76  ar & velocity;
77  ar & acceleration;
78  }
79  }; // Class Position
80 
81  class Book {
82  // example class in Bittner phd
83  public:
84  Book(const std::string & title, double price, const std::string & condition, int ending) : title_(title), price_(price), condition_(condition), ending_(ending) {}
85 
86  std::string title_;
87  double price_;
88  std::string condition_;
89  int ending_;
90  }; // class Book
91 
92 } /* namespace filter */
93 } /* namespace pubsub */
94 } /* namespace m2etis */
95 
96 #endif /* __M2ETIS_PUBSUB_FILTER_POSITIONEVENT_H__ */
97 
std::string toStr() const
Definition: Position.h:51
std::string get_region() const
Definition: Position.h:55
STL namespace.
friend class boost::serialization::access
Definition: Position.h:68
Position(const std::string &payload, int _x=0, int _y=0)
Definition: Position.h:47
Position(const std::vector< unsigned char > &payload, int _x=0, int _y=0)
Definition: Position.h:45
bool operator==(const Position &rhs) const
Definition: Position.h:41
Book(const std::string &title, double price, const std::string &condition, int ending)
Definition: Position.h:84