MinVR  0.9.0
A multi-platform virtual reality library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Event.H
Go to the documentation of this file.
1 //========================================================================
2 // MinVR
3 // Platform: Any
4 // API version: 1.0
5 //------------------------------------------------------------------------
6 // The MIT License (MIT)
7 //
8 // Copyright (c) 2013 Regents of the University of Minnesota
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy of
11 // this software and associated documentation files (the "Software"), to deal in
12 // the Software without restriction, including without limitation the rights to
13 // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14 // the Software, and to permit persons to whom the Software is furnished to do so,
15 // subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included in all
18 // copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23 // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 //========================================================================
27 
28 #ifndef MINVREVENT_H
29 #define MINVREVENT_H
30 
31 #include <glm/glm.hpp>
32 #include <boost/shared_ptr.hpp>
33 #include <boost/date_time/posix_time/posix_time.hpp>
34 #include "MVRCore/StringUtils.H"
35 
36 namespace MinVR {
37 
38 class AbstractWindow;
39 typedef boost::shared_ptr<class AbstractWindow> WindowRef;
40 
41 class Event;
42 typedef boost::shared_ptr<class Event> EventRef;
43 
47 
55 class Event
56 {
57 public:
58 
59  enum EventType {
67  };
68 
69  Event(const std::string &name, const WindowRef window = nullptr, const int id = -1);
70  Event(const std::string &name, const double data, const WindowRef window = nullptr, const int id = -1);
71  Event(const std::string &name, const glm::vec2 &data, const WindowRef window = nullptr, const int id = -1);
72  Event(const std::string &name, const glm::vec3 &data, const WindowRef window = nullptr, const int id = -1);
73  Event(const std::string &name, const glm::vec4 &data, const WindowRef window = nullptr, const int id = -1);
74  Event(const std::string &name, const glm::mat4 &data, const WindowRef window = nullptr, const int id = -1);
75  Event(const std::string &name, const std::string &data, const WindowRef window = nullptr, const int id = -1);
76  virtual ~Event();
77 
78  std::string getName() const;
79  EventType getType() const;
80  int getId() const;
81  WindowRef getWindow() const;
82 
83  double get1DData();
84  glm::vec2 get2DData();
85  glm::vec3 get3DData();
86  glm::vec4 get4DData();
87  glm::mat4 getCoordinateFrameData();
88  std::string getMsgData();
89  boost::posix_time::ptime getTimestamp();
90 
91  bool operator<(Event other) const;
92  bool operator<(EventRef otherRef) const;
93 
94  std::string toString();
95 
96  void rename(const std::string &newname);
97 
98 protected:
99  std::string _name;
100  int _id;
102  boost::posix_time::ptime _timestamp;
104  double _data1D;
105  glm::vec2 _data2D;
106  glm::vec3 _data3D;
107  glm::vec4 _data4D;
108  glm::mat4 _dataCF;
109  std::string _dataMsg;
110 };
111 
112 
113 } // end namespace
114 
115 #endif
116