-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathClassWrapperBase.m
57 lines (42 loc) · 1.26 KB
/
ClassWrapperBase.m
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
classdef ClassWrapperBase < handle
% classdef ClassWrapperBase < handle
properties (Access = private, Hidden = true)
wrapper_fn_;
hdle_;
end
properties (Constant = true, Hidden = true)
Debug_ = false;
end
methods
function this = ClassWrapperBase(w_fn, varargin)
%function this = ClassWrapperBase(w_fn)
%
% INPUT
% w_fn a string/function handle to the mex interface
%
if ischar(w_fn)
this.wrapper_fn_ = str2func(w_fn);
elseif ishandle(w_fn)
this.wrapper_fn_ = w_fn;
else
error('input must be a function handle, or a function name');
end
this.hdle_ = this.wrapper_fn_('new', varargin{:});
end
function delete(this)
if this.Debug_
fprintf('delete class with handle %s\n', num2str(this.hdle_))
end
this.wrapper_fn_('delete', this.hdle_);
end
end % methods
methods (Access = protected)
function varargout = call_mex(this, command, varargin)
% function varargout = call_mex(command, varargin)
if(this.Debug_)
fprintf('calling %s with %d out args %d in args\n', command, nargout, nargin);
end
[varargout{1:nargout}] = this.wrapper_fn_(command, this.hdle_, varargin{:});
end
end
end