Line |
Branch |
Exec |
Source |
1 |
|
|
/* GATE PROJECT LICENSE: |
2 |
|
|
+----------------------------------------------------------------------------+ |
3 |
|
|
| Copyright(c) 2018-2025, Stefan Meislinger | |
4 |
|
|
| All rights reserved. | |
5 |
|
|
| | |
6 |
|
|
| Redistribution and use in source and binary forms, with or without | |
7 |
|
|
| modification, are permitted provided that the following conditions are met:| |
8 |
|
|
| | |
9 |
|
|
| 1. Redistributions of source code must retain the above copyright notice, | |
10 |
|
|
| this list of conditions and the following disclaimer. | |
11 |
|
|
| 2. Redistributions in binary form must reproduce the above copyright | |
12 |
|
|
| notice, this list of conditions and the following disclaimer in the | |
13 |
|
|
| documentation and/or other materials provided with the distribution. | |
14 |
|
|
| | |
15 |
|
|
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"| |
16 |
|
|
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
17 |
|
|
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
18 |
|
|
| ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
19 |
|
|
| LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
20 |
|
|
| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
21 |
|
|
| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
22 |
|
|
| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
23 |
|
|
| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
24 |
|
|
| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
25 |
|
|
| THE POSSIBILITY OF SUCH DAMAGE. | |
26 |
|
|
+----------------------------------------------------------------------------+ |
27 |
|
|
*/ |
28 |
|
|
|
29 |
|
|
#include "gate/tech/gateservices.hpp" |
30 |
|
|
#include "gate/exceptions.hpp" |
31 |
|
|
#include "gate/utilities.hpp" |
32 |
|
|
#include "gate/tech/microservices/webcontent_service.h" |
33 |
|
|
|
34 |
|
|
namespace gate |
35 |
|
|
{ |
36 |
|
|
namespace tech |
37 |
|
|
{ |
38 |
|
|
|
39 |
|
✗ |
ServiceHost::ServiceHost(gate_servicehost_t* host) |
40 |
|
✗ |
: object_impl_t(host) |
41 |
|
|
{ |
42 |
|
✗ |
} |
43 |
|
|
|
44 |
|
✗ |
ServiceHost::ServiceHost(ServiceHost const& src) |
45 |
|
✗ |
: object_impl_t(src) |
46 |
|
|
{ |
47 |
|
✗ |
} |
48 |
|
✗ |
ServiceHost::ServiceHost() |
49 |
|
✗ |
: object_impl_t(gate_servicehost_create()) |
50 |
|
|
{ |
51 |
|
✗ |
} |
52 |
|
✗ |
ServiceHost& ServiceHost::operator=(ServiceHost const& src) |
53 |
|
|
{ |
54 |
|
✗ |
if (this != &src) |
55 |
|
|
{ |
56 |
|
✗ |
ServiceHost that(src); |
57 |
|
✗ |
this->swap(that); |
58 |
|
|
} |
59 |
|
✗ |
return *this; |
60 |
|
|
} |
61 |
|
✗ |
ServiceHost::~ServiceHost() noexcept |
62 |
|
|
{ |
63 |
|
✗ |
} |
64 |
|
|
|
65 |
|
✗ |
void ServiceHost::publishMessage(String const& sourceAddress, String const& destinationAddress, String const& msgId, String const& message) |
66 |
|
|
{ |
67 |
|
✗ |
result_t result = gate_servicehost_publish_message(this->c_impl(), |
68 |
|
|
sourceAddress.c_impl(), destinationAddress.c_impl(), |
69 |
|
|
msgId.c_impl(), message.c_impl()); |
70 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
71 |
|
✗ |
} |
72 |
|
✗ |
void ServiceHost::publishObject(String const& sourceAddress, String const& destinationAddress, String const& objId, Object& obj) |
73 |
|
|
{ |
74 |
|
✗ |
result_t result = gate_servicehost_publish_object(this->c_impl(), |
75 |
|
|
sourceAddress.c_impl(), destinationAddress.c_impl(), |
76 |
|
|
objId.c_impl(), obj.c_impl()); |
77 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
78 |
|
✗ |
} |
79 |
|
|
|
80 |
|
✗ |
void ServiceHost::subscribeMessages(String const& sourceAddress, String const& destinationAddress, String const& msgId, MicroService& subScriber, void* userData) |
81 |
|
|
{ |
82 |
|
✗ |
result_t result = gate_servicehost_subscribe_messages(this->c_impl(), |
83 |
|
|
sourceAddress.c_impl(), destinationAddress.c_impl(), |
84 |
|
|
msgId.c_impl(), subScriber.c_impl(), userData); |
85 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
86 |
|
✗ |
} |
87 |
|
✗ |
void ServiceHost::unsubscribeMessages(String const& sourceAddress, String const& destinationAddress, String const& msgId, MicroService& subScriber, void* userData) |
88 |
|
|
{ |
89 |
|
✗ |
result_t result = gate_servicehost_unsubscribe_messages(this->c_impl(), |
90 |
|
|
sourceAddress.c_impl(), destinationAddress.c_impl(), |
91 |
|
|
msgId.c_impl(), subScriber.c_impl(), userData); |
92 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
93 |
|
✗ |
} |
94 |
|
|
|
95 |
|
✗ |
void ServiceHost::subscribeOjbects(String const& sourceAddress, String const& destinationAddress, String const& objId, MicroService& subscriber, void* userData) |
96 |
|
|
{ |
97 |
|
✗ |
result_t result = gate_servicehost_subscribe_objects(this->c_impl(), |
98 |
|
|
sourceAddress.c_impl(), destinationAddress.c_impl(), |
99 |
|
|
objId.c_impl(), subscriber.c_impl(), userData); |
100 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
101 |
|
✗ |
} |
102 |
|
✗ |
void ServiceHost::unsubscribeObjects(String const& sourceAddress, String const& destinationAddress, String const& objId, MicroService& subscriber, void* userData) |
103 |
|
|
{ |
104 |
|
✗ |
result_t result = gate_servicehost_unsubscribe_objects(this->c_impl(), |
105 |
|
|
sourceAddress.c_impl(), destinationAddress.c_impl(), |
106 |
|
|
objId.c_impl(), subscriber.c_impl(), userData); |
107 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
108 |
|
✗ |
} |
109 |
|
|
|
110 |
|
✗ |
void ServiceHost::remoteInvoke(String const& destinationAddress, String const& method, ConstStruct const& inputData, MutableStruct& outputData) |
111 |
|
|
{ |
112 |
|
✗ |
result_t result = gate_servicehost_remote_invoke(this->c_impl(), |
113 |
|
|
destinationAddress.c_impl(), method.c_impl(), |
114 |
|
|
inputData.c_impl(), outputData.c_impl()); |
115 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
116 |
|
✗ |
} |
117 |
|
|
|
118 |
|
✗ |
void ServiceHost::log(uint32_t logType, result_t resultCode, int32_t nativeCode, String const& origin, String const& message) |
119 |
|
|
{ |
120 |
|
✗ |
result_t result = gate_servicehost_log(this->c_impl(), |
121 |
|
|
logType, resultCode, nativeCode, |
122 |
|
|
origin.c_impl(), message.c_impl()); |
123 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
124 |
|
✗ |
} |
125 |
|
|
|
126 |
|
✗ |
void ServiceHost::addFactory(MicroFactory& factory, String const& factoryName) |
127 |
|
|
{ |
128 |
|
✗ |
result_t result = gate_servicehost_add_factory(this->c_impl(), factory.c_impl(), factoryName.c_impl()); |
129 |
|
✗ |
GATEXX_CHECK_ERROR(result); |
130 |
|
✗ |
} |
131 |
|
✗ |
Array<String> ServiceHost::getFactoryServiceNames() |
132 |
|
|
{ |
133 |
|
✗ |
gate_array_t names = GATE_INIT_EMPTY; |
134 |
|
✗ |
result_t result = gate_servicehost_get_factory_service_names(this->c_impl(), &names); |
135 |
|
✗ |
GATEXX_CHECK_ERROR(result); |
136 |
|
|
try |
137 |
|
|
{ |
138 |
|
✗ |
ArrayList<String> ret = gate::util::convertStringArray(names); |
139 |
|
✗ |
gate_array_release(&names); |
140 |
|
✗ |
return ret.toArray(); |
141 |
|
|
} |
142 |
|
✗ |
catch (...) |
143 |
|
|
{ |
144 |
|
✗ |
gate_array_release(&names); |
145 |
|
✗ |
throw; |
146 |
|
|
} |
147 |
|
|
} |
148 |
|
|
|
149 |
|
✗ |
void ServiceHost::removeFactory(String const& factoryName) |
150 |
|
|
{ |
151 |
|
✗ |
result_t result = gate_servicehost_remove_factory(this->c_impl(), factoryName.c_impl()); |
152 |
|
✗ |
GATEXX_CHECK_ERROR(result); |
153 |
|
✗ |
} |
154 |
|
|
|
155 |
|
✗ |
String ServiceHost::createService(String const& serviceName, String const& serviceInstance) |
156 |
|
|
{ |
157 |
|
✗ |
gate_string_t address = GATE_STRING_INIT_EMPTY; |
158 |
|
✗ |
result_t result = gate_servicehost_create_service(this->c_impl(), |
159 |
|
|
serviceName.c_impl(), serviceInstance.c_impl(), |
160 |
|
|
&address); |
161 |
|
✗ |
GATEXX_CHECK_ERROR(result); |
162 |
|
✗ |
return String::createFrom(address); |
163 |
|
|
} |
164 |
|
|
|
165 |
|
✗ |
Array<String> ServiceHost::getServiceAddresses() |
166 |
|
|
{ |
167 |
|
✗ |
gate_array_t names = GATE_INIT_EMPTY; |
168 |
|
✗ |
result_t result = gate_servicehost_get_service_addresses(this->c_impl(), &names); |
169 |
|
✗ |
GATEXX_CHECK_ERROR(result); |
170 |
|
✗ |
ArrayList<String> list = util::createStringArray(names); |
171 |
|
✗ |
return list.toArray(); |
172 |
|
|
} |
173 |
|
|
|
174 |
|
✗ |
MicroService ServiceHost::getService(String const& serviceAddress) |
175 |
|
|
{ |
176 |
|
✗ |
gate_microservice_t* ptrService = NULL; |
177 |
|
✗ |
result_t result = gate_servicehost_get_service(this->c_impl(), serviceAddress.c_impl(), &ptrService); |
178 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
179 |
|
✗ |
return MicroService(ptrService); |
180 |
|
|
} |
181 |
|
|
|
182 |
|
✗ |
Value ServiceHost::getServiceConfig(String const& serviceAddress, uint32_t configType) |
183 |
|
|
{ |
184 |
|
✗ |
Value ret; |
185 |
|
✗ |
result_t result = gate_servicehost_get_service_config(this->c_impl(), serviceAddress.c_impl(), configType, ret.c_impl()); |
186 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
187 |
|
✗ |
return ret; |
188 |
|
|
} |
189 |
|
|
|
190 |
|
✗ |
void ServiceHost::setServiceConfig(String const& serviceAddress, uint32_t configType, Value const& value) |
191 |
|
|
{ |
192 |
|
✗ |
result_t result = gate_servicehost_set_service_config(this->c_impl(), serviceAddress.c_impl(), configType, value.c_impl()); |
193 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
194 |
|
✗ |
} |
195 |
|
|
|
196 |
|
✗ |
void ServiceHost::startService(String const& serviceAddress) |
197 |
|
|
{ |
198 |
|
✗ |
result_t result = gate_servicehost_start_service(this->c_impl(), serviceAddress.c_impl()); |
199 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
200 |
|
✗ |
} |
201 |
|
|
|
202 |
|
✗ |
void ServiceHost::stopService(String const& serviceAddress) |
203 |
|
|
{ |
204 |
|
✗ |
result_t result = gate_servicehost_stop_service(this->c_impl(), serviceAddress.c_impl()); |
205 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
206 |
|
✗ |
} |
207 |
|
|
|
208 |
|
✗ |
void ServiceHost::releaseService(String const& serviceAddress) |
209 |
|
|
{ |
210 |
|
✗ |
result_t result = gate_servicehost_release_service(this->c_impl(), serviceAddress.c_impl()); |
211 |
|
✗ |
GATEXX_CHECK_ERROR(result); |
212 |
|
✗ |
} |
213 |
|
|
|
214 |
|
✗ |
void ServiceHost::startup() |
215 |
|
|
{ |
216 |
|
✗ |
result_t result = gate_servicehost_startup(this->c_impl()); |
217 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
218 |
|
✗ |
} |
219 |
|
✗ |
void ServiceHost::shutdown(bool_t releaseServices) |
220 |
|
|
{ |
221 |
|
✗ |
result_t result = gate_servicehost_shutdown(this->c_impl(), releaseServices); |
222 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
223 |
|
✗ |
} |
224 |
|
|
|
225 |
|
✗ |
ServiceHost ServiceHost::create() |
226 |
|
|
{ |
227 |
|
✗ |
gate_servicehost_t* host = gate_servicehost_create(); |
228 |
|
✗ |
if (NULL == host) |
229 |
|
|
{ |
230 |
|
✗ |
GATEXX_RAISE_ERROR(results::OutOfResources); |
231 |
|
|
} |
232 |
|
✗ |
return ServiceHost(host); |
233 |
|
|
} |
234 |
|
|
|
235 |
|
|
|
236 |
|
✗ |
void ServiceHost::loadConfig(Stream& sourceStream, uint32_t format, Config& targetConfig) |
237 |
|
|
{ |
238 |
|
✗ |
result_t result = gate_servicehost_load_config(sourceStream.c_impl(), format, targetConfig.c_instance()); |
239 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
240 |
|
✗ |
} |
241 |
|
✗ |
void ServiceHost::saveConfig(Config const& sourceConfig, uint32_t format, Stream& targetStream) |
242 |
|
|
{ |
243 |
|
✗ |
result_t result = gate_servicehost_save_config(sourceConfig.c_instance(), format, targetStream.c_impl()); |
244 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
245 |
|
✗ |
} |
246 |
|
|
|
247 |
|
✗ |
MicroFactory ServiceHost::getEssentialsFactory() |
248 |
|
|
{ |
249 |
|
✗ |
gate_microfactory_t* ptrFactory = gate_servicehost_essentials_factory(); |
250 |
|
✗ |
if (!ptrFactory) |
251 |
|
|
{ |
252 |
|
✗ |
GATEXX_RAISE_EXCEPTION(results::NotAvailable, "Essential microservices factory not available", 0); |
253 |
|
|
} |
254 |
|
✗ |
return MicroFactory(ptrFactory); |
255 |
|
|
} |
256 |
|
|
|
257 |
|
|
static StaticString const name_webcontent = GATE_MICROSERVICE_NAME_WEBCONTENT; |
258 |
|
|
|
259 |
|
|
class GATE_TECH_CPP_API ExtensionFactory : public MicroFactoryBase |
260 |
|
|
{ |
261 |
|
|
public: |
262 |
|
✗ |
ExtensionFactory() |
263 |
|
✗ |
{ |
264 |
|
✗ |
} |
265 |
|
✗ |
virtual ~ExtensionFactory() noexcept |
266 |
|
✗ |
{ |
267 |
|
|
|
268 |
|
✗ |
} |
269 |
|
|
|
270 |
|
✗ |
virtual Array<String> getSupportedServiceNames() override |
271 |
|
|
{ |
272 |
|
✗ |
ArrayList<String> lst; |
273 |
|
✗ |
lst.add(name_webcontent); |
274 |
|
✗ |
return lst.toArray(); |
275 |
|
|
} |
276 |
|
|
|
277 |
|
✗ |
virtual MicroService createService(String const& serviceName) override |
278 |
|
|
{ |
279 |
|
✗ |
if (serviceName == name_webcontent) |
280 |
|
|
{ |
281 |
|
✗ |
gate_microservice_t* ptr = gate_microservice_webcontent_create(); |
282 |
|
✗ |
if (!ptr) |
283 |
|
|
{ |
284 |
|
✗ |
gate::raiseError(results::OutOfMemory); |
285 |
|
|
} |
286 |
|
✗ |
return MicroService(ptr); |
287 |
|
|
} |
288 |
|
✗ |
gate::raiseException(results::NoMatch); |
289 |
|
✗ |
return MicroService(NULL); |
290 |
|
|
} |
291 |
|
|
}; |
292 |
|
|
|
293 |
|
✗ |
MicroFactory ServiceHost::getEssentialsExtensionsFactory() |
294 |
|
|
{ |
295 |
|
✗ |
ExtensionFactory* ptr = new ExtensionFactory(); |
296 |
|
✗ |
return ptr->getInstance(); |
297 |
|
|
} |
298 |
|
|
|
299 |
|
|
|
300 |
|
|
|
301 |
|
✗ |
void ServiceHost::importConfig(Config const& cfg) |
302 |
|
|
{ |
303 |
|
✗ |
result_t result = gate_servicehost_import_config(this->c_impl(), cfg.c_instance()); |
304 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
305 |
|
✗ |
} |
306 |
|
✗ |
void ServiceHost::exportConfig(Config& cfg) |
307 |
|
|
{ |
308 |
|
✗ |
result_t result = gate_servicehost_export_config(this->c_impl(), cfg.c_instance()); |
309 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
310 |
|
✗ |
} |
311 |
|
|
|
312 |
|
✗ |
void ServiceHost::releaseServices() |
313 |
|
|
{ |
314 |
|
✗ |
result_t result = gate_servicehost_release_services(this->c_impl()); |
315 |
|
✗ |
GATEXX_CHECK_ERROR(result); |
316 |
|
✗ |
} |
317 |
|
|
|
318 |
|
|
|
319 |
|
|
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
|
323 |
|
|
|
324 |
|
✗ |
ServiceHost::ConfigService::ConfigService() |
325 |
|
✗ |
: struct_instance_t(&gate_servicehost_config_service_init) |
326 |
|
|
{ |
327 |
|
✗ |
} |
328 |
|
✗ |
ServiceHost::ConfigService::ConfigService(gate_servicehost_config_service_t const& src) |
329 |
|
✗ |
: struct_instance_t(src) |
330 |
|
|
{ |
331 |
|
✗ |
} |
332 |
|
|
|
333 |
|
|
|
334 |
|
✗ |
String ServiceHost::ConfigService::getName() const |
335 |
|
|
{ |
336 |
|
✗ |
return String::duplicate((*this)->name); |
337 |
|
|
} |
338 |
|
✗ |
void ServiceHost::ConfigService::setName(String const& value) |
339 |
|
|
{ |
340 |
|
✗ |
String::assign((*this)->name, value); |
341 |
|
✗ |
} |
342 |
|
|
|
343 |
|
✗ |
String ServiceHost::ConfigService::getInstance() const |
344 |
|
|
{ |
345 |
|
✗ |
return String::duplicate((*this)->instance); |
346 |
|
|
} |
347 |
|
✗ |
void ServiceHost::ConfigService::setInstance(String const& value) |
348 |
|
|
{ |
349 |
|
✗ |
String::assign((*this)->instance, value); |
350 |
|
✗ |
} |
351 |
|
|
|
352 |
|
✗ |
ArrayList<String> ServiceHost::ConfigService::getMessageSubscriptions() const |
353 |
|
|
{ |
354 |
|
✗ |
ArrayList<String> tmp = util::convertStringArray((*this)->msg_subscriptions); |
355 |
|
✗ |
return tmp; |
356 |
|
|
} |
357 |
|
✗ |
void ServiceHost::ConfigService::setMessageSubscriptions(ArrayList<String> const& value) |
358 |
|
|
{ |
359 |
|
✗ |
gate_arraylist_t list = util::convertStringArray(value); |
360 |
|
✗ |
gate_arraylist_release((*this)->msg_subscriptions); |
361 |
|
✗ |
(*this)->msg_subscriptions = list; |
362 |
|
✗ |
} |
363 |
|
|
|
364 |
|
✗ |
ArrayList<String> ServiceHost::ConfigService::getObjectSubscriptions() const |
365 |
|
|
{ |
366 |
|
✗ |
ArrayList<String> tmp = util::convertStringArray((*this)->obj_subscriptions); |
367 |
|
✗ |
return tmp; |
368 |
|
|
} |
369 |
|
✗ |
void ServiceHost::ConfigService::setObjectSubscriptions(ArrayList<String> const& value) |
370 |
|
|
{ |
371 |
|
✗ |
gate_arraylist_t list = util::convertStringArray(value); |
372 |
|
✗ |
gate_arraylist_release((*this)->obj_subscriptions); |
373 |
|
✗ |
(*this)->obj_subscriptions = list; |
374 |
|
✗ |
} |
375 |
|
|
|
376 |
|
✗ |
String ServiceHost::ConfigService::getServiceGroup() const |
377 |
|
|
{ |
378 |
|
✗ |
return String::duplicate((*this)->service_group); |
379 |
|
|
} |
380 |
|
✗ |
void ServiceHost::ConfigService::setServiceGroup(String const& value) |
381 |
|
|
{ |
382 |
|
✗ |
String::assign((*this)->service_group, value); |
383 |
|
✗ |
} |
384 |
|
✗ |
bool ServiceHost::ConfigService::getAutostart() const |
385 |
|
|
{ |
386 |
|
✗ |
return (*this)->autostart; |
387 |
|
|
} |
388 |
|
✗ |
void ServiceHost::ConfigService::setAutostart(bool const& value) |
389 |
|
|
{ |
390 |
|
✗ |
(*this)->autostart = value; |
391 |
|
✗ |
} |
392 |
|
✗ |
uint32_t ServiceHost::ConfigService::getStartOrder() const |
393 |
|
|
{ |
394 |
|
✗ |
return (*this)->startorder; |
395 |
|
|
} |
396 |
|
✗ |
void ServiceHost::ConfigService::setStartOrder(uint32_t const& value) |
397 |
|
|
{ |
398 |
|
✗ |
(*this)->startorder = value; |
399 |
|
✗ |
} |
400 |
|
|
|
401 |
|
✗ |
Property ServiceHost::ConfigService::getParameters() const |
402 |
|
|
{ |
403 |
|
✗ |
return Property((*this)->parameters); |
404 |
|
|
} |
405 |
|
✗ |
void ServiceHost::ConfigService::setParameters(Property const& value) |
406 |
|
|
{ |
407 |
|
✗ |
Property::assignCopy((*this)->parameters, value); |
408 |
|
✗ |
} |
409 |
|
|
|
410 |
|
✗ |
ServiceHost::Config::Config() |
411 |
|
✗ |
: struct_instance_t(&gate_servicehost_config_init) |
412 |
|
|
{ |
413 |
|
✗ |
} |
414 |
|
|
|
415 |
|
✗ |
ServiceHost::Config::Config(gate_servicehost_config_t const& src) |
416 |
|
✗ |
: struct_instance_t(src) |
417 |
|
|
{ |
418 |
|
✗ |
} |
419 |
|
|
|
420 |
|
|
|
421 |
|
✗ |
String ServiceHost::Config::getId() const |
422 |
|
|
{ |
423 |
|
✗ |
return String::duplicate((*this)->id); |
424 |
|
|
} |
425 |
|
✗ |
void ServiceHost::Config::setId(String const& value) |
426 |
|
|
{ |
427 |
|
✗ |
String::assign((*this)->id, value); |
428 |
|
✗ |
} |
429 |
|
|
|
430 |
|
✗ |
String ServiceHost::Config::getVersion() const |
431 |
|
|
{ |
432 |
|
✗ |
return String::duplicate((*this)->version); |
433 |
|
|
} |
434 |
|
✗ |
void ServiceHost::Config::setVersion(String const& value) |
435 |
|
|
{ |
436 |
|
✗ |
String::assign((*this)->version, value); |
437 |
|
✗ |
} |
438 |
|
|
|
439 |
|
✗ |
ArrayList<ServiceHost::ConfigService> ServiceHost::Config::getServices() const |
440 |
|
|
{ |
441 |
|
✗ |
ArrayList<ServiceHost::ConfigService> ret; |
442 |
|
✗ |
ret.importFrom<gate_servicehost_config_service_t>(this->c_instance()->services); |
443 |
|
✗ |
return ret; |
444 |
|
|
} |
445 |
|
✗ |
void ServiceHost::Config::setServices(ArrayList<ServiceHost::ConfigService> const& value) |
446 |
|
|
{ |
447 |
|
✗ |
gate_arraylist_t arr = gate_arraylist_create(sizeof(gate_servicehost_config_service_t), NULL, 0, |
448 |
|
|
&gate_servicehost_config_service_copy_constructor, &gate_struct_destructor); |
449 |
|
✗ |
if (!arr) |
450 |
|
|
{ |
451 |
|
✗ |
GATEXX_RAISE_ERROR(results::OutOfMemory); |
452 |
|
|
} |
453 |
|
|
try |
454 |
|
|
{ |
455 |
|
✗ |
ArrayList<ServiceHost::ConfigService>::const_iterator iter = value.begin(); |
456 |
|
✗ |
ArrayList<ServiceHost::ConfigService>::const_iterator end = value.end(); |
457 |
|
✗ |
for (; iter != end; ++iter) |
458 |
|
|
{ |
459 |
|
✗ |
gate_arraylist_add(arr, iter->c_instance()); |
460 |
|
|
} |
461 |
|
✗ |
gate_arraylist_release(this->c_instance()->services); |
462 |
|
✗ |
this->c_instance()->services = arr; |
463 |
|
|
} |
464 |
|
✗ |
catch (...) |
465 |
|
|
{ |
466 |
|
✗ |
gate_arraylist_release(arr); |
467 |
|
✗ |
throw; |
468 |
|
|
} |
469 |
|
|
|
470 |
|
|
|
471 |
|
✗ |
} |
472 |
|
|
|
473 |
|
|
|
474 |
|
|
} // end of namespace sys |
475 |
|
|
} // end of namespace gate |
476 |
|
|
|