
#ifndef __ACM_SYMBOL_LIBRARY_H
#define __ACM_SYMBOL_LIBRARY_H
/////////////////////////////////////////////////////////////////////
//
//  (C) Copyright 2008 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.
//

class AcmSymbol;
class AcmCSubSymbol;
class AcmSymbolLibObjectImp;
class DllImpExp AmdtSymbolLibObject : public AcDbObject
{
public:
  ACRX_DECLARE_MEMBERS(AmdtSymbolLibObject);
  AmdtSymbolLibObject();
  ~AmdtSymbolLibObject();

  virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler* pFiler);
  virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;

  const ACHAR * stdName() const;
  const ACHAR * entryName() const;
  const ACHAR* symStdClassName() const;
  Acm::ErrorStatus setEntryName(const ACHAR *newName);

  virtual bool isDefault() const;
  virtual bool setIsDefault(bool, const ACHAR* className = NULL);

  Acm::ErrorStatus getRequirementValue(Acm::Variable var, ACHAR *& retVal) const;

  // Update
  virtual void getObject(AcmCSubSymbol *pCSubSym) const;
  virtual void setObject(const AcmCSubSymbol *pCSubSym);

  virtual Acm::ErrorStatus set(const AcmCSubSymbol * pCSubSym, const ACHAR *itemName, const ACHAR *stdName, const ACHAR* className);
  
  bool operator==(const AmdtSymbolLibObject& symLibObj)const;
protected:
  Adesk::UInt16 classVersion() const;
private:
  Adesk::UInt16     mVersion;
protected:
  AcmSymbolLibObjectImp *mpImp;
};
MAKE_ACDBOPENOBJECT_FUNCTION(AmdtSymbolLibObject);

inline Adesk::UInt16 
AmdtSymbolLibObject::classVersion() const
{ return mVersion; }

////////////////////////////////////////////////////////////////
// class AmdtSymbolLibrary
class DllImpExp AmdtSymbolLibrary : public AcDbDictionary
{
public:
  ACRX_DECLARE_MEMBERS(AmdtSymbolLibrary);

  virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler* pFiler);
  virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;

  virtual const ACHAR *name() const = 0;

  //Edit functions
  // Retrieve stored item
  virtual Acad::ErrorStatus loadItem(const ACHAR *itemName, AcmSymbol *pSym) = 0;

  // Add new item
  virtual Acad::ErrorStatus appendItem(const ACHAR *itemName, AcmSymbol *pSym, AcDbObjectId& newId, bool bCheckValidName=true) = 0;
  Acad::ErrorStatus appendItem(AmdtSymbolLibObject*, AcDbObjectId& newId, bool bCheckValidName=true);

  // Update existing item
  virtual Acad::ErrorStatus modifyItem(const ACHAR *itemName, AcmSymbol *pSym) = 0;

  // Delete existing item
  bool removeItem(const ACHAR *itemName, const ACHAR *stdName, const ACHAR* className);

  // Rename existing item
  bool renameItem(const ACHAR *oldName, const ACHAR *newName, const ACHAR *stdName, const ACHAR* className) const;

  // Set a default item
  bool setIsDefaultItem(const ACHAR *itemName, const ACHAR *stdName, const ACHAR* className, bool bDefault) const;

  //Query functions
  bool isItemExist(const ACHAR *itemName, const ACHAR *stdName, const ACHAR* className) const;

  virtual bool find(const ACHAR *itemName, const ACHAR *stdName, const ACHAR* className, AcDbObjectId &returnId, bool bCompatiableRev=true) const;
  virtual bool find(const ACHAR *stdName, const ACHAR* className, AcDbObjectIdArray &ListId, bool bCompatiableRev=true) const;

  virtual bool getDefaultItem(const ACHAR *stdName, const ACHAR* className, AcDbObjectId &returnId) const;

  virtual Acad::ErrorStatus decomposeForSave(AcDb::AcDbDwgVersion ver,
    AcDbObject*& replaceObj,
    AcDbObjectId& replaceId,
    Adesk::Boolean& exchangeXData);

protected:
  Adesk::UInt16 classVersion() const;
private:
  Adesk::UInt16 mVersion;
};

inline Adesk::UInt16 
AmdtSymbolLibrary::classVersion() const
{ return mVersion; }

MAKE_ACDBOPENOBJECT_FUNCTION(AmdtSymbolLibrary);
DBREF_DECLARE(AmdtSymbolLibrary)

#endif //