ndmspc  v1.1.1-1
NCloudEvent.h
1 #ifndef NdmspcHttpNCloudEvent_H
2 #define NdmspcHttpNCloudEvent_H
3 
4 #include <TObject.h>
5 #include <nlohmann/json.hpp>
6 #include <string>
7 using json = nlohmann::json;
8 
9 class THttpCallArg;
10 namespace Ndmspc {
11 
23 class NCloudEvent : public TObject {
24  public:
32  NCloudEvent(std::string id = "0", std::string source = "unknown", std::string specVersion = "1.0",
33  std::string type = "unknown");
34 
39  NCloudEvent(THttpCallArg * arg);
40 
44  virtual ~NCloudEvent();
45 
50  virtual void Clear(Option_t * opt = "");
51 
56  virtual void Print(Option_t * opt = "") const;
57 
62  bool IsValid() const { return fIsValid; }
63 
68  std::string GetId() const { return fId; }
69 
74  std::string GetSource() const { return fSource; }
75 
80  std::string GetSpecVersion() const { return fSpecVersion; }
81 
86  std::string GetType() const { return fType; }
87 
92  std::string GetDatacontentType() const { return fDataContentType; }
93 
98  std::string GetData() const { return fData; }
99 
104  std::string GetInfo() const;
105 
110  void HandleNCloudEventRequest(THttpCallArg * arg);
111 
116  void SetId(std::string id) { fId = id; }
117 
122  void SetSource(std::string source) { fSource = source; }
123 
128  void SetSpecVersion(std::string specVersion) { fSpecVersion = specVersion; }
129 
134  void SetDatacontentType(std::string datacontenttype) { fDataContentType = datacontenttype; }
135 
140  void SetType(std::string type) { fType = type; }
141 
146  void SetData(std::string data) { fData = data; }
147 
148  private:
149  bool fIsValid{false};
150  std::string fId{};
151  std::string fSource{};
152  std::string fSpecVersion{};
153  std::string fType{};
154  std::string fDataContentType{};
155  std::string fData{};
156 
158  ClassDef(NCloudEvent, 1);
160 };
161 } // namespace Ndmspc
162 #endif
Represents a CloudEvent object for HTTP communication.
Definition: NCloudEvent.h:23
void SetType(std::string type)
Sets the event type.
Definition: NCloudEvent.h:140
std::string fType
Event type.
Definition: NCloudEvent.h:153
bool IsValid() const
Checks if the event is valid.
Definition: NCloudEvent.h:62
void HandleNCloudEventRequest(THttpCallArg *arg)
Handles an HTTP request for a CloudEvent.
Definition: NCloudEvent.cxx:21
void SetDatacontentType(std::string datacontenttype)
Sets the event data content type.
Definition: NCloudEvent.h:134
std::string fSource
Event source URI-reference.
Definition: NCloudEvent.h:151
bool fIsValid
Validity flag for the event.
Definition: NCloudEvent.h:149
virtual ~NCloudEvent()
Destroys the NCloudEvent instance.
Definition: NCloudEvent.cxx:19
NCloudEvent(std::string id="0", std::string source="unknown", std::string specVersion="1.0", std::string type="unknown")
Constructs a new NCloudEvent with specified parameters.
Definition: NCloudEvent.cxx:11
std::string GetInfo() const
Gets additional event information.
Definition: NCloudEvent.cxx:64
void SetData(std::string data)
Sets the event data payload.
Definition: NCloudEvent.h:146
void SetSpecVersion(std::string specVersion)
Sets the CloudEvent specification version.
Definition: NCloudEvent.h:128
std::string GetSpecVersion() const
Gets the CloudEvent specification version.
Definition: NCloudEvent.h:80
std::string GetDatacontentType() const
Gets the event data content type.
Definition: NCloudEvent.h:92
std::string GetSource() const
Gets the event source URI.
Definition: NCloudEvent.h:74
std::string fDataContentType
Event data content type.
Definition: NCloudEvent.h:154
void SetId(std::string id)
Sets the event identifier.
Definition: NCloudEvent.h:116
std::string fData
Event data payload.
Definition: NCloudEvent.h:155
std::string fId
Event identifier.
Definition: NCloudEvent.h:150
std::string GetId() const
Gets the event identifier.
Definition: NCloudEvent.h:68
std::string fSpecVersion
CloudEvent specification version.
Definition: NCloudEvent.h:152
virtual void Clear(Option_t *opt="")
Clears the event data.
Definition: NCloudEvent.cxx:71
std::string GetData() const
Gets the event data payload.
Definition: NCloudEvent.h:98
virtual void Print(Option_t *opt="") const
Prints the event details.
Definition: NCloudEvent.cxx:81
void SetSource(std::string source)
Sets the event source URI.
Definition: NCloudEvent.h:122
std::string GetType() const
Gets the event type.
Definition: NCloudEvent.h:86