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 #include <PStringList.h>
20 
21 PAPILLON_BEGIN_NAMESPACE
22 
23 class PDateTime;
24 class PEventBuilder;
25 class PProperties;
26 class PList;
27 
43 class PAPILLON_API_CORE PEvent : public PObject
44 {
45 public:
50  {
56  E_UNDEFINED
57  };
58 
59 public:
77  PEvent();
78 
89  static PEventBuilder Create(const PString& type, const PString& annotation = PString::Empty(), const PGuid& sourceId = PGuid::Null());
90 
94  PEvent(const PEvent& other);
95 
99  virtual ~PEvent();
100 
104  PEvent& operator=(const PEvent& other);
105 
109  bool operator==(const PEvent& other) const;
110 
114  int GetVersion() const;
115 
120  void SetType(const PString& eventType) const;
121 
125  const PString& GetType() const;
126 
127 
131  bool GetComposition() const;
132 
136  void SetComposition(bool eventComposition);
137 
141  void AddAncestor(const PGuid & ancestor);
142 
146  const PList& GetAncestors() const;
147 
151  void SetTimeGranularity(EEventTimeGranularity eventGranularity);
152 
156  EEventTimeGranularity GetTimeGranularity() const;
157 
162  void SetOccurrenceTime(const PDateTime& occurrenceTime);
163 
168  const PDateTime& GetOccurrenceTime() const;
169 
173  void SetCertainty(double eventCertainty);
174 
178  double GetCertainty() const;
179 
183  void SetAnnotation(const PString& eventAnnotation);
184 
188  const PString& GetAnnotation() const;
189 
194  void SetEventId(const PGuid& eventId);
195 
199  const PGuid& GetEventId() const;
200 
204  void SetDetectionTime(const PDateTime& detectionTime);
205 
209  const PDateTime& GetDetectionTime() const;
210 
214  void SetSource(const PGuid& sourceId);
215 
219  const PGuid& GetSource() const;
220 
224  void SetSourceName(const PString& sourceName);
225 
229  const PString& GetSourceName() const;
230 
234  PProperties& SetPayload() const;
235 
239  const PProperties& GetPayload() const;
240 
266  PString ToJSON(const PStringList & includeKeysFromPayload = PStringList()) const;
267 
287  PResult FromJSON(const PString & jsonString);
288 
289 private:
290  PEvent(const PString& eventType,
291  const PString& eventAnnotation,
292  const PGuid& eventSource,
293  const PProperties& payload,
294  double eventCertainty,
295  const PDateTime& occurrenceTime,
296  const EEventTimeGranularity timeGranularity,
297  const PDateTime& detectionTime,
298  const PGuid& eventId,
299  bool isComposed,
300  const PString& eventSourceName,
301  const PList& ancestors);
302 
303  friend class PEventBuilder;
304  friend class PEventImpl;
305 };
306 
307 
311 class PAPILLON_API_CORE PEventBuilder
312 {
313 public:
317  PEventBuilder(const PString& type, const PString& annotation = PString::Empty(), const PGuid& sourceId = PGuid::Null());
318 
322  PEventBuilder(const PEventBuilder& other);
323 
327  ~PEventBuilder();
328 
332  PEventBuilder& Type(const PString& eventType);
333 
337  PEventBuilder& Annotation(const PString& eventAnnotation);
338 
342  PEventBuilder& SourceId(const PGuid& eventSourceId);
343 
347  PEventBuilder& SourceName(const PString & sourceName);
348 
352  PEventBuilder& Payload(const PProperties& payload);
353 
357  PEventBuilder& Payload(const PString& key, const PObject& value);
358 
362  PEventBuilder& Certainty(double certainty);
363 
367  PEventBuilder& OccurrenceTime(const PDateTime& occurenceTime);
368 
372  PEventBuilder& TimeGranularity(PEvent::EEventTimeGranularity timeGranularity);
373 
377  PEventBuilder& DetectionTime(const PDateTime& detectionTime);
378 
382  PEventBuilder& Id(const PGuid& eventId);
383 
387  PEventBuilder& Composed(bool isComposed);
388 
392  PEventBuilder& Ancestor(const PGuid & ancestorEventId);
393 
397  PEvent Done() const;
398 
399 private:
400  PEventBuilder& operator=(const PEventBuilder&);
401 
402 private:
403  void* p;
404 };
405 
406 PAPILLON_END_NAMESPACE
407 
The PString class provides an Unicode character strings.
Definition: PString.h:37
EEventTimeGranularity
All the available time granularity for events.
Definition: PEvent.h:49
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 PResult class represents the result returned by most of Papillon functions; this class is used to...
Definition: PResult.h:159
Class PStringList: a list of strings.
The PList class represents a generic container which handle an ordered collection of PObject; NOT thr...
Definition: PList.h:46
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).
The PStringList class represents a list of PString; NOT thread-safe.
Definition: PStringList.h:26
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:311
The PEvent class represents an event detected by a video analytics algorithm (PAnalytics); NOT thread...
Definition: PEvent.h:43