PEvent.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2018 Digital Barriers plc. All rights reserved.
3  * Contact: http://www.digitalbarriers.com/
4  *
5  * This file is part of the Papillon SDK.
6  *
7  * You can't use, modify or distribute any part of this file without
8  * the explicit written agreements of Digital Barriers.
9  */
10 
15 #pragma once
16 #include <PObject.h>
17 #include <PGuid.h>
18 #include <PString.h>
19 
20 PAPILLON_BEGIN_NAMESPACE
21 
22 class PDateTime;
23 class PEventBuilder;
24 class PProperties;
25 
41 class PAPILLON_API_CORE PEvent : public PObject
42 {
43 public:
48  {
54  E_UNDEFINED
55  };
56 
57 public:
73  PEvent();
74 
85  static PEventBuilder Create(const PString& type, const PString& annotation = PString::Empty(), const PGuid& sourceId = PGuid::Null());
86 
90  PEvent(const PEvent& other);
91 
95  virtual ~PEvent();
96 
100  PEvent& operator=(const PEvent& other);
101 
105  bool operator==(const PEvent& other) const;
106 
111  void SetType(const PString& eventType) const;
112 
116  const PString& GetType() const;
117 
121  void SetComposition(bool eventComposition);
122 
126  bool GetComposition() const;
127 
131  void SetTimeGranularity(EEventTimeGranularity eventGranularity);
132 
136  EEventTimeGranularity GetTimeGranularity() const;
137 
142  void SetOccurrenceTime(const PDateTime& occurrenceTime);
143 
148  const PDateTime& GetOccurrenceTime() const;
149 
153  void SetCertainty(double eventCertainty);
154 
158  double GetCertainty() const;
159 
163  void SetAnnotation(const PString& eventAnnotation);
164 
168  const PString& GetAnnotation() const;
169 
174  void SetEventId(const PGuid& eventId);
175 
179  const PGuid& GetEventId() const;
180 
184  void SetDetectionTime(const PDateTime& detectionTime);
185 
189  const PDateTime& GetDetectionTime() const;
190 
194  void SetSource(const PGuid& sourceId);
195 
199  const PGuid& GetSource() const;
200 
204  PProperties& SetPayload() const;
205 
209  const PProperties& GetPayload() const;
210 
211 private:
212  PEvent(const PString& eventType,
213  const PString& eventAnnotation,
214  const PGuid& eventSource,
215  const PProperties& payload,
216  double eventCertainty,
217  const PDateTime& occurrenceTime,
218  const EEventTimeGranularity timeGranularity,
219  const PDateTime& detectionTime,
220  const PGuid& eventId,
221  bool isComposed
222  );
223 
224  friend class PEventBuilder;
225  friend class PEventImpl;
226 };
227 
228 
232 class PAPILLON_API_CORE PEventBuilder
233 {
234 public:
238  PEventBuilder(const PString& type, const PString& annotation = PString::Empty(), const PGuid& sourceId = PGuid::Null());
239 
243  PEventBuilder(const PEventBuilder& other);
244 
248  ~PEventBuilder();
249 
253  PEventBuilder& Type(const PString& eventType);
254 
258  PEventBuilder& Annotation(const PString& eventAnnotation);
259 
263  PEventBuilder& SourceId(const PGuid& eventSourceId);
264 
268  PEventBuilder& Payload(const PProperties& payload);
269 
273  PEventBuilder& Payload(const PString& key, const PObject& value);
274 
278  PEventBuilder& Certainty(double certainty);
279 
283  PEventBuilder& OccurenceTime(const PDateTime& occurenceTime);
284 
288  PEventBuilder& TimeGranularity(PEvent::EEventTimeGranularity timeGranularity);
289 
293  PEventBuilder& DetectionTime(const PDateTime& detectionTime);
294 
298  PEventBuilder& Id(const PGuid& eventId);
299 
303  PEventBuilder& Composed(bool isComposed);
304 
308  PEvent Done() const;
309 
310 private:
311  PEventBuilder& operator=(const PEventBuilder&);
312 
313 private:
314  void* p;
315 };
316 
317 PAPILLON_END_NAMESPACE
318 
The PString class provides an Unicode character strings.
Definition: PString.h:37
EEventTimeGranularity
All the available time granularity for events.
Definition: PEvent.h:47
Class PGuid: an immutable Globally Unique Identifier (GUID).
The PDateTime class provides date and time functions, including time-zone management and UTC conversi...
Definition: PDateTime.h:38
The PProperties class represents a container of properties; each property has a name (PString) and a ...
Definition: PProperties.h:38
The PObject class is the root class of all Papillon classes; all PObject behaves like shared referenc...
Definition: PObject.h:27
Class PString: an unicode character strings (use copy-on-write idiom).
static const PString & Empty()
Returns the constant holding the empty string "".
Definition: PString.h:64
static const PGuid & Null()
Returns the constant holding the null GUID (i.e.
Definition: PGuid.h:44
The PGuid class represents a Globally Unique Identifier (GUID); PGuid instances are immutable (thread...
Definition: PGuid.h:28
Class PObject: the root class of all Papillon classes.
PObject & operator=(const PObject &obj)
Performs a shared copy of other to this object.
Definition: PObject.h:45
The PEventBuilder class is an helper class used to build PEvent objects.
Definition: PEvent.h:232
The PEvent class represents an event detected by a video analytics algorithm (PAnalytics); NOT thread...
Definition: PEvent.h:41