source: trunk/FACT++/src/EventDim.h@ 14556

Last change on this file since 14556 was 13833, checked in by tbretz, 13 years ago
Removed target state; 'fixed' GetSize return code.
File size: 1.9 KB
Line 
1// **************************************************************************
2/** @class EventDim
3
4@brief Concerete implementation of an EventImp as a DimCommand
5
6This is the implementation of an event which can be posted to a state
7machine via the DIM network.
8
9@todo
10- Add reference to DIM docu
11- improve docu
12
13*/
14// **************************************************************************
15#ifndef FACT_EventDim
16#define FACT_EventDim
17
18#include "EventImp.h"
19
20#include "dis.hxx" // DimCommand
21
22#include "DimDescriptionService.h"
23
24class EventDim : public EventImp, public DimCommand
25{
26 DimDescriptionService *fDescription;
27
28public:
29 EventDim(const std::string &name, const std::string &format, DimCommandHandler *handler)
30 : EventImp(), DimCommand(name.c_str(), format.c_str(), handler), fDescription(0)
31 {
32 // Initialize these values from DimCommand, because DimCommand
33 // does not yet do it.
34 itsData = 0;
35 itsSize = 0;
36
37 secs = 0;
38 millisecs = 0;
39 }
40 ~EventDim()
41 {
42 delete fDescription;
43 }
44 void SetDescription(const std::string &str)
45 {
46 if (fDescription)
47 delete fDescription;
48 fDescription = new DimDescriptionService(GetName(), str);
49 }
50 std::string GetDescription() const { return fDescription ? fDescription->GetDescription() : ""; }
51
52 std::string GetName() const { return const_cast<EventDim*>(this)->getName(); }
53 std::string GetFormat() const { return const_cast<EventDim*>(this)->getFormat(); }
54
55 const void *GetData() const { return const_cast<EventDim*>(this)->getData(); }
56 size_t GetSize() const { return const_cast<EventDim*>(this)->getSize(); }
57
58 Time GetTime() const
59 {
60 // Must be in exactly this order!
61 const int tsec = const_cast<EventDim*>(this)->getTimestamp();
62 const int tms = const_cast<EventDim*>(this)->getTimestampMillisecs();
63
64 return Time(tsec, tms*1000);
65 }
66};
67
68#endif
Note: See TracBrowser for help on using the repository browser.