source: trunk/FACT++/src/Event.h@ 12905

Last change on this file since 12905 was 10299, checked in by tbretz, 14 years ago
Implemented event description into all kind of events.
File size: 2.0 KB
Line 
1#ifndef FACT_Event
2#define FACT_Event
3
4#include "EventImp.h"
5
6class Event : public EventImp
7{
8private:
9 std::string fName; /// A name associated with the event
10 std::string fFormat; /// A string describing the format of the data
11 std::string fDescription; /// A human readable description of the event
12
13 std::vector<char> fData; /// Data associated with this event
14
15 Time fTime; /// Time stamp
16
17public:
18 /// Constructs an event as a combination of an EventImp and a DimCommand
19 Event(int targetstate, const char *name="", const char *fmt="");
20 Event(const std::string &name, const char *fmt="");
21 /// Copy constructor
22 Event(const EventImp &imp);
23 Event(const EventImp &imp, const char *name, size_t siz);
24
25 void SetDescription(const std::string &str) { fDescription=str; }
26 std::string GetDescription() const { return fDescription; }
27
28 /// Return the stored name of the event
29 std::string GetName() const { return fName; }
30 /// Return the stored format of the data
31 std::string GetFormat() const { return fFormat; }
32
33 /// Return a pointer to the data region
34 const void *GetData() const { return &*fData.begin(); }
35 /// Return the size of the data
36 int GetSize() const { return fData.size(); }
37
38 /// Return reference to a time stamp
39 Time GetTime() const { return fTime; }
40
41
42 void SetTime() { fTime = Time(); }
43 void SetData(const std::vector<char> &data) { fData = data; }
44 void SetData(const void *ptr, size_t siz) {
45 const char *c = reinterpret_cast<const char*>(ptr);
46 fData = std::vector<char>(c, c+siz); }
47
48 void SetInt(int i) { SetData(&i, sizeof(i)); }
49 void SetFloat(float f) { SetData(&f, sizeof(f)); }
50 void SetDouble(float d) { SetData(&d, sizeof(d)); }
51 void SetShort(short s) { SetData(&s, sizeof(s)); }
52 void SetText(const char *txt) { SetData(txt, strlen(txt)+1); }
53 void SetString(const std::string &str) { SetData(str.c_str(), str.length()+1); }
54
55};
56
57#endif
Note: See TracBrowser for help on using the repository browser.