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

Last change on this file since 14033 was 14002, checked in by tbretz, 12 years ago
Replaced some 'const char*' with a const-refernce to a std::string
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 /// Constructs an event as a combination of an EventImp and a DimCommand
20 Event(const std::string &name, const std::string &fmt="");
21 /// Copy constructor
22 Event(const EventImp &imp);
23 Event(const EventImp &imp, const char *ptr, 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 size_t GetSize() const { return fData.size(); }
37
38 /// Return reference to a time stamp
39 Time GetTime() const { return fTime; }
40 int GetQoS() const { return fQoS; }
41
42
43 void SetTime() { fTime = Time(); }
44 void SetData(const std::vector<char> &data) { fData = data; }
45 void SetData(const void *ptr, size_t siz) {
46 const char *c = reinterpret_cast<const char*>(ptr);
47 fData = std::vector<char>(c, c+siz); }
48
49 void SetInt(int i) { SetData(&i, sizeof(i)); }
50 void SetFloat(float f) { SetData(&f, sizeof(f)); }
51 void SetDouble(float d) { SetData(&d, sizeof(d)); }
52 void SetShort(short s) { SetData(&s, sizeof(s)); }
53 void SetText(const char *txt) { SetData(txt, strlen(txt)+1); }
54 void SetString(const std::string &str) { SetData(str.c_str(), str.length()+1); }
55};
56
57#endif
Note: See TracBrowser for help on using the repository browser.