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

NmbProfileCatalog.lua

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

ADOBE CONFIDENTIAL
------------------
Copyright 2018 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.

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

	-- RxLua
local Rx = require 'Rx'

local WFArguments = require 'WFArguments'
local WFCatalogBase = require 'WFCatalogBase'
local WFObjectProxy = require 'WFObjectProxy'
local NmbStdProfileInfoCache = require 'NmbStdProfileInfoCache'

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

local check = assert( WFArguments.check )

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

local nmbProfileCatalogPrototype = {
	
	WFCatalogBase,
		--superclass
	
	_initOptArgs = false,
		-- (table) optional args passed in at __init (needed for __inited)
		
	_standardProfileCache = false,
		-- (NmbStdProfileInfoCache) Responsible for caching the standard profiles
		-- in the catalog.
		
	class = {},
	
}

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

--[[!
	\brief Creates a NmbProfileCatalog.
	
	\param ozCatalogSpec (WFCatSpec) specification for the catalog user and catalogID
	\param rootCatalogPath (string) root directory under which to store catalog related files
	\param optArgs (table) optional args for doc store index store creation. These are in addition
			to any optional args allowed by WFCatalogBase
		- deletionBacklogPath -- path to deletion backlog db
]]--

function nmbProfileCatalogPrototype:__init( ozCatalogSpec, rootCatalogPath, optArgs )
	
	check( 'NmbProfileCatalog', 'WFCatSpec', 'string', '?table' )
	
	self._initOptArgs = optArgs or {}
	
	-- these arguments are returned to be used in the superclass (WFCatalog) init
	return ozCatalogSpec, rootCatalogPath, optArgs
	
end

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

--[[ 
	\brief Completes initialization of the NmbCatalog after the superclass has been initialized
]]--
function nmbProfileCatalogPrototype:__inited( )

	check( 'NmbProfileCatalog' )
					
	local profileCache = NmbStdProfileInfoCache( self )
		
	self:setOwned {
		_standardProfileCache = profileCache,
	}
	
end

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

function nmbProfileCatalogPrototype:getProfileCache()

	check( 'NmbProfileCatalog' )
	return self._standardProfileCache

end

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

local NmbProfileCatalog_class = Rx.Class( 'NmbProfileCatalog', nmbProfileCatalogPrototype )

return WFObjectProxy( 'WFCatalog', NmbProfileCatalog_class, nil, true )
