view +mpm/PersistentState.m @ 38:16d56bf04117

Change place of storage of the state
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 05 Dec 2018 15:43:13 +0100
parents 29da718b8e7f
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