% ForwardingMJSAccess - Decorator for MJSAccess forwards all methods to
% Access. Inherit from this class to overwrite selected methods only.

% Copyright 2020-2021 The MathWorks, Inc.

classdef (Hidden) ForwardingMJSAccess < parallel.internal.cluster.IMJSAccess
    
    properties (GetAccess = protected, SetAccess = immutable)
        % parallel.internal.cluster.IMJSAccess to delegate to
        Access;
    end
        
    methods
        function obj = ForwardingMJSAccess(access)
            obj.Access = access;
        end
    end
    
    % parallel.internal.cluster.IMJSAccess methods
    methods
        function updated = refreshClient(obj)
            updated = obj.Access.refreshClient();
        end
        
        function ping(obj)
           obj.Access.ping();
        end
        
        function serialisedToken = serialiseHashedCredential(obj, digestAlgorithmChain, username, hashedBytes)
            serialisedToken = obj.Access.serialiseHashedCredential(digestAlgorithmChain, username, hashedBytes);
        end
        
        function addNewUser(obj, username, hashedCredential, encryptedPassword, sessionID, salt)
            if nargin < 3
                % No password provided
                obj.Access.addNewUser(username);
            elseif nargin < 4
                % No encrypted password provided
                obj.Access.addNewUser(username, hashedCredential);
            else
                obj.Access.addNewUser(username, hashedCredential, encryptedPassword, sessionID, salt);
            end
        end
        
        function changeCredentialsOfExistingUser(obj, username, hashedOldCredentials, hashedCredential, encryptedPassword, sessionID, salt)
            if nargin < 5
                % No encrypted password provided
                obj.Access.changeCredentialsOfExistingUser(username, hashedOldCredentials, hashedCredential);
            else
                obj.Access.changeCredentialsOfExistingUser(username, hashedOldCredentials, hashedCredential, encryptedPassword, sessionID, salt);
            end
        end
        
        function checkCredentialsOfExistingUser(obj, username, hashedCredentials)
            obj.Access.checkCredentialsOfExistingUser(username, hashedCredentials);
        end
        
        function userExists = userExists(obj, username)
            userExists = obj.Access.userExists(username);
        end
        
        function values = getClusterProperties(obj, propertyNames, hashedCredentials)
            values = obj.Access.getClusterProperties(propertyNames, hashedCredentials);
        end
        
        function values = getTaskProperties(obj, taskIDs, propertyNames, hashedCredentials)
            values = obj.Access.getTaskProperties(taskIDs, propertyNames, hashedCredentials);
        end
        
        function values = getJobProperties(obj, jobIDs, propertyNames, hashedCredentials)
            values = obj.Access.getJobProperties(jobIDs, propertyNames, hashedCredentials);
        end
        
        function setClusterProperties(obj, propertyNames, propertyValues, hashedCredentials)
            obj.Access.setClusterProperties(propertyNames, propertyValues, hashedCredentials);
        end
        
        function setTaskProperties(obj, taskIDs, propertyNames, propertyValues, hashedCredentials)
            obj.Access.setTaskProperties(taskIDs, propertyNames, propertyValues, hashedCredentials);
        end
        
        function setJobProperties(obj, jobIDs, propertyNames, propertyValues, hashedCredentials)
            obj.Access.setJobProperties(jobIDs, propertyNames, propertyValues, hashedCredentials);
        end

        function listener = createMJSEventListener(obj, callback)
            listener = obj.Access.createMJSEventListener(callback);
        end

        function sessionID = createClientSession(obj)
            sessionID = obj.Access.createClientSession();
        end

        function closeClientSession(obj, clientSessionID)
            obj.Access.closeClientSession(clientSessionID);
        end
        
        function session = createSession(obj, supportedEncryptionAlgorithms, supportedDigestAlgorithms)           
            session = obj.Access.createSession(supportedEncryptionAlgorithms, supportedDigestAlgorithms);
        end
        
        function closeSession(obj, sessionID)
            obj.Access.closeSession(sessionID);
        end
        
        function jobIDNumAndType = createJob(obj, user, entitlement, hashedCredentials, encryptor)
            jobIDNumAndType = obj.Access.createJob(user, entitlement, hashedCredentials, encryptor);
        end
        
        function jobIDNumAndType = createCommunicatingSPMDJob(obj, user, entitlement, hashedCredentials, encryptor)
            jobIDNumAndType = obj.Access.createCommunicatingSPMDJob(user, entitlement, hashedCredentials, encryptor);
        end
        
        function jobIDNumAndType = createCommunicatingPoolJob(obj, user, entitlement, hashedCredentials, encryptor)
            jobIDNumAndType = obj.Access.createCommunicatingPoolJob(user, entitlement, hashedCredentials, encryptor);
        end
        
        function jobIDNumAndType = createConcurrentJob(obj, user, entitlement, hashedCredentials, encryptor)
            jobIDNumAndType = obj.Access.createConcurrentJob(user, entitlement, hashedCredentials, encryptor);
        end
        
        function taskIDAndNums = createTask(obj, jobIDs, taskFcns, numArgsOut, argsIn, ...
            taskNames, timeouts, captureDiary, maxNumRetries, funcNames, containsCallbacks, hashedCredentials, clientSessionID)
            taskIDAndNums = obj.Access.createTask(jobIDs, taskFcns, numArgsOut, argsIn, ...
                taskNames, timeouts, captureDiary, maxNumRetries, funcNames, containsCallbacks, hashedCredentials, clientSessionID);
        end
        
        function getClusterLogs(obj, saveLocation, hashedCredentials)
            obj.Access.getClusterLogs(saveLocation, hashedCredentials);
        end
        
        function pauseQueue(obj)
            obj.Access.pauseQueue();
        end
        
        function resumeQueue(obj)
            obj.Access.resumeQueue();
        end
        
        function promoteJob(obj, jobID)
            obj.Access.promoteJob(jobID);
        end
        
        function demoteJob(obj, jobID)
            obj.Access.demoteJob(jobID);
        end
        
        function jobIDNumAndTypesByState = getJobsByState(obj, states)
            jobIDNumAndTypesByState = obj.Access.getJobsByState(states);
        end
        
        function addEventListener(obj, workUnitIDs, sessionID)
            obj.Access.addEventListener(workUnitIDs, sessionID);
        end

        function removeEventListener(obj, workUnitIDs, sessionID)
            obj.Access.removeEventListener(workUnitIDs, sessionID);
        end

        function cancelJobs(obj, jobIDs, cancelMessages, hashedCredentials)
            obj.Access.cancelJobs(jobIDs, cancelMessages, hashedCredentials);
        end
        
        function cancelTasks(obj, taskIDs, cancelMessages, hashedCredentials)
            obj.Access.cancelTasks(taskIDs, cancelMessages, hashedCredentials);
        end
        
        function destroyJobs(obj, jobIDs, hashedCredentials)
            obj.Access.destroyJobs(jobIDs, hashedCredentials);
        end
        
        function destroyTasks(obj, taskIDs, hashedCredentials)
            obj.Access.destroyTasks(taskIDs, hashedCredentials);
        end
        
        function submitJobs(obj, jobIDs, hashedCredentials)
            obj.Access.submitJobs(jobIDs, hashedCredentials);
        end
        
        function submitTaskResult(obj, taskID, attempt, result, error, ...
            errorMessage, errorIdentifier, warnings, diary, hashedCredentials)
            obj.Access.submitTaskResult(taskID, attempt, result, error, ...
                errorMessage, errorIdentifier, warnings, diary, hashedCredentials);
        end
        
        function setEnvironmentVariableValues(obj, jobIDs, environmentVariableMaps, hashedCredentials, encryptor)
            obj.Access.setEnvironmentVariableValues(jobIDs, environmentVariableMaps, hashedCredentials, encryptor);
        end
        
        function future = getJobStatusDataAsync(obj, jobIDs)
            future = obj.Access.getJobStatusDataAsync(jobIDs);
        end
        
        function hAddRemoteInvocationListener(obj, listener)
            obj.Access.hAddRemoteInvocationListener(listener);
        end
    end
end
