Skip to content
Snippets Groups Projects
Commit 594c3bc1 authored by jacques.grelet_ird.fr's avatar jacques.grelet_ird.fr
Browse files

add new methods set and isfield, update get in tsg_nc class

parent 2d5b722b
No related branches found
No related tags found
No related merge requests found
function result = get( self, varargin )
% tsg_ncvar/get -- get structure of "tsg_ncvar" object.
% tsg_nc/get -- get structure of "tsg_ncv" object.
%
% Input
% -----
% self ........... instance of 'tsg_ncvar' object
% key ........... GF3 code
% self ........... instance of 'tsg_nc' object
% key ........... hashtable key
% member ........... attribute member
%
% Output
% ------
% result ........... structure for the key (hastable)
% result ........... structure for the key (hashtable)
%
% if key dosn't exist, return empty structure
%
% if key dosn't exist, return empty struct
% $Id$
% Test variable argument list
......@@ -38,8 +38,10 @@ switch (nargin)
% ----------------------------
case 3
% call method get for an hashtable object
% ---------------------------------------
result = get(self, varargin{1});
% test if third arg is a valid member of the struct in the hash
% -------------------------------------------------------------
if ~isempty( find(strcmp(keys(self), varargin{1})) ) && ...
isfield(result,varargin{2})
result = result.(varargin{2});
......
function bool = isfield( self, fieldname )
% tsg_nc/get_fieldnames -- get internal structure fieldnames of "tsg_nc" object.
%
% Input
% -----
% self ........... an instance of 'tsg_nc' object
% fieldname ........... is field of internal structure ?
%
% Output
% ------
% bool .......... true if fieldname is internal structure
% $Id: get_fieldnames.m 92 2008-01-09 11:10:40Z jgrelet $
% get cell of keys inside object
% ------------------------------
c = get(self);
if isempty(c)
warning('Empty object') ;
else
% get structure for the first element
theStruc = get(self,c{1});
bool = isfield(theStruc, fieldname);
end
function self = set( self, varargin )
function self = set( self, key, theStruct )
% tsg_ncvar/set -- set new pair key/value for "tsg_ncvar" object.
% tsg_nc/set -- set new pair key/value for "tsg_nc" object.
%
% not implemented yet
% Input
% -------
% self ........... instance of 'tsg_nc' object
% key ........... hashtable key
% theStruct ........... hashtable structure
%
% Output
% --------
% self ........... instance of updated 'tsg_nc' object
%
% $Id$
% populate the internal hashtable
% -------------------------------
self.hashtable = put(self.hashtable, key, theStruct);
% $Id£
% update self.size
% ----------------
self.size = numel(keys(self.hashtable));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment