#ifndef ACMREVISIONLIST_H
#define ACMREVISIONLIST_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.
//

#include "AcmTitle.h"

//STL headers
#include <vector>
#include <string>
#include <map>

//ARX headers
#include <AcString.h>

//class forward declaration 
class AcMgRevisionList;
class AcMgRevisionLists;
class AcMgRevisionListContext;
class AcMgRevisionListAttribMap;
class AcMgRevisionListDescriptor;

//revision list item's attribute name(key)
#define REVLINE_ATTRIB_NR               _T(/*MSG0*/"GEN-REV-NR")
#define REVLINE_ATTRIB_DAT              _T(/*MSG0*/"GEN-REV-DAT")
#define REVLINE_ATTRIB_TEXT1            _T(/*MSG0*/"GEN-REV-TEXT1")
#define REVLINE_ATTRIB_TEXT2            _T(/*MSG0*/"GEN-REV-TEXT2")
#define REVLINE_ATTRIB_NAME             _T(/*MSG0*/"GEN-REV-NAME")
#define REVLINE_ATTRIB_BLK              _T(/*MSG0*/"GEN-REV-BLK")

//the revision list manager class
class AMGTITLE_DLLSHARE AcMgRevisionMgr : public AcRxService
{
public:
  //create a new empty descriptor object.
  //AddRef() is called internally.
  virtual AcMgRevisionListDescriptor* NewDescriptor()=0;

  //create a new attribute map object.
  //AddRef() is called internally.
  virtual AcMgRevisionListAttribMap* NewAttributeMap() = 0;

  //create a new revision list object based on the specified context and descriptor object.
  virtual AcDbObjectId CreateRevisionList(AcMgRevisionListDescriptor* pDesc, 
                                          AcMgRevisionListContext* pCont = NULL) = 0;
  //retrieve the revision list object from its Id or its entity part Id(s).
  //AddRef() is called internally
  virtual AcMgRevisionList* GetRevListFromRef(AcDbObjectId& ObjId)=0;
  //delete the revision list object specified by its Id.
  virtual bool DeleteRevisionList(const AcDbObjectId& revListId)=0;
  //delete the revision list object specified by its index maintained by the manager
  virtual bool DeleteRevisionList(const VARIANT& index)=0;
  //retrieve the collection of revision list maintained by the manager.
  //AddRef() is called internally.
  virtual bool GetRevisionLists(AcMgRevisionLists*& pLists)=0;

//deprecated public APIs for back-compatibility only, please don't use them.
public:
  //AutoControl property access/manipulation functions.
  virtual bool GetAutoControl() = 0;
  virtual void SetAutoControl(const bool on) = 0;
  //create a new empty context object.
  virtual AcMgRevisionListContext* NewContext() = 0;

protected:
  virtual ~AcMgRevisionMgr() {}   
};

//the attribute map class for revision list
class AMGTITLE_DLLSHARE AcMgRevisionListAttribMap {
public:
  virtual ULONG AddRef() = 0;
  virtual ULONG Release() = 0;

  //returns the count of attributes for revision list
  virtual int   Count() const   = 0;
  virtual bool  GetAt(const AcString& strKey, AcString& strValue) const = 0;
  virtual bool  GetAt(int index, AcString& strKey, AcString& strValue) const = 0;
  virtual bool  SetAt(const AcString& strKey, const AcString& strValue) = 0;

protected:
  virtual ~AcMgRevisionListAttribMap() {}
};


//the revision list class
class AMGTITLE_DLLSHARE AcMgRevisionList
{
public:
  virtual ULONG AddRef() = 0;
  virtual ULONG Release() = 0;

  //Attributes access/manipulation functions
  virtual int  totalItem()= 0;
  virtual bool item(int index, AcMgRevisionListAttribMap*& pAttributesMap) = 0;
  virtual bool add(const AcMgRevisionListAttribMap* pAttributesMap) = 0;
  virtual bool set(int index, const AcMgRevisionListAttribMap* pAttributesMap) = 0;

  // retrieve the Id of this revision list object
  virtual bool RevListId(AcDbObjectId& RevId)=0;
  // retrieve the Id of the attached title/border object. 
  virtual void Border(AcDbObjectId& bordId) = 0;
  // retrieve the position of this revision list object
  virtual void Point(AcGePoint3d& point) = 0;

protected:
  //virtual protected destructor
  //  virtual: make the derived class to be destructed properly.
  //  protected: prevent from automatically or explicitly destructing objects.
  virtual ~AcMgRevisionList() {
    //
  }
};


//the revision list description specifies its position and attached title/border object.
class AMGTITLE_DLLSHARE AcMgRevisionListDescriptor
{
public:
  virtual ULONG AddRef() = 0;
  virtual ULONG Release() = 0;

  // return a pointer points to the title/border object id.
  virtual AcDbObjectId* Border()                = 0;
  // return a pointer points to the position. 
  virtual AcGePoint3d*  Position()              = 0;
  // specify the title/border object id.
  virtual int setBorder(const AcDbObjectId& brdId)  = 0;
  // specify the position.
  virtual int setPosition(const AcGePoint3d& pos) = 0;

  // retrieve the attributes maintained by the descriptor object.
  virtual void Attributes(AcMgRevisionListAttribMap*& pAttributeMap) = 0;
  // modify the attributes maintained by the descriptor object.
  virtual bool setAttributes(const AcMgRevisionListAttribMap* pAttributeMap) = 0;

protected:
  virtual ~AcMgRevisionListDescriptor() {}
};


//the revision list context
class AMGTITLE_DLLSHARE AcMgRevisionListContext
{
public:
  virtual ULONG AddRef()=0;
  virtual ULONG Release()=0;

  virtual bool inputPosition()=0;
  virtual bool inputBorder()=0;
  virtual void setInputPosition( bool newValue )=0;
  virtual void setInputBorder( bool newValue )=0;

protected:
  virtual ~AcMgRevisionListContext() {}
};


//the collection for all revision lists managed by the manager
class AMGTITLE_DLLSHARE AcMgRevisionLists
{   
public:
  virtual ULONG AddRef()  = 0;
  virtual ULONG Release() = 0;

  // returns the number of revision lists in the drawing
  virtual int   Count() const   =0;
  // retrieve the revision list specified by its index
  virtual AcMgRevisionList* item(int n) = 0;

protected:
  virtual ~AcMgRevisionLists() {}
};


#define ACMG_REVISION_SERVICE _T(/*MSG0*/"AcMgRevisionService")
#define pAcMgRevListMgr ((AcMgRevisionMgr*)AcRxService::cast(acrxServiceDictionary->at( ACMG_REVISION_SERVICE )))

#endif