#ifndef __STDMGR_H
#define __STDMGR_H
/////////////////////////////////////////////////////////////////////
// (C) Copyright 1993-1998 by Autodesk, Inc. 
//
// 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.
//
// file: stdmgr.h
//
// Description: 
//
// The manager of all standards. The standards are located in the named object 
// dictionary as custom objects. The creation of each standard objects is 
// performed automaticaly when you want to insert any standard symbols.
//
/////////////////////////////////////////////////////////////////////
#include "AdAChar.h"

class AcmStandard;
class AcmSymbolStd;
class AcmStdReactor;

class DllImpExp AcmStandardManager : public AcRxService
{
public:
  ACRX_DECLARE_MEMBERS(AcmStandardManager);

  virtual void             getDefaultStd(CString& stdName) const = 0;
  virtual Adesk::Boolean   edit(CWnd* pParentWnd = NULL) = 0;

  virtual Acm::ErrorStatus setCurrent(const AcDbObjectId& stdId, AcDbDatabase *pDb  = NULL) = 0;
  virtual Acm::ErrorStatus setCurrent(LPCTSTR name, AcDbDatabase *pDb = NULL) = 0;
  
  virtual Acm::ErrorStatus getCurrent(CString& name, AcDbDatabase *pDb = NULL) const = 0;
  virtual Acm::ErrorStatus getCurrent(AcDbObjectId& stdId, AcDbDatabase *pDb = NULL) const = 0;

  virtual Acm::ErrorStatus addStandard(AcDbObjectId& stdId,
                                       AcmStandard* pNewStd,
                                       Adesk::Boolean setCurrent = Adesk::kTrue,
                                       AcDbDatabase *pDb = NULL) = 0;

  virtual Acm::ErrorStatus addStandard(AcDbObjectId& stdId,
                                       LPCTSTR pNewStdName,
                                       LPCTSTR pBaseStdName,
                                       Adesk::Boolean setCurrent = Adesk::kTrue,
                                       AcDbDatabase *pDb = NULL) = 0;

  virtual Acm::ErrorStatus removeStandard(const AcDbObjectId& stdId) = 0;

  virtual Acm::ErrorStatus getStd(LPCTSTR pStdName, AcDbObjectId &objId, AcDbDatabase *pDb = NULL) const = 0;

  virtual Acm::ErrorStatus getStandards(AcDbObjectIdArray& stdIdArray, AcDbDatabase *pDb = NULL) const = 0;
  virtual Acm::ErrorStatus getAllStandardNames(CStringArray& stdNames) const = 0;
  virtual Acm::ErrorStatus getXRefStandards(CMap<CString,LPCTSTR,AcDbObjectId,const AcDbObjectId&>& stdList) const = 0;

  virtual Acm::ErrorStatus getRegisteredStd(LPCTSTR baseClass,
                                            AcDbVoidPtrArray& arrayOfStandards) const = 0;

  virtual Acm::ErrorStatus renameStd(AcDbObjectId &stdId, const ACHAR* newName) = 0;

  virtual Acm::ErrorStatus registerStdBasedOn(const AcDbObjectId &basedStdId,
                                              const ACHAR* stdName,
                                              AcDbObjectId &stdId) = 0;

  virtual Acm::ErrorStatus updateSymbols(AcDbDatabase *pDb = NULL) = 0;

  virtual int numStandards(AcDbDatabase *pDb = NULL) const = 0;

  virtual void attachReactor(AcmStdReactor* pReactor) = 0;
  virtual void removeReactor(AcmStdReactor* pReactor) = 0;

};

class DllImpExp AcmStdReactor : public AcRxObject
{
public:
  ACRX_DECLARE_MEMBERS(AcmStdReactor);

  // use this call back to populate standard with your implemented symbol
  // standard. It is MDI safe, because we are sendign already opened object
	virtual void onNewStandard(AcmStandard *pNewStd) 
  {
		UNREFERENCED_PARAMETER(pNewStd);
  }

  // use this call back to react on changing basic standard setting, such as 
  // attachment for lists, units, text height, text style, arrowhead type. 
  // Var specifies which portion of standard has changed.
  // It is MDI safe, because we are sendign already opened object
  virtual void onChanged(const AcmStandard* pStd, Acm::StdVariable var)
  {
    UNREFERENCED_PARAMETER(pStd);
    UNREFERENCED_PARAMETER(var);
  }

  // use this call back to react on changing symbol standard setting. This 
  // can be used to react on chnaged settings, if the dependent entity isn't 
  // symbol and so didn't receive teh regen() call back.
  // It is MDI safe, because we are sendign already opened object
  // it is implemented for standards whic do not have yet it own symbols 
  // (section line, thread line)
  virtual void onChanged(const AcmSymbolStd* pSymStd)
  {
	  UNREFERENCED_PARAMETER(pSymStd);
  }

  // this callback is used to obtain the notification when we are going to remove the
  // standard. This call beack is going to be used in setup dialog to react on 
  // erasing the standard. But it could be used for any other purpose.
  virtual void onRemoved(const AcmStandard* pStd)
  {
	  UNREFERENCED_PARAMETER(pStd);
  }

  // this callback is used when we need to monitor changing the current standard
  virtual void onSetCurrentStd(AcDbObjectId& oldCurrentStandard, AcDbObjectId& newCurrentStdId)
  {
	  UNREFERENCED_PARAMETER(newCurrentStdId);
	  UNREFERENCED_PARAMETER(oldCurrentStandard);
	  
  }

  virtual LPCTSTR symbolStdClassName() const
  { return _T(/*MSG0*/""); }
};

DllImpExp AcmStandardManager* getAcmStdMgr();

#define STDMGR_SERVICE_NAME  ACRX_T(/*MSG0*/"AcmStdManagerService")
#define acmStdMgr            getAcmStdMgr()
#define isStdMgrReady()      acrxServiceIsRegistered(STDMGR_SERVICE_NAME)
#define LockStdMgr()         (isStdMgrReady() ? acmStdMgr->addDependency(), TRUE : FALSE )
#define UnlockStdMgr()       (isStdMgrReady() ? acmStdMgr->removeDependency(), TRUE : FALSE )

#endif
