Looking for a way to mask handle functions when calling methods or doc

Hi
I'm putting together an object-oriented program that I want others to use. Most of the classes I use derive from handles, which is all good and well except that calling
help MyClass
also displays all the handle functions (eq, delete, addListener etc.). I want to hide these to help people learning to use the program, and to keep the tab-completion menu short and snappy.
I found a work-around solution from 2008 here: http://www.tim.cz/en/nfaq/matlab-simulink/tab-completion.php
Which involves overwriting the default methods() function. Before I commit to making sense of the approach in the link, has a more elegant means of this been implemented since 2008? (We've got R2010a at my university)
Cheers

 採用された回答

Oleg Komarov
Oleg Komarov 2012 年 9 月 10 日
編集済み: Oleg Komarov 2012 年 9 月 11 日

0 投票

EDITED
Hide superclass methods using Hidden from Method Attributes
classdef foo < handle
properties
a = [];
b = [];
end
methods
function obj = foo
end
function methodA(obj)
obj.a = 1;
end
end
methods (Hidden)
function methodB(obj)
obj.b = 2;
end
function addlistener(obj, property, eventname, callback)
addlistener@addlistener(obj, property, eventname, callback)
end
end
end
a = foo;
methods(a)

6 件のコメント

Leon
Leon 2012 年 9 月 11 日
aha I'll have a go with this later tonight, but will it allow me to hide inherited methods, without having to overide them?
Oleg Komarov
Oleg Komarov 2012 年 9 月 11 日
I edited the above solution. As you can see I hid the addlistener() method and I simply call the superclass method. You can have problems however if you don't get the number of inputs right.
Sean de Wolski
Sean de Wolski 2012 年 9 月 11 日
@Oleg, couldn't you use varargin with a comma separated list expansion?
function addlistener(varargin)
addlistener@addlistener(varargin{:})
end
This would make the input handling more flexible.
Oleg Komarov
Oleg Komarov 2012 年 9 月 11 日
Nice one Sean.
Leon
Leon 2012 年 9 月 12 日
Ah thanks to you both - this is anything but elegant but it will have to do.
For anyone else interested I have lots and lots of classes, so I've made a hiddenHandle class that overwrites everything and I just inherit from that.
Again far from idea, but such is life.
Oleg Komarov
Oleg Komarov 2012 年 9 月 13 日
You could actually submit an enhancement request to the technical support.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Construct and Work with Object Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by