// RaClip.h : Declaration of the CRaClip

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


// {C3443071-0AF5-4505-9874-5F4CA98F24E1}
RS_DEFINE_GUID(CON_KFANIMDATA, 
0xc3443071, 0xaf5, 0x4505, 0x98, 0x74, 0x5f, 0x4c, 0xa9, 0x8f, 0x24, 0xe1);

// {FA345C82-BB83-42e0-890E-31DBC8A0B55C}
RS_DEFINE_GUID(CON_USELOCALTIME, 
0xfa345c82, 0xbb83, 0x42e0, 0x89, 0xe, 0x31, 0xdb, 0xc8, 0xa0, 0xb5, 0x5c);


// IRaClip
[
	object,
	uuid("6CCD6C36-34EC-461d-B3C1-6AB7B9FE026A"),
	helpstring("IRaClip Interface"),
	pointer_default(unique)
]
__interface IRaClip : IUnknown
{
};



// CRaClip

class ATL_NO_VTABLE CRaClip : 
    public CComObjectRootEx<CComGlobalsThreadModel>,
    public IRsUnknownNode,
    public IRsCommand,
	public IRaClip
{
public:
	CRaClip()
	{
	}

    BEGIN_COM_MAP(CRaClip)
        COM_INTERFACE_ENTRY(IRaClip)
        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 ApplyKfData(IRsNode* pAnimSpace, IRsAnimAttrRecord* pAnimAttrRec, RtTime tTime);
	HRESULT GetAnimData(IRdAnimData** ppAnimData);
	HRESULT GetAnimTime(RtTime* ptTime);

public:
    // IRsObject
    RS_DECLARE_IRS_OBJECT(IRaClip, L"ProcClipActv")

    // 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;
};
