1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
%{
**********************************************************************
Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
This copy of Ice is licensed to you under the terms described in the
ICE_LICENSE file included in this distribution.
**********************************************************************
%}
classdef Communicator < IceInternal.WrapperObject
methods
function obj = Communicator(impl, initData)
if ~isa(impl, 'lib.pointer')
throw(MException('Ice:ArgumentException', 'invalid argument'));
end
obj = obj@IceInternal.WrapperObject(impl);
obj.initData = initData;
enc = obj.getProperties().getProperty('Ice.Default.EncodingVersion');
if isempty(enc)
obj.encoding = Ice.currentEncoding();
else
arr = sscanf(enc, '%u.%u');
if length(arr) ~= 2
throw(MException('Ice:ArgumentException', 'invalid value for Ice.Default.EncodingVersion'));
end
obj.encoding = Ice.EncodingVersion(arr(1), arr(2));
end
end
function destroy(obj)
obj.iceCall('destroy');
end
function f = destroyAsync(obj)
future = libpointer('voidPtr');
obj.iceCall('destroyAsync', future);
assert(~isNull(future));
f = Ice.Future(future, 'destroy', 0, 'Ice_SimpleFuture', @(fut) fut.iceCall('check'));
end
function r = stringToProxy(obj, str)
impl = libpointer('voidPtr');
obj.iceCall('stringToProxy', str, impl);
if isNull(impl)
r = [];
else
r = Ice.ObjectPrx(obj, obj.encoding, impl);
end
end
function r = proxyToString(obj, proxy)
if isempty(proxy)
r = '';
elseif ~isa(proxy, 'Ice.ObjectPrx')
throw(MException('Ice:ArgumentException', 'expecting a proxy'));
else
r = proxy.ice_toString();
end
end
function r = propertyToProxy(obj, prop)
impl = libpointer('voidPtr');
obj.iceCall('propertyToProxy', prop, impl);
if isNull(impl)
r = [];
else
r = Ice.ObjectPrx(obj, obj.encoding, impl);
end
end
function r = proxyToProperty(obj, proxy, prop)
if isempty(proxy)
r = containers.Map('KeyType', 'char', 'ValueType', 'char');
elseif ~isa(proxy, 'Ice.ObjectPrx')
throw(MException('Ice:ArgumentException', 'expecting a proxy'));
else
r = obj.iceCallWithResult('proxyToProperty', proxy.iceGetImpl(), prop);
end
end
function r = identityToString(obj, id)
r = obj.iceCallWithResult('identityToString', id);
end
function r = getProperties(obj)
if isempty(obj.properties_)
impl = libpointer('voidPtr');
obj.iceCall('getProperties', impl);
obj.properties_ = Ice.Properties(impl);
end
r = obj.properties_;
end
function r = getLogger(obj)
if isempty(obj.logger)
impl = libpointer('voidPtr');
obj.iceCall('getLogger', impl);
obj.logger = Ice.Logger(impl);
end
r = obj.logger;
end
function r = getDefaultRouter(obj)
impl = libpointer('voidPtr');
obj.iceCall('getDefaultRouter', impl);
if ~isNull(impl)
r = Ice.RouterPrx(impl, obj);
else
r = [];
end
end
function setDefaultRouter(obj, proxy)
if isempty(proxy)
impl = libpointer('voidPtr');
elseif ~isa(proxy, 'Ice.RouterPrx')
throw(MException('Ice:ArgumentException', 'expecting a router proxy'));
else
impl = proxy.iceGetImpl();
end
obj.iceCall('setDefaultRouter', impl);
end
function r = getDefaultLocator(obj)
impl = libpointer('voidPtr');
obj.iceCall('getDefaultLocator', impl);
if ~isNull(impl)
r = Ice.LocatorPrx(impl, obj);
else
r = [];
end
end
function setDefaultLocator(obj, proxy)
if isempty(proxy)
impl = libpointer('voidPtr');
elseif ~isa(proxy, 'Ice.LocatorPrx')
throw(MException('Ice:ArgumentException', 'expecting a locator proxy'));
else
impl = proxy.iceGetImpl();
end
obj.iceCall('setDefaultLocator', impl);
end
function r = getValueFactoryManager(obj)
r = obj.initData.valueFactoryManager;
end
function flushBatchRequests(obj, mode)
obj.iceCall('flushBatchRequests', mode);
end
function f = flushBatchRequestsAsync(obj, mode)
future = libpointer('voidPtr');
obj.iceCall('flushBatchRequestsAsync', mode, future);
assert(~isNull(future));
r = Ice.Future(future, 'flushBatchRequests', 0, 'Ice_SimpleFuture', @(fut) fut.iceCall('check'));
end
function r = getClassResolver(obj)
if isempty(obj.classResolver) % Lazy initialization.
obj.classResolver = IceInternal.ClassResolver(obj.getProperties());
end
r = obj.classResolver;
end
function r = getCompactIdResolver(obj)
r = obj.initData.compactIdResolver;
end
function r = getEncoding(obj)
r = obj.encoding;
end
function r = createOutputStream(obj, encoding)
if nargin == 1
encoding = obj.encoding;
end
r = Ice.OutputStream(obj, encoding);
end
end
properties(Access=private)
initData
classResolver
encoding
logger
properties_
end
end
|