classdef (Hidden) TargetInfoFileTargetFrameworkUpgrade < RTW.TargetRegistryFileTargetFrameworkUpgrade
    %TARGETINFOFILETARGETFRAMEWORKUPGRADE Plugin for the Target
    %Framework target.upgrade tool to upgrade RTW.TargetRegistry
    %registrations from rtwTargetInfo.m files to Target Framework exported 
    %MATLAB code.

%   Copyright 2019 The MathWorks, Inc.
        
    methods (Access=protected)
        function functionArguments = setupRegistrationInjection(this, functionName, registerTargetFunctionHandle)
            
            % Validate the specified legacy file. We are only expecting an
            % rtwTargetInfo file.
            if (isequal(functionName, 'rtwTargetInfo'))                                                

                % Setup the dummy input to the legacy registration file. This
                % function handle replaces the "registerTargetInfo" function in
                % the RTW.TargetRegistry. We capture all the registrations to
                % the registrationObjects cell array on the call to feval
                % in the base class
                dummy.registerTargetInfo = registerTargetFunctionHandle;                
                functionArguments = {dummy};
            else
                
                % At this point we have an unrecognized function
                error(message('RTW:targetRegistry:invalidRegistrationFile', this.LegacyRegstrationFilename, 'rtwTargetInfo'));
            end
        end
    end    
end

