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

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