FACT++  1.0
EventDim.h
Go to the documentation of this file.
1 // **************************************************************************
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 
24 class EventDim : public EventImp, public DimCommand
25 {
27 
28 public:
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  }
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
int getTimestampMillisecs()
Definition: discpp.cxx:1466
A general base-class describing events issues in a state machine.
Definition: EventImp.h:11
char * getFormat()
Definition: discpp.cxx:1448
std::string GetName() const
Definition: EventDim.h:52
int getTimestamp()
Definition: discpp.cxx:1453
Time GetTime() const
Definition: EventDim.h:58
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
char str[80]
Definition: test_client.c:7
char * getName()
Definition: discpp.cxx:1482
void * itsData
Definition: dis.hxx:268
const void * GetData() const
Definition: EventDim.h:55
size_t GetSize() const
Definition: EventDim.h:56
A DimService which broadcasts descriptions for services and commands.
void * getData()
Definition: discpp.cxx:1408
EventDim(const std::string &name, const std::string &format, DimCommandHandler *handler)
Definition: EventDim.h:29
std::string GetDescription() const
Definition: EventDim.h:50
~EventDim()
Definition: EventDim.h:40
Concerete implementation of an EventImp as a DimCommand.
Definition: EventDim.h:24
DimDescriptionService * fDescription
Definition: EventDim.h:26
std::string GetFormat() const
Definition: EventDim.h:53
static void handler(int conn_id, char *packet, int size, int status)
Definition: webServer.c:635
int secs
Definition: dis.hxx:298
int getSize()
Definition: discpp.cxx:1443
void SetDescription(const std::string &str)
Definition: EventDim.h:44
int millisecs
Definition: dis.hxx:298
int itsSize
Definition: dis.hxx:269
std::string GetDescription() const