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

Last change on this file since 10299 was 10299, checked in by tbretz, 9 years ago
Implemented event description into all kind of events.
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(int target, const std::string &name, const std::string &format, DimCommandHandler *handler)
30        : EventImp(target), 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    int         GetSize() const   { return const_cast<EventDim*>(this)->getSize(); }
57
58    Time GetTime() const
59    {
60        return Time(const_cast<EventDim*>(this)->getTimestamp(),
61                    const_cast<EventDim*>(this)->getTimestampMillisecs());
62    }
63};
64
65#endif
Note: See TracBrowser for help on using the repository browser.