|
149 | 149 | properties (SetAccess = private, GetAccess = private) |
150 | 150 | strRealFilename; % Binary data file on disk (real part of tensor) |
151 | 151 | strCmplxFilename; % Binary data file on disk (complex part of tensor) |
| 152 | + bReadOnly = false; % Should the data be protected from writing? |
152 | 153 | hRealContent; % File handle for data (real part) |
153 | 154 | hCmplxContent; % File handle for data (complex part) |
154 | 155 | bTemporary; % A flag which records whether a temporary file was created by MappedTensor |
|
198 | 199 | vbKeepArg(nArg:nArg+1) = false; |
199 | 200 | nArg = nArg + 1; |
200 | 201 |
|
| 202 | + case {'readonly'} |
| 203 | + % - Read-only or read/write status was specified |
| 204 | + mtVar.bReadOnly = logical(varargin{nArg+1}); |
| 205 | + vbKeepArg(nArg:nArg+1) = false; |
| 206 | + nArg = nArg + 1; |
| 207 | + |
201 | 208 | otherwise |
202 | 209 | % - No other properties are supported |
203 | 210 | error('MappedTensor:InvalidProperty', ... |
@@ -447,6 +454,11 @@ function delete(mtVar) |
447 | 454 |
|
448 | 455 | % subsasgn - METHOD Overloaded subsasgn |
449 | 456 | function [mtVar] = subsasgn(mtVar, subs, tfData) |
| 457 | + % - Test read-only status if tensor |
| 458 | + if (mtVar.bReadOnly) |
| 459 | + error('MappedTensor:ReadProtect', '*** MappedTensor: Attempted write to a read-only tensor.'); |
| 460 | + end |
| 461 | + |
450 | 462 | % - Test real/complex nature of input and current tensor |
451 | 463 | if (~isreal(tfData)) |
452 | 464 | % - The input data is complex |
@@ -578,6 +590,36 @@ function delete(mtVar) |
578 | 590 | bIsReal = ~mtVar.bIsComplex; |
579 | 591 | end |
580 | 592 |
|
| 593 | + % islogical - METHOD Overloaded islogical function |
| 594 | + function [bIsLogical] = islogical(mtVar) |
| 595 | + bIsLogical = isequal(mtVar.strClass, 'logical'); |
| 596 | + end |
| 597 | + |
| 598 | + % isnumeric - METHOD Overloaded isnumeric function |
| 599 | + function [bIsNumeric] = isnumeric(mtVar) |
| 600 | + bIsNumeric = ~islogical(mtVar); |
| 601 | + end |
| 602 | + |
| 603 | + % isscalar - METHOD Overloaded isscalar function |
| 604 | + function [bIsScalar] = isscalar(mtVar) |
| 605 | + bIsScalar = numel(mtVar) == 1; |
| 606 | + end |
| 607 | + |
| 608 | + % ismatrix - METHOD Overloaded ismatrix function |
| 609 | + function [bIsMatrix] = ismatrix(mtVar) |
| 610 | + bIsMatrix = ~isscalar(mtVar); |
| 611 | + end |
| 612 | + |
| 613 | + % ischar - METHOD Overloaded ischar function |
| 614 | + function [bIsChar] = ischar(mtVar) |
| 615 | + bIsChar = isequal(mtVar.strClass, 'char'); |
| 616 | + end |
| 617 | + |
| 618 | + % isnan - METHOD Overloaded isnan function |
| 619 | + function [bIsNan] = isnan(mtVar) %#ok<MANU> |
| 620 | + bIsNan = false; |
| 621 | + end |
| 622 | + |
581 | 623 | %% Overloaded methods (uminus, uplus, times, mtimes, ldivide, rdivide, mldivide, mrdivide) |
582 | 624 |
|
583 | 625 | % uminus - METHOD Overloaded uminus operator (-mtVar) |
|
0 commit comments