(function () {

	'use strict';

	angular.module('uniflash').service('ufMemoryRanges', ufMemoryRanges);

	function ufMemoryRanges() {
		let memoryRanges: uniflash.memory.Range[] = [];

		// add a memory range to the array
		function addMemoryRange(range: uniflash.memory.Range) {
			memoryRanges.push(range);
		}

		// clear the array
		function clear() {
			memoryRanges = [];
		}

		function getMemoryRange(index: number): uniflash.memory.Range {
			return memoryRanges[index];
		}

		function getMemoryRanges(): uniflash.memory.Range[] {
			return memoryRanges;
		}

		return {
			addMemoryRange: addMemoryRange,
			clear: clear,
			getMemoryRange: getMemoryRange,
			getMemoryRanges: getMemoryRanges,
		};
	}

})();
