classdef (Sealed) config < handle
    
    properties (Constant)
        % If you are on UNIX (Linux or macOS), add here the path to the
        % graphviz tool "dot": type "which dot" in the command line, 
        % and copy paste here the output of it.
        % E.g., dir_dot = "/opt/local/bin/dot"
        path_dot = "dot"
        
        dir_initial_images = "initial_images"
        dir_images = "images"
        dir_dbms = "dbms"
        dir_measures = "measures"
        dbm_format = "csv";

        % dbm other
        dbm_h1_nodes = 50
        dbm_h2_nodes = 20
        dbm_learning_rate = 0.001
        dbm_initial_non_zero_weights = false
        
        % dbm equilibriums
        dbm_compute_similarities = false
        dbm_n_mean_field_echoes = 10
        dbm_n_gibbs_echoes = 10
        dbm_use_echoes = 30
    end
    
    properties (SetAccess = immutable)
        path_initial_images
        path_images
        path_dbms
        path_measures
    end
    
    methods (Access = private)
        function obj = config
            obj.path_initial_images = fullfile(pwd, obj.dir_initial_images);
            obj.path_images = fullfile(pwd, obj.dir_images);
            obj.path_dbms = fullfile(pwd, obj.dir_dbms);
            obj.path_measures = fullfile(pwd, obj.dir_measures);
        end
    end
    
    methods (Static)
        function singleObj = getInstance
            persistent localObj
            if isempty(localObj) || ~isvalid(localObj)
                localObj = config;     
                if ~exist(localObj.path_initial_images, 'dir')
                    error("folder initial_images is missing")
                end
                if ~exist(localObj.path_images, 'dir')
                    mkdir(localObj.path_images)
                end
                if ~exist(localObj.path_dbms, 'dir')
                    mkdir(localObj.path_dbms)
                end
                if ~exist(localObj.path_measures, 'dir')
                    mkdir(localObj.path_measures)
                end
            end
            singleObj = localObj;
        end
    end

end