NuTo
Numerics Tool
Event.h
Go to the documentation of this file.
1 /*
2  * EventBase.h
3  *
4  * Created on: 21 Jan 2014
5  * Author: ttitsche
6  */
7 
8 #pragma once
9 
10 
11 #include <boost/ptr_container/ptr_set.hpp>
12 #include <vector>
13 
14 
15 namespace NuTo
16 {
17 class CollidableBase;
18 class EventListHandler;
19 
20 
22 class Event
23 {
24 public:
25  typedef std::vector<Event*> LocalEvents;
26 
28  enum EventType
29  {
33  };
34 
36  static const double EVENTNULL;
37 
42  Event(double rTime, CollidableBase* rFirst, CollidableBase* rSecond, int rType);
43 
45  Event(const Event& rEvent) = default;
46 
47 #ifndef SWIG
48  Event& operator=(const NuTo::Event&) = default;
49  Event(Event&& rEvent) = default;
50  Event& operator=(Event&&) = default;
51 #endif
52 
55  bool operator<(const Event& rOther) const;
56 
58  bool operator==(Event const& rRhs) const;
59 
61  bool operator!=(Event const& rRhs) const;
62 
63 
66  ~Event();
67 
70  double GetTime() const;
71 
76  void AddNewEvents(EventListHandler& rEvents) const;
77 
80  void EraseOldEvents(EventListHandler& rEvents) const;
81 
83  void PerformCollision() const;
84 
86  void AddLocalEvent();
87 
89  int GetType() const;
90 
91 protected:
94 
97 
98 private:
100  double mTime;
101 
103  int mType;
104 
105 #ifndef SWIG
106  friend std::ostream& operator<<(std::ostream& rOutStream, const Event& rEvent);
107 #endif
108 
111  void Print(std::ostream& rOutStream) const;
112 };
113 
114 } /* namespace NuTo */
~Event()
destructor removes itself (this) from the local event lists of both collidables
Definition: Event.cpp:25
static const double EVENTNULL
identifier for null events
Definition: Event.h:36
CollidableBase * mFirst
first CollidableBase involved
Definition: Event.h:93
double GetTime() const
getter for mTime
Definition: Event.cpp:37
void EraseOldEvents(EventListHandler &rEvents) const
removes all events in the local event lists of rEvent
Definition: Event.cpp:58
bool operator<(const Event &rOther) const
important operator for the event list sorting sort priority: time >> collidables
Definition: Event.cpp:73
int GetType() const
getter for type
Definition: Event.cpp:124
Definition: Event.h:31
Definition: Event.h:32
Event & operator=(const NuTo::Event &)=default
class for storing events
Definition: Event.h:22
void AddNewEvents(EventListHandler &rEvents) const
creates new events for mFirst and mSecond (–> automatically added to local event lists...
Definition: Event.cpp:49
bool operator!=(Event const &rRhs) const
determines, whether two events are unequal
Definition: Event.cpp:113
EventType
statistics
Definition: Event.h:28
Base class for all collidables.
Definition: CollidableBase.h:22
class for event list operations
Definition: EventListHandler.h:23
Definition: Event.h:30
bool operator==(Event const &rRhs) const
determines, whether two events are equal
Definition: Event.cpp:97
void PerformCollision() const
performs the collision of mFirst vs. mSecond
Definition: Event.cpp:42
friend std::ostream & operator<<(std::ostream &rOutStream, const Event &rEvent)
Definition: Event.cpp:140
Definition: Exception.h:6
Event(double rTime, CollidableBase *rFirst, CollidableBase *rSecond, int rType)
constructor, initialized with the two CollidableBase objects involved in this collision ...
Definition: Event.cpp:17
CollidableBase * mSecond
second CollidableBase involved
Definition: Event.h:96
std::vector< Event * > LocalEvents
Definition: Event.h:25
void AddLocalEvent()
adds itself (this) to the local event lists of both collidables
Definition: Event.cpp:118