//////////////////////////////////////////////////////////////////////////////
//
//  Copyright 2025 by Autodesk, Inc.  All rights reserved.
//
// This computer source code and related instructions and comments 
// are the unpublished confidential and proprietary information of 
// Autodesk, Inc. and are protected under applicable copyright and 
// trade secret law.  They may not be disclosed to, copied or used 
// by any third party without the prior written consent of Autodesk, Inc.
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

//
// Description: This is the definition for edit extension to
// split UI and entity implementation.
//

#ifndef __ACM_H
	#error include 'acm.h' before including 'editExt_crx.h' file
#endif

typedef void (*AcadTaskFCN)(void*);

class AcmCLeader;
class CPlstFltrDlg;

class ACMSYMBB_CRX_DLLSHARE AcmCEditExt : public AcRxObject
{
public:
  ACRX_DECLARE_MEMBERS(AcmCEditExt);
  // for AcDbEntity based classes (symbols)
  virtual bool edit(AcDbObject* rObj, INT_PTR GsMarker) const = 0;
  // for AcDbObject based classes (standards, bom tables, ...)
  virtual bool edit(const AcDbObject* rObj, CWnd* pParentWnd = NULL) const = 0;
  // for symbols
  virtual void addLeaderTo(AcDbObject* pObj) const = 0;
  virtual bool delLeaderFrom(AcDbObject* pObj, bool silent = false, INT_PTR gsMarker = -1, const AcGePoint3d& pck = (*(const AcGePoint3d*)NULL) ) const = 0;
  // test of validity to enable add/delete leader
  // (for conditions detectable before action)
  virtual bool addLeaderEnabled(const AcDbObject* pObj) const = 0;
  virtual bool delLeaderEnabled(const AcDbObject* pObj) const = 0;
  // test of validity to enable delete leader
  // (for conditions detectable as far as during action)
  virtual bool abortRemovingLeader(AcDbObject* pObj) const = 0;
  // this method specifies if the extension is valid and can be used for
  // editing. The default implementation for AcDbObject and AcDbEntity return false;
  virtual bool isValid() const = 0;
  // For filter
  virtual CPlstFltrDlg* fltrPropertiesDlg(AcDbObject* pObj,CWnd* pParentWnd) const = 0;
  virtual bool placeAndPost(AcDbObject* pObj,AcDbObjectId& newSymId) const = 0;

  ///<summary>It is enhanced version of the placeAndPost extensenion protocol which can 
  /// return state of the placement operation for given symbol type.</summary>
  ///<param name="pObj"> object pointer of the symbol.</param>
  ///<param name="state"> input/output state of the additional operation as bit combination of PlaceAndPostOperationFlag</param>
  ///<param name="newSymId"> AcDbObjectId of the newly created symbol</param>
  ///<returns>Return state of the function if symbol was succesfuly placed and created.</returns>
  virtual bool placeAndPost(AcDbObject* pObj, Adesk::UInt32& state, AcDbObjectId& newSymId) const = 0;

  ///<summary>Function returns state of the reassociation options according to actual 
  /// state of the given symbol and corresponding symbol standard.</summary>
  ///<param name="pObj"> object pointer of the symbol.</param>
  ///<param name="state"> state of the reassociation options as bit combination of ReassociationOptionsFlag</param>
  ///<param name="bCheckSymbol"> imput flag defines if we ckeck current state of the symbol to determine reassociation options states.
  /// If the value is false then we return bit combination of options which should be available for input symbol.
  /// Default value is true/param>
  ///<returns>Return state of the function.</returns>
  virtual Adesk::Boolean getReassociationOptionsState(const AcDbObject* pObj, int& state, bool bCheckSymbol = true) const = 0;
};

/// <summary>
/// Enumeration class for re-association options flags. The each item enabled 
/// specific re-association action. Use the flags as bit combination of actions
/// </summary>
enum class ACMSYMBB_CRX_DLLSHARE ReassociationOptionsFlag : UInt32
{
    kNoEnableReassoc    = 0x0000,
    kEnableAddLeader    = 0x0001 << 0,
    kEnableRemoveLeader = 0x0001 << 1,
    kEnableAttach       = 0x0001 << 2,
    kEnableDetach       = 0x0001 << 3,
    //last segment - bit composition of all flags 
    kEnableAllOperations = kEnableAddLeader | kEnableRemoveLeader | kEnableAttach | kEnableDetach
};

/// <summary>
/// Enumeration class for placing addition operation status flags. The each item represent 
/// specific additional operation before/after symbol placing. Use the flags as bit combination of operations
/// </summary>
enum class ACMSYMBB_CRX_DLLSHARE PlaceAndPostOperationFlag : UInt32
{
    kNoOperation    = 0x00000000,
    //common post-operation
    kDisableEdit    = 0x00000001 << 0,

    //AmdtNote P&P operation
    kAddContent     = 0x00000001 << 1, 
    kReorganize     = 0x00000001 << 2,
    kAddLibrary     = 0x00000001 << 3
};

class ACMSYMBB_CRX_DLLSHARE AcmCCreateExt : public AcRxObject
{
public:
  ACRX_DECLARE_MEMBERS(AcmCCreateExt);

  //this function should not be in API!!
  virtual AcmCLeader* newLeader(AcDbObject* pSym, bool bIsSIL = false) const = 0;

  ///<summary>Function shows the command line interface for edit given symbol standard setings 
  /// Function opens nested transaction to preform update of existing symbols of given symbol standard.</summary>
  ///<param name="pObj"> object pointer of the symbol standard.</param>
  ///<returns>Return state of the function.</returns>
  virtual Acm::ErrorStatus getSymStdCLOptions(const AcDbObject* pObj) const = 0;
};

void initCreateExt();
void releaseCreateExt();

void initEditExt_crx();
void releaseEditExt_crx();
