FACT++  1.0
Event.h
Go to the documentation of this file.
1 #ifndef FACT_Event
2 #define FACT_Event
3 
4 #include "EventImp.h"
5 
6 class Event : public EventImp
7 {
8 private:
9  std::string fName;
10  std::string fFormat;
11  std::string fDescription;
12 
13  std::vector<char> fData;
14 
16  int fQoS;
17  bool fEmpty;
18 
19 public:
20  Event() : fQoS(0), fEmpty(true) { }
22  Event(const std::string &name, const std::string &fmt="");
24  Event(const EventImp &imp);
25  Event(const EventImp &imp, const char *ptr, size_t siz);
26 
27  void SetDescription(const std::string &str) { fDescription=str; }
28  std::string GetDescription() const { return fDescription; }
29 
31  std::string GetName() const { return fName; }
33  std::string GetFormat() const { return fFormat; }
34 
36  const void *GetData() const { return &*fData.begin(); }
38  size_t GetSize() const { return fData.size(); }
39 
41  Time GetTime() const { return fTime; }
43  int GetQoS() const { return fQoS; }
45  bool IsEmpty() const { return fEmpty; }
46 
47  void SetTime() { fTime = Time(); }
48  void SetData(const std::vector<char> &data) { fData = data; }
49  void SetData(const void *ptr, size_t siz) {
50  const char *c = reinterpret_cast<const char*>(ptr);
51  fData = std::vector<char>(c, c+siz); }
52 
53  void SetInt(int i) { SetData(&i, sizeof(i)); }
54  void SetFloat(float f) { SetData(&f, sizeof(f)); }
55  void SetDouble(float d) { SetData(&d, sizeof(d)); }
56  void SetShort(short s) { SetData(&s, sizeof(s)); }
57  void SetText(const char *txt) { SetData(txt, strlen(txt)+1); }
58  void SetString(const std::string &str) { SetData(str.c_str(), str.length()+1); }
59 };
60 
61 #endif
bool fEmpty
Quality of service.
Definition: Event.h:17
void SetShort(short s)
Definition: Event.h:56
A general base-class describing events issues in a state machine.
Definition: EventImp.h:11
int i
Definition: db_dim_client.c:21
std::string GetFormat() const
Return the stored format of the data.
Definition: Event.h:33
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
char str[80]
Definition: test_client.c:7
std::vector< char > fData
A human readable description of the event.
Definition: Event.h:13
void SetDouble(float d)
Definition: Event.h:55
int GetQoS() const
Return Quality of Service.
Definition: Event.h:43
void SetText(const char *txt)
Definition: Event.h:57
void SetDescription(const std::string &str)
Definition: Event.h:27
void SetTime()
Definition: Event.h:47
void SetInt(int i)
Definition: Event.h:53
void SetFloat(float f)
Definition: Event.h:54
const void * GetData() const
Return a pointer to the data region.
Definition: Event.h:36
size_t GetSize() const
Return the size of the data.
Definition: Event.h:38
std::string GetName() const
Return the stored name of the event.
Definition: Event.h:31
std::string fDescription
A string describing the format of the data.
Definition: Event.h:11
void SetData(const std::vector< char > &data)
Definition: Event.h:48
Event()
Empty is true if received event was a NULL pointer.
Definition: Event.h:20
std::string GetDescription() const
Definition: Event.h:28
float data[4 *1440]
Concerete implementation of an EventImp stroring name, format, data and time.
Definition: Event.h:6
bool IsEmpty() const
Return if event is not just zero size but empty.
Definition: Event.h:45
int fQoS
Time stamp.
Definition: Event.h:16
Time GetTime() const
Return reference to a time stamp.
Definition: Event.h:41
std::string fFormat
A name associated with the event.
Definition: Event.h:10
void SetData(const void *ptr, size_t siz)
Definition: Event.h:49
Time fTime
Data associated with this event.
Definition: Event.h:15
std::string fName
Definition: Event.h:9
void SetString(const std::string &str)
Definition: Event.h:58