// RsSPCmdFactory.h : Declaration of the CRsSPCmdFactory
#pragma once



// CRsSPCmdFactory
class ATL_NO_VTABLE CRsSPCmdFactory :
	public CComObjectRootEx<CComGlobalsThreadModel>,
	public IRsCmdFactory
{
public:
	CRsSPCmdFactory()
	{
	}

	BEGIN_COM_MAP(CRsSPCmdFactory)
        COM_INTERFACE_ENTRY(IRsCmdFactory)
        COM_INTERFACE_ENTRY2(IUnknown, IRsCmdFactory)
    END_COM_MAP()

	DECLARE_CLASSFACTORY_SINGLETON(CRsSPCmdFactory)
    DECLARE_NOT_AGGREGATABLE(CRsSPCmdFactory)
    DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}
	
	void FinalRelease() 
	{
	}

public:

	/**@name Methods of interface IRsCmdFactory */
	//@{
        
	/** Creates an uninitialized command object.
		@param riid [in] Reference to the identifier of the node 
		@param ppNode [out] Address of Node Interface variable that receives the interface pointer 
			to newly created object.
		@return This method supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following: 
		@return S_OK The specified object was created. 
		@return E_NOTIMPL This command factory does not support instancing nodes
	*/
	STDMETHOD(CreateInstance)(const IID *riid, IRsCommand** ppCmd);
        
	/** Creates an uninitialized command object that is part of an aggregate.
			@param pUnkOuter [in] pointer to the controlling IUnknown interface of the aggregate 
            @param riid [in] Reference to the identifier of the node.
			@param ppCmd [out] Address of Command Interface variable that receives the interface pointer 
				   to newly created object.
		    @return This method supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following: 
			@return S_OK The specified object was created. 
			@return E_NOTIMPL This node factory does not support instancing agregated nodes
    */
	STDMETHOD(CreateAggInstance)(IUnknown* pUnkOuter, const IID *riid, IUnknown** ppvObject);
		
	/** Enumerates commands's descriptors available in current factory object
            @ppEnumCmdDesc Pointer to an IRsEnumCmdDesc interface.
			@return S_OK Method succeeded.
			@return E_NOTIMPL This command factory does not support enumeration of Command's descriptors
    */
	STDMETHOD(EnumCommandDesc)(IRsEnumCmdDesc** ppEnumCmdDesc);

	/** Enumerates named items objects available in current factory object
            @ppEnum Pointer to an IRsEnumNamedItem interface.
			@return S_OK Method succeeded.
			@return E_NOTIMPL This command factory does not support enumeration of Script object descriptors
    */
	STDMETHOD(EnumScriptObjects)(IRsEnumNamedItem** ppEnum);

	
//@}

private:

	/// array of named items
    CInterfaceArray<IRsNamedItem>	m_aNamedItemsArray;  
};

