/***************************************************************************
 *                          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 ITool
 *   Tool's base interface. ZModeler provides extension of this interfaces
 *   that implements the rest of in-zmodeler operations. User only overloads
 *   or re-implements desired behavior of the tool
 *--------------------------------------------------------------------------
 * @created: Saturday, September 21, 2002 13:40:20
 */

#if !defined(ITool_h_included)
#define ITool_h_included
//forward declaration of this class might require
namespace core
{ namespace tools
  { class ITool; class CToolCol; }; };
#include <zmodeler.h>
#include <core/tools/toolTypes.h>
#include <core/layout/ILayout.h>
#include <core/libs/ILibrary.h>
#include <core/IProcParams.h>


namespace core
{
  namespace tools
  {
    struct tToolInfo
    {
      ZPtr<core::tools::ITool> m_pTool;
      long                     m_nIndex;
      bool operator == (const tToolInfo& info) const
      {
        return m_pTool == info.m_pTool && m_nIndex == info.m_nIndex;
      }
    };
    // currently selected tools are stored in form above
    // and provided as a sequence below.
    typedef ZSequence<tToolInfo> tToolInfoSeq;
    class ITool : public ZUnknown
    {
    public:
      /* Bit-masked code of input-device resources required for the tool.
       * Mouse buttons, keyboard input, etc. */
      virtual ZRESULT requires(DWORD& dwRequires) const=0;
      /* The tool provides layout information, It's a base ILayout
       * interface. Actually, each tool provides one if it's derived
       * implementations (ILayoutCommandBar, ILayoutFloader etc.) */
      virtual ZRESULT getLayout(core::layout::ILayout** ppLayout)=0;
      virtual ZRESULT getLibrary(core::libs::ILibrary** ppLib)=0;
      virtual ZRESULT setLibrary(core::libs::ILibrary* pLib)=0;
      /* The primary tool's function. It's purpose is to apply
       * the tool to supplied data subset. */
      virtual ZRESULT apply(core::IProcParams* pProcParams=NULL, DWORD* pRetVal=NULL)=0;
      /* Notifies tool that zmodeler has done with it (interrupt or new tool was selected) */
      virtual ZRESULT done(core::IProcParams* pProcParams=NULL, DWORD* pRetVal=NULL)=0;
    
    };//class ITool
    
    //
    // collection template
    //
    class CToolCol : public ZUnknown,
        public ZIntrCollection<ITool>
    {
    public:
      INTERFACE_FUNCTIONS_DEFAULT(CToolCol)
    };//class CToolCol
  };//tools
};//core

#endif
