#ifndef   _ACRX_EVENT_H__
#define   _ACRX_EVENT_H__
//
//  (C) Copyright 1992-2009 by Autodesk, Inc.  All rights reserved.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted, 
// provided that the above copyright notice appears in all copies and 
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting 
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC. 
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to 
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
// 
//  DESCRIPTION:  Header for AcRxEventReactor notification.
//

#include "acarray.h"
#include "rxobject.h"
#include "AdAChar.h"
#include "dbid.h"
#pragma pack (push, 8)

#define ACRX_EVENT_OBJ ACRX_T("AcRxEvent")

class AcDbDatabase;
class AcGeMatrix3d;
class AcDbIdMapping;
class AcGePoint3d;
    
enum AcXrefSubCommand {
    kAttach = 0,
    kBind = 1,
    kDetach = 2,
    kOverlay = 3,
    kPath = 4,
    kReload = 5,
    kResolve = 6,
    kUnload = 7,
    kXBind = 8
};


class AcRxEventReactor: public AcRxObject 
{ 
public:

    ACRX_DECLARE_MEMBERS(AcRxEventReactor);

    // DWG/Save Events.
    //
    virtual void dwgFileOpened(AcDbDatabase*, ACHAR * fileName);
    virtual void initialDwgFileOpenComplete(AcDbDatabase*);
    virtual void databaseConstructed(AcDbDatabase*);
    virtual void databaseToBeDestroyed(AcDbDatabase*);

    virtual void beginSave    (AcDbDatabase*, const ACHAR * pIntendedName);
    virtual void saveComplete (AcDbDatabase*, const ACHAR * pActualName);
    virtual void abortSave    (AcDbDatabase*);

    // DXF In/Out Events.
    //
    virtual void beginDxfIn      (AcDbDatabase*);
    virtual void abortDxfIn      (AcDbDatabase*);
    virtual void dxfInComplete   (AcDbDatabase*);
    //
    virtual void beginDxfOut     (AcDbDatabase*);
    virtual void abortDxfOut     (AcDbDatabase*);
    virtual void dxfOutComplete  (AcDbDatabase*);
    
    // Insert Events.
    //
    virtual void beginInsert(AcDbDatabase* pTo, const ACHAR * pBlockName,
                             AcDbDatabase* pFrom);
    virtual void beginInsert(AcDbDatabase* pTo, const AcGeMatrix3d& xform,
                             AcDbDatabase* pFrom);
    virtual void otherInsert(AcDbDatabase* pTo, AcDbIdMapping& idMap,
                             AcDbDatabase* pFrom);
    virtual void abortInsert(AcDbDatabase* pTo);
    virtual void endInsert  (AcDbDatabase* pTo);

    // Wblock Events.
    //
    virtual void wblockNotice(AcDbDatabase* pDb);
    virtual void beginWblock(AcDbDatabase* pTo, AcDbDatabase* pFrom,
                             const AcGePoint3d*& insertionPoint);
    virtual void beginWblock(AcDbDatabase* pTo, AcDbDatabase* pFrom,
                             AcDbObjectId blockId);
    virtual void beginWblock(AcDbDatabase* pTo, AcDbDatabase* pFrom); 
    virtual void otherWblock(AcDbDatabase* pTo, AcDbIdMapping&,
                             AcDbDatabase* pFrom);
    virtual void abortWblock(AcDbDatabase* pTo);
    virtual void endWblock  (AcDbDatabase* pTo);
    virtual void beginWblockObjects(AcDbDatabase*, AcDbIdMapping&);

    // Deep Clone Events.
    //
    virtual void beginDeepClone       (AcDbDatabase* pTo, AcDbIdMapping&);
    virtual void beginDeepCloneXlation(AcDbIdMapping&, Acad::ErrorStatus*);
    virtual void abortDeepClone       (AcDbIdMapping&);
    virtual void endDeepClone         (AcDbIdMapping&);

    // Partial Open Events.
    //
    virtual void partialOpenNotice  (AcDbDatabase* pDb);

    // XREF-related Events
    //
    virtual void beginAttach (AcDbDatabase* pTo, const ACHAR *,
                              AcDbDatabase* pFrom);
    virtual void otherAttach (AcDbDatabase* pTo, AcDbDatabase* pFrom);
    virtual void abortAttach (AcDbDatabase* pFrom);
    virtual void endAttach   (AcDbDatabase* pTo);
    virtual void redirected  (AcDbObjectId  newId, AcDbObjectId oldId);
    virtual void comandeered (AcDbDatabase* pTo, AcDbObjectId id,
                              AcDbDatabase* pFrom);
    virtual void beginRestore(AcDbDatabase* pTo, const ACHAR *,
                              AcDbDatabase* pFrom);
    virtual void abortRestore(AcDbDatabase* pTo);
    virtual void endRestore  (AcDbDatabase* pTo);

    virtual void xrefSubCommandStart(AcDbDatabase* pHostDb,
            AcXrefSubCommand op, const AcArray<AcDbObjectId>& ids,
            const ACHAR* const* btrNames, 
            const ACHAR* const* paths, bool& vetoOp); 

    virtual void xrefSubCommandAborted(AcDbDatabase* pHostDb,
            AcXrefSubCommand op, const AcArray<AcDbObjectId>& ids,
            const ACHAR* const* btrNames, 
            const ACHAR* const* paths); 

    virtual void preXrefLockFile(AcDbDatabase* pDb,
            AcDbObjectId btrId);
};

#define acrxEvent AcRxEvent::cast(acrxSysRegistry()->at(ACRX_EVENT_OBJ))

class AcRxEvent: public AcRxObject 
{ 
public:
    ACRX_DECLARE_MEMBERS(AcRxEvent);
    virtual void addReactor   (AcRxEventReactor * newObj) = 0;
    virtual void removeReactor(AcRxEventReactor * delObj) = 0;
};

#pragma pack (pop)
#endif
