% SerializableDataArray - Basically a handle class to an array which allows
% methods to incrementally append values to the array which must be
% streamed rather than passed in memory

% Copyright 2020 The MathWorks, Inc.

classdef (Sealed, Hidden) SerializableDataArray < handle
    
    properties (GetAccess = private, SetAccess = private)
        % Array of data to stream
        DataArray
    end
    
    methods
        function obj = SerializableDataArray()
            obj.DataArray = parallel.internal.cluster.SerializableData.empty(0, 1);
        end
        
        function index = put(obj, data)
            obj.DataArray(end+1) = data;
            index = numel(obj.DataArray);
        end
        
        function data = getData(obj)
            data = obj.DataArray;
        end
    end
end

