view +mpm/PersistentState.m @ 41:17ac3ce49b55 default tip

Add todo
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 23 Jun 2025 15:25:27 +0200
parents 16d56bf04117
children
line wrap: on
line source

classdef PersistentState < handle
    properties
        prefGroup
        subpaths
    end

    methods
        function obj = PersistentState(prefGroup)
            obj.prefGroup = prefGroup;

            try
                % Read state from file
                obj.subpaths = getpref(prefGroup, 'state');
            catch
                % If reading the file failed, create an empty state
                obj.subpaths = containers.Map();
            end
        end

        function s = saveState(obj)
            setpref(obj.prefGroup, 'state', obj.subpaths);
        end
    end
end