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
21 class IUtilityProvider0: public Interface<IUtilityProvider0>
22 {
23 public:
24 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider"); }
25
30 virtual int64_t vmsSystemTimeSinceEpochMs() const = 0;
31
33 protected: virtual const IString* getHomeDir() const = 0;
45 public: std::string homeDir() const { return Ptr(getHomeDir())->str(); }
46 };
47
48 class IUtilityProvider1: public Interface<IUtilityProvider1, IUtilityProvider0>
49 {
50 public:
51 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider1"); }
52
54 protected: virtual const IString* getServerSdkVersion() const = 0;
58 public: std::string serverSdkVersion() const { return Ptr(getServerSdkVersion())->str(); }
59 };
60
61 class IUtilityProvider2: public Interface<IUtilityProvider2, IUtilityProvider1>
62 {
63 public:
64 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider2"); }
65
66 virtual const char* serverId() const = 0;
67 };
68
69 class IUtilityProvider3: public Interface<IUtilityProvider3, IUtilityProvider2>
70 {
71 public:
72 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider3"); }
73
74 virtual IString* cloudSystemId() const = 0;
75 virtual IString* cloudAuthKey() const = 0;
76 };
77
78 class IUtilityProvider4: public Interface<IUtilityProvider4, IUtilityProvider3>
79 {
80 public:
81 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider4"); }
82
83 enum class HttpDomainName: int
84 {
85 cloud,
86 vms,
87 };
88
93 class IHttpRequestCompletionHandler: public Interface<IHttpRequestCompletionHandler>
94 {
95 public:
96 static auto interfaceId() { return makeId("nx::sdk::IHttpRequestCompletionHandler"); }
97
98 virtual void execute(Result<IString*> response) = 0;
99 };
100 using IHttpRequestCompletionHandler0 = IHttpRequestCompletionHandler;
101
103 protected: virtual void doSendHttpRequest(
104 HttpDomainName requestDomainName,
105 const char* url,
106 const char* httpMethod,
107 const char* mimeType,
108 const char* requestBody,
109 IHttpRequestCompletionHandler* callback) const = 0;
116 public: void sendHttpRequest(
117 HttpDomainName requestDomainName,
118 const char* url,
119 const char* httpMethod,
120 const char* mimeType,
121 const char* requestBody,
122 Ptr<IHttpRequestCompletionHandler> callback) const
123 {
124 doSendHttpRequest(
125 requestDomainName, url, httpMethod, mimeType, requestBody, callback.get());
126 }
127 };
128
129 class ICloudTokenSubscriber : public Interface<ICloudTokenSubscriber>
130 {
131 public:
132 virtual void updated(const char* token) const = 0;
133 };
134
135 class IUtilityProvider5: public Interface<IUtilityProvider5, IUtilityProvider4>
136 {
137 public:
138 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider5"); }
139
150 virtual const char* cloudToken() const = 0;
151
155 virtual void subscribeForCloudTokenUpdate(ICloudTokenSubscriber* subscriber) = 0;
156 };
157
158 class IUtilityProvider6: public Interface<IUtilityProvider6, IUtilityProvider5>
159 {
160 public:
161 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider6"); }
162
169 virtual IString* supportedVectorizationModels() const = 0;
170 };
171
172 class IUtilityProvider: public Interface<IUtilityProvider, IUtilityProvider6>
173 {
174 public:
175 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider7"); }
176
178 protected: virtual IString* getDataDir() const = 0;
179
184 public: std::string dataDir() const { return Ptr(getDataDir())->str(); }
185 };
186
187 using IUtilityProvider7 = IUtilityProvider;
188
189 } // namespace nx::sdk
nx::sdk::IUtilityProvider4
Definition: i_utility_provider.h:78
nx::sdk::IUtilityProvider2
Definition: i_utility_provider.h:61
nx::sdk::IUtilityProvider::dataDir
std::string dataDir() const
Definition: i_utility_provider.h:184
nx::sdk::IUtilityProvider5::subscribeForCloudTokenUpdate
virtual void subscribeForCloudTokenUpdate(ICloudTokenSubscriber *subscriber)=0
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:116
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:58
nx::sdk::IUtilityProvider3
Definition: i_utility_provider.h:69
nx::sdk::IUtilityProvider::getDataDir
virtual IString * getDataDir() const =0
nx::sdk::IUtilityProvider1
Definition: i_utility_provider.h:48
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::IUtilityProvider0::homeDir
std::string homeDir() const
Definition: i_utility_provider.h:45
nx::sdk::IUtilityProvider0::vmsSystemTimeSinceEpochMs
virtual int64_t vmsSystemTimeSinceEpochMs() const =0
nx::sdk::IUtilityProvider6
Definition: i_utility_provider.h:158
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::IUtilityProvider4::IHttpRequestCompletionHandler
Definition: i_utility_provider.h:93
nx::sdk::Result
Definition: result.h:52
nx::sdk::IUtilityProvider
Definition: i_utility_provider.h:172
nx::sdk::IUtilityProvider0
Definition: i_utility_provider.h:21
nx::sdk
Definition: device_agent.h:12
nx::sdk::ICloudTokenSubscriber
Definition: i_utility_provider.h:129
nx::sdk::IUtilityProvider5
Definition: i_utility_provider.h:135
nx::sdk::IUtilityProvider5::cloudToken
virtual const char * cloudToken() const =0
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