nx_server_plugin_sdk 1.0 Server Plugin SDK

i_utility_provider.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2
3 #pragma once
4
5 #include <nx/sdk/i_string.h>
6 #include <nx/sdk/interface.h>
7 #include <nx/sdk/result.h>
8
9 namespace nx::sdk {
10
11 class IStringMap;
12
23 class IUtilityProvider0: public Interface<IUtilityProvider0>
24 {
25 public:
26 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider"); }
27
32 virtual int64_t vmsSystemTimeSinceEpochMs() const = 0;
33
35 protected: virtual const IString* getHomeDir() const = 0;
47 public: std::string homeDir() const { return Ptr(getHomeDir())->str(); }
48 };
49
50 class IUtilityProvider1: public Interface<IUtilityProvider1, IUtilityProvider0>
51 {
52 public:
53 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider1"); }
54
56 protected: virtual const IString* getServerSdkVersion() const = 0;
60 public: std::string serverSdkVersion() const { return Ptr(getServerSdkVersion())->str(); }
61 };
62
63 class IUtilityProvider2: public Interface<IUtilityProvider2, IUtilityProvider1>
64 {
65 public:
66 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider2"); }
67
68 virtual const char* serverId() const = 0;
69 };
70
71 class IUtilityProvider3: public Interface<IUtilityProvider3, IUtilityProvider2>
72 {
73 public:
74 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider3"); }
75
76 virtual IString* cloudSystemId() const = 0;
77 virtual IString* cloudAuthKey() const = 0;
78 };
79
80 class IUtilityProvider4: public Interface<IUtilityProvider4, IUtilityProvider3>
81 {
82 public:
83 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider4"); }
84
85 enum class HttpDomainName: int
86 {
87 cloud,
88 vms,
89 };
90
95 class IHttpRequestCompletionHandler: public Interface<IHttpRequestCompletionHandler>
96 {
97 public:
98 static auto interfaceId() { return makeId("nx::sdk::IHttpRequestCompletionHandler"); }
99
100 virtual void execute(Result<IString*> response) = 0;
101 };
102 using IHttpRequestCompletionHandler0 = IHttpRequestCompletionHandler;
103
105 protected: virtual void doSendHttpRequest(
106 HttpDomainName requestDomainName,
107 const char* url,
108 const char* httpMethod,
109 const char* mimeType,
110 const char* requestBody,
111 IHttpRequestCompletionHandler* callback) const = 0;
118 public: void sendHttpRequest(
119 HttpDomainName requestDomainName,
120 const char* url,
121 const char* httpMethod,
122 const char* mimeType,
123 const char* requestBody,
124 Ptr<IHttpRequestCompletionHandler> callback) const
125 {
126 doSendHttpRequest(
127 requestDomainName, url, httpMethod, mimeType, requestBody, callback.get());
128 }
129 };
130
131 class ICloudTokenSubscriber : public Interface<ICloudTokenSubscriber>
132 {
133 public:
134 virtual void updated(const char* token) const = 0;
135 };
136
137 class IUtilityProvider5: public Interface<IUtilityProvider5, IUtilityProvider4>
138 {
139 public:
140 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider5"); }
141
152 virtual const char* cloudToken() const = 0;
153
157 virtual void subscribeForCloudTokenUpdate(ICloudTokenSubscriber* subscriber) = 0;
158 };
159
160 class IUtilityProvider6: public Interface<IUtilityProvider6, IUtilityProvider5>
161 {
162 public:
163 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider6"); }
164
171 virtual IString* supportedVectorizationModels() const = 0;
172 };
173
174 class IUtilityProvider7: public Interface<IUtilityProvider7, IUtilityProvider6>
175 {
176 public:
177 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider7"); }
178
180 protected: virtual IString* getDataDir() const = 0;
181
186 public: std::string dataDir() const { return Ptr(getDataDir())->str(); }
187 };
188
189 class IUtilityProvider: public Interface<IUtilityProvider, IUtilityProvider7>
190 {
191 public:
192 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider8"); }
193
200 public: virtual void setServiceUsageQuantities(const char* engineId, const IStringMap* values) = 0;
201 };
202
203 using IUtilityProvider8 = IUtilityProvider;
204
205 } // namespace nx::sdk
nx::sdk::IUtilityProvider4
Definition: i_utility_provider.h:80
nx::sdk::IStringMap
Definition: i_string_map.h:9
nx::sdk::IUtilityProvider2
Definition: i_utility_provider.h:63
nx::sdk::IUtilityProvider5::subscribeForCloudTokenUpdate
virtual void subscribeForCloudTokenUpdate(ICloudTokenSubscriber *subscriber)=0
nx::sdk::IUtilityProvider7
Definition: i_utility_provider.h:174
nx::sdk::IUtilityProvider4::sendHttpRequest
void sendHttpRequest(HttpDomainName requestDomainName, const char *url, const char *httpMethod, const char *mimeType, const char *requestBody, Ptr< IHttpRequestCompletionHandler > callback) const
Definition: i_utility_provider.h:118
nx::sdk::Interface
Definition: interface.h:48
nx::sdk::IUtilityProvider0::getHomeDir
virtual const IString * getHomeDir() const =0
nx::sdk::IUtilityProvider1::serverSdkVersion
std::string serverSdkVersion() const
Definition: i_utility_provider.h:60
nx::sdk::IUtilityProvider3
Definition: i_utility_provider.h:71
nx::sdk::IUtilityProvider1
Definition: i_utility_provider.h:50
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::IUtilityProvider0::homeDir
std::string homeDir() const
Definition: i_utility_provider.h:47
nx::sdk::IUtilityProvider0::vmsSystemTimeSinceEpochMs
virtual int64_t vmsSystemTimeSinceEpochMs() const =0
nx::sdk::IUtilityProvider6
Definition: i_utility_provider.h:160
nx::sdk::IString
Definition: i_string.h:9
nx::sdk::IUtilityProvider4::doSendHttpRequest
virtual void doSendHttpRequest(HttpDomainName requestDomainName, const char *url, const char *httpMethod, const char *mimeType, const char *requestBody, IHttpRequestCompletionHandler *callback) const =0
nx::sdk::IUtilityProvider7::getDataDir
virtual IString * getDataDir() const =0
nx::sdk::IUtilityProvider4::IHttpRequestCompletionHandler
Definition: i_utility_provider.h:95
nx::sdk::Result
Definition: result.h:52
nx::sdk::IUtilityProvider
Definition: i_utility_provider.h:189
nx::sdk::IUtilityProvider0
Definition: i_utility_provider.h:23
nx::sdk
Definition: device_agent.h:12
nx::sdk::ICloudTokenSubscriber
Definition: i_utility_provider.h:131
nx::sdk::IUtilityProvider5
Definition: i_utility_provider.h:137
nx::sdk::IUtilityProvider5::cloudToken
virtual const char * cloudToken() const =0
nx::sdk::IUtilityProvider::setServiceUsageQuantities
virtual void setServiceUsageQuantities(const char *engineId, const IStringMap *values)=0
nx::sdk::IUtilityProvider7::dataDir
std::string dataDir() const
Definition: i_utility_provider.h:186
nx::sdk::IUtilityProvider6::supportedVectorizationModels
virtual IString * supportedVectorizationModels() const =0
nx::sdk::IUtilityProvider1::getServerSdkVersion
virtual const IString * getServerSdkVersion() const =0
nx::sdk::IRefCountable::makeId
static const InterfaceId * makeId(const char(&charArray)[len])
Definition: i_ref_countable.h:77