00001
00009 #ifndef VRG3DEVENT_H
00010 #define VRG3DEVENT_H
00011
00012 #include <G3D/G3DAll.h>
00013
00014 namespace VRG3D {
00015
00016 class Event;
00017 typedef ReferenceCountedPointer<class Event> EventRef;
00018
00021 EventRef createCopyOfEvent(EventRef e);
00022
00030 class Event : public ReferenceCountedObject
00031 {
00032 public:
00033
00034 enum EventType {
00035 EVENTTYPE_STANDARD = 0,
00036 EVENTTYPE_1D = 1,
00037 EVENTTYPE_2D = 2,
00038 EVENTTYPE_3D = 3,
00039 EVENTTYPE_COORDINATEFRAME = 4,
00040 EVENTTYPE_MSG = 5
00041 };
00042
00043 Event(const std::string &name) {
00044 _name = name;
00045 _type = EVENTTYPE_STANDARD;
00046 }
00047
00048 Event(const std::string &name, const double data) {
00049 _name = name;
00050 _data1D = data;
00051 _type = EVENTTYPE_1D;
00052 }
00053
00054 Event(const std::string &name, const Vector2 &data) {
00055 _name = name;
00056 _data2D = data;
00057 _type = EVENTTYPE_2D;
00058 }
00059
00060 Event(const std::string &name, const Vector3 &data) {
00061 _name = name;
00062 _data3D = data;
00063 _type = EVENTTYPE_3D;
00064 }
00065
00066 Event(const std::string &name, const CoordinateFrame &data) {
00067 _name = name;
00068 _dataCF = data;
00069 _type = EVENTTYPE_COORDINATEFRAME;
00070 }
00071
00072 Event(const std::string &name, const std::string &data) {
00073 _name = name;
00074 _dataMsg = data;
00075 _type = EVENTTYPE_MSG;
00076 }
00077
00078 virtual ~Event() {}
00079
00080
00081 std::string getName() const { return _name; }
00082 EventType getType() const { return _type; }
00083
00084 double get1DData();
00085 Vector2 get2DData();
00086 Vector3 get3DData();
00087 CoordinateFrame getCoordinateFrameData();
00088 std::string getMsgData();
00089
00090 std::string toString();
00091
00092 void rename(const std::string &newname) { _name = newname; }
00093
00094 void serialize(BinaryOutput &b) const;
00095 void deserialize(BinaryInput &b);
00096
00097 protected:
00098 std::string _name;
00099 EventType _type;
00100 double _data1D;
00101 Vector2 _data2D;
00102 Vector3 _data3D;
00103 CoordinateFrame _dataCF;
00104 std::string _dataMsg;
00105 };
00106
00107
00108 }
00109
00110 #endif
00111