// RcCreateProcClip.h : Declaration of the CRcCreateProcClip

#pragma once
#include "resource.h"       // main symbols


// {EF7DD9AC-75A9-4d40-A25F-0B5855C60440}
RS_DEFINE_GUID(CON_ANIMCMD_CLIPNAME, 
0xef7dd9ac, 0x75a9, 0x4d40, 0xa2, 0x5f, 0xb, 0x58, 0x55, 0xc6, 0x4, 0x40);


// IRcCreateProcClip
[
	object,
	uuid("41B58464-CFDF-430a-9E12-8CD321EF08F1"),
	helpstring("IRcCreateProcClip Interface"),
	pointer_default(unique)
]
__interface IRcCreateProcClip : IUnknown
{
};



// CRcCreateProcClip

class ATL_NO_VTABLE CRcCreateProcClip : 
    public CComObjectRootEx<CComGlobalsThreadModel>,
    public IRsUnknownNode,
    public IRsCommand,
	public IRcCreateProcClip
{
public:
	CRcCreateProcClip()
	{
	}

    BEGIN_COM_MAP(CRcCreateProcClip)
        COM_INTERFACE_ENTRY(IRcCreateProcClip)
        COM_INTERFACE_ENTRY(IRsCommand)
        COM_INTERFACE_ENTRY(IRsUnknownNode)
        COM_INTERFACE_ENTRY2(IUnknown, IRsUnknownNode)
        COM_INTERFACE_ENTRY2(IRsObject, IRsUnknownNode)
        COM_INTERFACE_ENTRY_AGGREGATE(DEF_GUIDNAME(IRsBaseNode), m_spUnkAgg.p)
        COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_spUnkAgg.p)    // Just for safety, the speed is slower only for unknown interfaces
    END_COM_MAP()

    DECLARE_GET_CONTROLLING_UNKNOWN()
	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct();
		
	void FinalRelease() 
	{
        m_spUnkAgg.Release();
	}

	HRESULT GetClipObject(IRsNode** ppAnimClipNode);
	HRESULT AddProceduralClip(IRnEncapsulator* pOwner, IRsNode** ppClipProc);

public:
    // IRsObject
    RS_DECLARE_IRS_OBJECT(IRcCreateProcClip, L"CreateProcClip")

    // IRsCommand
    STDMETHOD(Execute)(void);
    STDMETHOD(Undo)(void);
    STDMETHOD(Redo)(void);
    STDMETHOD(HasUndo)(RtBool* isUndoable);

    // IRsUnknownNode
    STDMETHOD(OnGetValue)(CONID con_id, IRsDataCache* pDataCache, VARIANT* pVtData, RtBool* pHandled);
    STDMETHOD(OnSetValue)(CONID con_id, IRsDataCache* pDataCache, VARIANT* pvtData, RtBool* pHandled);
    STDMETHOD(OnDefaultValue)(CONID con_id, VARIANT* pVtData, RtBool* pHandled);
    STDMETHOD(OnInvalidate)(CONID con_id, RtBool* pHandled);
    STDMETHOD(OnInitialize)(void);
    STDMETHOD(OnLoadDefault)(void);
    STDMETHOD(OnDestroy)(void);

private:

    CComPtr<IUnknown>         m_spUnkAgg;
};
