// RpSamplePlugin.h : Declaration of the CRpSamplePlugin
#pragma once

#define CMDPROMPT_PACKAGE_VERSION1			1	// cmdprompt package version
#define CMDPROMPT_PACKAGE_VERSION			CMDPROMPT_PACKAGE_VERSION1  

#ifndef __IRpSamplePlugin_FWD_DEFINED__
#define __IRpSamplePlugin_FWD_DEFINED__
typedef interface IRpSamplePlugin IRpSamplePlugin;
#endif 	/* __IRpSamplePlugin_FWD_DEFINED__ */

// IRpSamplePlugin
MIDL_INTERFACE("E9E305ED-F066-4e05-92F1-490CBD0DB155")
IRpSamplePlugin : public IRsObject
{
public:
};



class __declspec(uuid("6983692F-3ACA-493d-952E-79A1CEA35D3D")) ATL_NO_VTABLE CRpSamplePlugin : 
	public CComObjectRootEx<CComMultiThreadModel>,
    public IRpSamplePlugin,
    public IRsUnknownPackage,
    public IRsModulePackage,
	public IRsPackageDesc
{
private:
    /**@name Attributes */
    //@{
        /// Pointer to kernel Package.
    static CComPtr<IRpKernel>			m_spKernelPackage;
		/// Pointer to Command prompt Package.
    static CComPtr<IRpSamplePlugin>     m_spSamplePackage;
	
    	/// node factory
	//CComPtr<IRsNodeFactory>			m_spNodeFactory;
		/// command factory
	CComPtr<IRsCmdFactory>				m_spCmdFactory;
		/// command factory
	//CComPtr<IRsDataObjFactory>		m_spDataObjFactory;
        /// UI control object factory
	//CComPtr<IRsUIControlFactory>		m_spUIControlFactory;
    //@}

public:
    /**@name Methods */
    //@{
        /// Constructor, this constructor does nothing important.
    CRpSamplePlugin()
    {
    }

        /// This method does nothing important.
    HRESULT FinalConstruct()
    {
        return S_OK;
    }

        /// This method just releases array of named items.
    void FinalRelease() 
    {
        //m_NamedItemsArray.RemoveAll();
    }

        /** This method allow access to the kernel package interface IRpKernel.
            @param ppPackage Out Pointer to the kernel package interface.
        */
	static HRESULT GetKernelPackage(IRpKernel** ppPackage);
		/** This method allow access to the math package interface IRpKernel.
            @param ppPackage Out Pointer to the kernel package interface.
        */
   	
    /**@name Methods of interface IRsUnknownPackage */
        //@{
    STDMETHOD(Initialize)(IRsUnknownPackage *pParentPackage);
        /// This method releases m_pKernelPackage.
    STDMETHOD(UnInitialize)();
    STDMETHOD(OnSysMessage)(MSGID msgId, IRsUnknownMsg* pMsg);
		/// returns NodeFactory interface provided by package
	STDMETHOD(GetNodeFactory)(IRsNodeFactory** ppNodeFactory);
		/// returns Command Factory interface provided by package
	STDMETHOD(GetCmdFactory)(IRsCmdFactory** ppCmdFactory);
		/// returns Data Object Factory interface provided by package
	STDMETHOD(GetDataObjFactory)(IRsDataObjFactory** ppDataObjFactory);
	    /// returns Package module instance
    STDMETHOD(GetModuleInstance)(RtInstance* pInstance);
	    /// returns Package resource instance
    STDMETHOD(GetResourceInstance)(RtInstance* pInstance);
		/// package version
	RS_DECLARE_PACKAGE_VERSION(PRODUCT_VERSION, CMDPROMPT_PACKAGE_VERSION);
	RS_PACKAGE_DESCRIPTION(L"Simple sdk example");
        //@}
    //@}

    // Macros are reason of problems for Doc++ so they should be out of
    // scope of Doc++ comments

    // IRsObject Methods
    RS_DECLARE_IRS_OBJECT(CRpSamplePlugin, L"Sample Package")

    // we want only one instance of cmdprompt package
    DECLARE_CLASSFACTORY_SINGLETON(CRpSamplePlugin)
    DECLARE_NOT_AGGREGATABLE(CRpSamplePlugin)
    DECLARE_PROTECT_FINAL_CONSTRUCT()

    // log support
    RS_LOG_ACCESS(m_spKernelPackage)
    #define RS_LOG(lev, hr, text) CRpSamplePlugin::MyLogEntry(lev, hr, text, __FILE__, __LINE__);   


    BEGIN_COM_MAP(CRpSamplePlugin)
        COM_INTERFACE_ENTRY(IRpSamplePlugin)
        COM_INTERFACE_ENTRY2(IRsObject, IRpSamplePlugin)
        COM_INTERFACE_ENTRY(IRsUnknownPackage)
        COM_INTERFACE_ENTRY(IRsModulePackage)
		COM_INTERFACE_ENTRY(IRsPackageDesc)
    END_COM_MAP()

};


