// RiSampleItem.h : Declaration of the CRiSampleItem
#pragma once


/**
@interface IRiSampleItem
The IRiSampleItem interface provides methods for package management  
\n\n
Root-level name in the scripting engine's name space: @b RsPackage
*/
MIDL_INTERFACE("DC21B4C8-C724-43b7-8A58-22AAA88F81D6")
IRiSampleItem : IDispatch
{
	/**
	Add info message to the output log.
	@param bszText – text message
	*/
	STDMETHOD(LogInfo)(BSTR bszText);
	/**
	Add error message to the output log.
	@param bszText – text message
	*/
	STDMETHOD(LogError)(BSTR bszText);
};



// CRiSampleItem
class ATL_NO_VTABLE CRiSampleItem : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public IRsNamedItem,
    public IRiSampleItem,
	public IRsObject
{
public:
    
	CRiSampleItem()
	{
	}


	DECLARE_PROTECT_FINAL_CONSTRUCT()

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

	BEGIN_COM_MAP(CRiSampleItem)
        COM_INTERFACE_ENTRY(IRsNamedItem)
        COM_INTERFACE_ENTRY(IRiSampleItem)
        COM_INTERFACE_ENTRY(IDispatch)
        COM_INTERFACE_ENTRY(IRsObject)
    END_COM_MAP()

    
	// IRsObject
    RS_DECLARE_IRS_OBJECT(IRiSampleItem, L"Sample Script Command")

	// IRsNamedItem
	STDMETHOD(get_Name)(BSTR* pVal);
	STDMETHOD(CreateCmdObj)(const IID* piid, IRsNode** ppCmd);
	STDMETHOD(ProcessCmd)(IRsNode* pCmd);


	// IRiSampleItem


	//Add info message to the output log.
	STDMETHOD(LogInfo)(BSTR bszText);
	//Add error message to the output log.
	STDMETHOD(LogError)(BSTR bszText);
	

	// IDispatch
    
	STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) ;
	STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
	STDMETHOD(GetTypeInfoCount)(unsigned int*  pctinfo) 
	{
		if (pctinfo == NULL) {
			return E_POINTER;
		}

		*pctinfo = 0;
		return S_OK;
	}
	STDMETHOD(GetTypeInfo)(unsigned int iTInfo, LCID lcid, ITypeInfo** ppTInfo) 
	{
		if (iTInfo != 0) {
			return DISP_E_BADINDEX;
		}
		return E_FAIL;
	}

  


private:
	// system core
	CComPtr<IRsSysCore> m_spSysCore;
	// system factory
	CComPtr<IRsSysFactory> m_spFactory;

};
			
