diff --git a/@quality/display.m b/@quality/display.m new file mode 100644 index 0000000000000000000000000000000000000000..a706f89c696f493232ea9c99cf862fe36e1e2852 --- /dev/null +++ b/@quality/display.m @@ -0,0 +1,9 @@ +function display(this) + +%$Id: display.m 53 2006-03-03 13:41:22Z jgrelet $ + +try + disp(struct(this)); +catch + err ('quality', 'display', lasterr) ; +end diff --git a/@quality/get.m b/@quality/get.m new file mode 100644 index 0000000000000000000000000000000000000000..06662bc2669e8c2cf4f8ac5bd176282c30b01092 --- /dev/null +++ b/@quality/get.m @@ -0,0 +1,52 @@ +function result = get( self, varargin ) + +% quality/get -- get structure of "quality" object. +% +% Input +% ----- +% self ........... instance of 'quality' object +% key ........... types +% member ........... attribute member +% +% Output +% ------ +% result ........... structure for the key (hastable) +% +% if key dosn't exist, return empty struct + +% $Id$ + +% Test variable argument list +% --------------------------- +switch (nargin) + + % Return the list of key + % ---------------------- + case 1 + result = keys(self); + + % Return for a valid key the hash (structure) + % ------------------------------------------- + case 2 + if ~isempty( find(strcmp(keys(self), varargin{1}))) + result = get(self.hashtable, varargin{1}); + else + result = {}; + end + + % Return the hash member value + % ---------------------------- + 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}); + else + result = {}; + end + + otherwise + error('Wrong input args'); +end diff --git a/@quality/keys.m b/@quality/keys.m new file mode 100644 index 0000000000000000000000000000000000000000..8050e33513f5fc0ff5f7ea31cd2bd349b24995a1 --- /dev/null +++ b/@quality/keys.m @@ -0,0 +1,10 @@ +function result = types(self) + +% quality/types -- Get all the types currently being used in the internal +% quality hash +% result = types(self) + +% $Id$ + +result = keys(self.hashtable); + diff --git a/@quality/quality.csv b/@quality/quality.csv new file mode 100644 index 0000000000000000000000000000000000000000..db1f11dc95d381a002d7fb5f5e6d17b48a2af85f --- /dev/null +++ b/@quality/quality.csv @@ -0,0 +1,10 @@ +NO_CONTROL;No control;0;k;on +GOOD;Good;1;b;on +PROBABLY_GOOD;Probably Good;2;g;on +PROBABLY_BAD;Probably bad;3;m;on +BAD;Bad;4;r;on +HARBOUR;Harbour;5;c;on +NOT_USED;Not used;6;w;off +NOT_USED;Not used;7;w;off +INTERPOLATED_VALUE;Interpolated value;8;k;off +MISSING_VALUE;Missing value;9;k;off diff --git a/@quality/quality.m b/@quality/quality.m new file mode 100644 index 0000000000000000000000000000000000000000..26885153e47aac07fe9978935b09e35ed494aee5 --- /dev/null +++ b/@quality/quality.m @@ -0,0 +1,51 @@ +function q = quality( varargin ) +% QUALITY constructor function for QUALITY object +% +% Use: q = quality( <file> ) +% +% by default: q = quality +% use @quality/quality.scv file +% +% example: +% Get all types get(q) +% get internal has get(q, 'NO_CONTROL') +% get specific value get(q, 'NO_CONTROL','code') +% +% $Id$ + +switch nargin + case 0 % create default object + file = 'quality.csv'; + case 1 + if( isa(varargin{1}, 'char')) + file = varargin{1}; + else + error('Wrong input argument'); + end + otherwise + error('Wrong number of input arguments'); +end + +if exist(file, 'file') ~= 2 + disp(['The specified data file ' file ' does not exist ...']); + disp('Or is not in the directory which is on the MATLAB search path'); + datagui_closereq_callback; +end + +[type,label,code,color,state] = textread(... + file,'%s%s%d%s%s','delimiter',';'); + +q.file = which(file); +q.size = length(type); +types = hashtable; + +for i=1:length(type) + s.label = label{i}; + s.code = code(i); + s.color = color{i}; + s.state = state{i}; + + types = put(types, type{i}, s); +end + +q = class(q, 'quality', types );