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

Last change on this file since 14098 was 14094, checked in by tbretz, 12 years ago
Added default constructor.
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 int fQoS; /// Quality of service
17
18public:
19 Event() { }
20 /// Constructs an event as a combination of an EventImp and a DimCommand
21 Event(const std::string &name, const std::string &fmt="");
22 /// Copy constructor
23 Event(const EventImp &imp);
24 Event(const EventImp &imp, const char *ptr, size_t siz);
25
26 void SetDescription(const std::string &str) { fDescription=str; }
27 std::string GetDescription() const { return fDescription; }
28
29 /// Return the stored name of the event
30 std::string GetName() const { return fName; }
31 /// Return the stored format of the data
32 std::string GetFormat() const { return fFormat; }
33
34 /// Return a pointer to the data region
35 const void *GetData() const { return &*fData.begin(); }
36 /// Return the size of the data
37 size_t GetSize() const { return fData.size(); }
38
39 /// Return reference to a time stamp
40 Time GetTime() const { return fTime; }
41 int GetQoS() const { return fQoS; }
42
43
44 void SetTime() { fTime = Time(); }
45 void SetData(const std::vector<char> &data) { fData = data; }
46 void SetData(const void *ptr, size_t siz) {
47 const char *c = reinterpret_cast<const char*>(ptr);
48 fData = std::vector<char>(c, c+siz); }
49
50 void SetInt(int i) { SetData(&i, sizeof(i)); }
51 void SetFloat(float f) { SetData(&f, sizeof(f)); }
52 void SetDouble(float d) { SetData(&d, sizeof(d)); }
53 void SetShort(short s) { SetData(&s, sizeof(s)); }
54 void SetText(const char *txt) { SetData(txt, strlen(txt)+1); }
55 void SetString(const std::string &str) { SetData(str.c_str(), str.length()+1); }
56};
57
58#endif
Note: See TracBrowser for help on using the repository browser.