/***************************************************************************
 *                          Zanoza Modeler v2.x                            *
 *      This is unpublished propietary source code of Zanoza Software.     *
 *      The copyright notice does not evidence any actual or intended      *
 *                    publication of such source code.                     *
 *                                                                         *
 *                Copyright (c) 2002-2008 Zanoza Software.                 *
 *                                                                         *
 *                        All rights reserved.                             *
 ***************************************************************************
 *--------------------------------------------------------------------------
 * @author:   Oleg Melashenko
 *--------------------------------------------------------------------------
 * @purpose:  Declaration of the class IRepository
 *   Repository of plug-ins. It represents both static and dynamic views of
 *   available plug-ins and implemeted classes
 *--------------------------------------------------------------------------
 * @created: Sunday, September 22, 2002 21:54:34
 */

#if !defined(IRepository_h_included)
#define IRepository_h_included
//forward declaration of this class might require
namespace core
{ class IRepository; };
#include <zmodeler.h>
#include <core/coreTypes.h>
#include <core/events/eventsTypes.h>
#include <core/libs/ILibrary.h>
#include <core/libs/ILibraryHolder.h>
#include <core/tools/ITool.h>
#include <services/IService.h>


namespace core
{
  
  class IRepository : public ZUnknown
  {
  public:
    /* adds library to repository (if it's not there yet) */
    virtual ZRESULT addLibrary(core::libs::ILibrary* pLib)=0;
    /* Unloads library, but keeps reference to it's classes location. */
    virtual ZRESULT unloadLibrary(ZString strName)=0;
    virtual ZRESULT hasLibrary(ZString strName)=0;
    virtual ZRESULT getLibraries(core::libs::CLibraryHolderCol** ppLibs)=0;
    virtual ZRESULT scan(void)=0;
    virtual ZRESULT load(ZString strFile)=0;
    virtual ZRESULT save(ZString strFile)=0;
    virtual ZRESULT setRootLocation(ZString strRoot)=0;
    virtual ZRESULT getRootLocation(ZString& strRoot)=0;
    virtual ZRESULT enumTools(ZStringSeq& strSeq)=0;
    virtual ZRESULT enumServices(ZStringSeq& strSeq)=0;
    virtual ZRESULT getClassHolder(LPCTSTR pszClassName, core::libs::ILibraryHolder** ppHolder)=0;
    virtual ZRESULT createTool(ZString strClassName, core::tools::ITool** ppTool)=0;
    /* Creates independ service. The pointer it provides will
     * never be returned by getService operation */
    virtual ZRESULT createService(ZString strClassName, services::IService** ppService)=0;
    /* Provides service (creates new one on first call) */
    virtual ZRESULT getService(ZString strClassName, services::IService** ppService)=0;
    /* Creates an instance of any class */
    virtual ZRESULT createSharedClass(ZString strClassName, ZUnknown** ppUnk)=0;
    /* Obtains interface stored previousely by holdSharedInterface
     * by it's InterfaceID. Interface can be optionally removed from
     * further holding */
    virtual ZRESULT getSharedInterface(LPCTSTR pszIID, void** ppInterface, bool bHoldFurther=true)=0;
    /* Allows repository to hold one reference to shared interface. This allows to avoid
     * circular references. The reference held by repository will be released when
     * zmodeler shut down. */
    virtual ZRESULT holdSharedInterface(ZUnknown* pUnknown, LPCTSTR pszIID)=0;
    virtual ZRESULT enumSharedInterfaces(ZStringSeq& seqIIDs)=0;
  
  };//class IRepository
};//core

#endif
