--[[----------------------------------------------------------------------------

WFCatImportManifestThreadDB.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2017 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remains the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and are protected by all applicable
intellectual property laws, including trade secret and copyright laws.
Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

----------------------------------------------------------------------------]]--

	-- Rx
local Rx = require 'Rx'
local Observable = Rx.Observable

	-- core
local KSJsonEncoder = require 'KSJsonEncoder'
local WFWorkerThread = require 'WFWorkerThread'
local WFCloseSupport = require 'WFCloseSupport'


--==============================================================================

local WFCatImportManifestThreadDB = {

	_worker = false,
	
	WFCloseSupport.addCloseSupportMethods,
	
}

--------------------------------------------------------------------------------

function WFCatImportManifestThreadDB:__init( className, ... )
	
	local workerThreadArgs = KSJsonEncoder.encodeOzUploadJson( { ... } )
	
	self._worker = WFWorkerThread( className, workerThreadArgs )
	
	 
end

--------------------------------------------------------------------------------

function WFCatImportManifestThreadDB:readData( ... )
	
	local args = { ... }
	local argsCount = select( "#", ... )
	
 	return Observable.just( nil )
		:flatMap( function()
			return self._worker:request( "readDataAsync", unpack( args, 1, argsCount ) )
		end )
	 
end

--------------------------------------------------------------------------------

function WFCatImportManifestThreadDB:writeData( ... )
	
	local args = { ... }
	local argsCount = select( "#", ... )
	
 	return Observable.just( nil )
		:flatMap( function()
			return self._worker:request( "writeDataAsync", unpack( args, 1, argsCount ) )
		end )
	
end

--------------------------------------------------------------------------------

function WFCatImportManifestThreadDB:close( ... )
	
	self._worker:close()
	self._worker = nil
	
end

--==============================================================================

return Rx.Class 'WFCatImportManifestThreadDB'( WFCatImportManifestThreadDB )
