classdef CellExplorerGeneral < types.core.LabMetaData & types.untyped.GroupClass
% CELLEXPLORERGENERAL metadata necessary for full round trip in CellExplorer


% PROPERTIES
properties
    acgs_log10; % doc for log10
    isis_log10; % doc for log10
    saveAs; % doc for saveAs
    session_investigator; % doc for investigator
    session_sessionType; % doc for sessionType
    session_spikeSortingMethod; % doc for spikeSortingMethod
end

methods
    function obj = CellExplorerGeneral(varargin)
        % CELLEXPLORERGENERAL Constructor for CellExplorerGeneral
        %     obj = CELLEXPLORERGENERAL(parentname1,parentvalue1,..,parentvalueN,parentargN,name1,value1,...,nameN,valueN)
        % acgs_log10 = float
        % isis_log10 = float
        % saveAs = char
        % session_investigator = char
        % session_sessionType = char
        % session_spikeSortingMethod = char
        obj = obj@types.core.LabMetaData(varargin{:});
        
        
        p = inputParser;
        p.KeepUnmatched = true;
        p.PartialMatching = false;
        p.StructExpand = false;
        addParameter(p, 'acgs_log10',[]);
        addParameter(p, 'isis_log10',[]);
        addParameter(p, 'saveAs',[]);
        addParameter(p, 'session_investigator',[]);
        addParameter(p, 'session_sessionType',[]);
        addParameter(p, 'session_spikeSortingMethod',[]);
        misc.parseSkipInvalidName(p, varargin);
        obj.acgs_log10 = p.Results.acgs_log10;
        obj.isis_log10 = p.Results.isis_log10;
        obj.saveAs = p.Results.saveAs;
        obj.session_investigator = p.Results.session_investigator;
        obj.session_sessionType = p.Results.session_sessionType;
        obj.session_spikeSortingMethod = p.Results.session_spikeSortingMethod;
        if strcmp(class(obj), 'types.ndx_cell_explorer.CellExplorerGeneral')
            types.util.checkUnset(obj, unique(varargin(1:2:end)));
        end
    end
    %% SETTERS
    function obj = set.acgs_log10(obj, val)
        obj.acgs_log10 = obj.validate_acgs_log10(val);
    end
    function obj = set.isis_log10(obj, val)
        obj.isis_log10 = obj.validate_isis_log10(val);
    end
    function obj = set.saveAs(obj, val)
        obj.saveAs = obj.validate_saveAs(val);
    end
    function obj = set.session_investigator(obj, val)
        obj.session_investigator = obj.validate_session_investigator(val);
    end
    function obj = set.session_sessionType(obj, val)
        obj.session_sessionType = obj.validate_session_sessionType(val);
    end
    function obj = set.session_spikeSortingMethod(obj, val)
        obj.session_spikeSortingMethod = obj.validate_session_spikeSortingMethod(val);
    end
    %% VALIDATORS
    
    function val = validate_acgs_log10(obj, val)
        val = types.util.checkDtype('acgs_log10', 'float', val);
        if isa(val, 'types.untyped.DataStub')
            valsz = val.dims;
        elseif istable(val)
            valsz = height(val);
        else
            valsz = size(val);
        end
        validshapes = {[Inf]};
        types.util.checkDims(valsz, validshapes);
    end
    function val = validate_isis_log10(obj, val)
        val = types.util.checkDtype('isis_log10', 'float', val);
        if isa(val, 'types.untyped.DataStub')
            valsz = val.dims;
        elseif istable(val)
            valsz = height(val);
        else
            valsz = size(val);
        end
        validshapes = {[Inf]};
        types.util.checkDims(valsz, validshapes);
    end
    function val = validate_saveAs(obj, val)
        val = types.util.checkDtype('saveAs', 'char', val);
    end
    function val = validate_session_investigator(obj, val)
        val = types.util.checkDtype('session_investigator', 'char', val);
    end
    function val = validate_session_sessionType(obj, val)
        val = types.util.checkDtype('session_sessionType', 'char', val);
    end
    function val = validate_session_spikeSortingMethod(obj, val)
        val = types.util.checkDtype('session_spikeSortingMethod', 'char', val);
    end
    %% EXPORT
    function refs = export(obj, fid, fullpath, refs)
        refs = export@types.core.LabMetaData(obj, fid, fullpath, refs);
        if any(strcmp(refs, fullpath))
            return;
        end
        io.writeGroup(fid, [fullpath '/acgs']);
        if ~isempty(obj.acgs_log10)
            if startsWith(class(obj.acgs_log10), 'types.untyped.')
                refs = obj.acgs_log10.export(fid, [fullpath '/acgs/log10'], refs);
            elseif ~isempty(obj.acgs_log10)
                io.writeDataset(fid, [fullpath '/acgs/log10'], obj.acgs_log10, 'forceArray');
            end
        end
        io.writeGroup(fid, [fullpath '/isis']);
        if ~isempty(obj.isis_log10)
            if startsWith(class(obj.isis_log10), 'types.untyped.')
                refs = obj.isis_log10.export(fid, [fullpath '/isis/log10'], refs);
            elseif ~isempty(obj.isis_log10)
                io.writeDataset(fid, [fullpath '/isis/log10'], obj.isis_log10, 'forceArray');
            end
        end
        if ~isempty(obj.saveAs)
            if startsWith(class(obj.saveAs), 'types.untyped.')
                refs = obj.saveAs.export(fid, [fullpath '/saveAs'], refs);
            elseif ~isempty(obj.saveAs)
                io.writeDataset(fid, [fullpath '/saveAs'], obj.saveAs);
            end
        end
        io.writeGroup(fid, [fullpath '/session']);
        if ~isempty(obj.session_investigator)
            if startsWith(class(obj.session_investigator), 'types.untyped.')
                refs = obj.session_investigator.export(fid, [fullpath '/session/investigator'], refs);
            elseif ~isempty(obj.session_investigator)
                io.writeDataset(fid, [fullpath '/session/investigator'], obj.session_investigator);
            end
        end
        io.writeGroup(fid, [fullpath '/session']);
        if ~isempty(obj.session_sessionType)
            if startsWith(class(obj.session_sessionType), 'types.untyped.')
                refs = obj.session_sessionType.export(fid, [fullpath '/session/sessionType'], refs);
            elseif ~isempty(obj.session_sessionType)
                io.writeDataset(fid, [fullpath '/session/sessionType'], obj.session_sessionType);
            end
        end
        io.writeGroup(fid, [fullpath '/session']);
        if ~isempty(obj.session_spikeSortingMethod)
            if startsWith(class(obj.session_spikeSortingMethod), 'types.untyped.')
                refs = obj.session_spikeSortingMethod.export(fid, [fullpath '/session/spikeSortingMethod'], refs);
            elseif ~isempty(obj.session_spikeSortingMethod)
                io.writeDataset(fid, [fullpath '/session/spikeSortingMethod'], obj.session_spikeSortingMethod);
            end
        end
    end
end

end