#ifndef __ACMPLSTFLTR_API_H
#define __ACMPLSTFLTR_API_H
/////////////////////////////////////////////////////////////////////
// (C) Copyright 1993-2007 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.
//
// plistfltr.h
//
/////////////////////////////////////////////////////////////////////
#include "AdAChar.h"

class AcmCItFltrImp;
class AmdtItemFilterUtilImp;
class AcmPartList;

class DllImpExp AmdtItemFilter : public AcDbObject
{
  friend class AcmSymbbInternals;
public:
  ACRX_DECLARE_MEMBERS(AmdtItemFilter);
  AmdtItemFilter();
  virtual ~AmdtItemFilter();
  //This function evaluate the filter
  virtual bool evaluate(const AcDbObjectId& rowId) const;
  //This function returns name of filter
  virtual CString name() const ;
  // Retrieves the filter type.
  virtual Acm::FilterType type() const;
  //This function is called for preparing filter to be ready. Is called from 
  //AcmPartList::addFilter and when partlist must be refreshed.
  //There may be some internal filter settings
  virtual Acad::ErrorStatus makeFilterReady();
  //is excluded from UI add filter dialog?
  virtual bool excluded() const;

  bool isOn() const;
  void setIsOn(bool newStatus);
  
  //Standard AcDbObject Interface
  virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler* pFiler);
  virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;
  virtual Acad::ErrorStatus subErase(Adesk::Boolean erasing);

protected:
  // We are making this constructor and destructor protected to try and
  // ensure that they are not used.  The Tahoe team has discovered a 
  // bug with the destructor so has made it private in AcDbObject.
  // This doesn't allow us to compile unless we declare it on our classes
  // that are exported.  No implementation is supplied so that link
  // errors are encountered if either of these are used.
  // See Tahoe subdoc t39dca1.txt for more details.
  //
  Adesk::UInt16 classVersion() const;
  void *operator new[](size_t nSize) { assert(0); return NULL; }
  void operator delete[](void *p) { assert(0); }

  virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const;

private:
  AcmCItFltrImp* mpImp;
};

inline bool 
AmdtItemFilter::excluded() const
{
  return true;
}

DBREF_DECLARE(AmdtItemFilter);

class DllImpExp AmdtItemFilterCustom : public AmdtItemFilter
{
public:
  enum Operators {
    kContains = 0,
    kDoesNotCont,
    kEqual,
    kNotEqual,
    kLess,
    kGreater,
    kLessEqual,
    kGreaterEqual
  };

  ACRX_DECLARE_MEMBERS(AmdtItemFilterCustom);
  AmdtItemFilterCustom();

  virtual CString name() const;
  // Retrieves the filter type.
  virtual Acm::FilterType type() const;
  virtual Acad::ErrorStatus makeFilterReady();
  virtual bool evaluate(const AcDbObjectId& rowId) const;
  virtual bool excluded() const;
  //data Access function
  void set(const ACHAR* colName, Operators oper, const ACHAR* string);
  Operators oper() const;
  const ACHAR* string() const;
  const ACHAR* attrib() const;

protected:
  // Retrieves the COM class ID.
  virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const;

private:
  bool setupDataType();
};

class DllImpExp AmdtItemFilterStdParts : public AmdtItemFilterCustom
{
public:
  // Filter options.
  enum FilterOption {
    kStdPartsOnly = 0,
    kExcludeStdParts
  };

public:
  ACRX_DECLARE_MEMBERS(AmdtItemFilterStdParts);
  AmdtItemFilterStdParts();
  virtual CString name() const;
  // Retrieves the filter type.
  virtual Acm::FilterType type() const;
  virtual Acad::ErrorStatus makeFilterReady();

  // Sets the filter option.
  void setOption(FilterOption enOption);
  // Retrieves the filter option.
  AmdtItemFilterStdParts::FilterOption option() const;

protected:
  // Retrieves COM class ID.
  virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const;
};

class DllImpExp AmdtItemFilterBalloonedOnly : public AmdtItemFilter
{
public:
  ACRX_DECLARE_MEMBERS(AmdtItemFilterBalloonedOnly);
  AmdtItemFilterBalloonedOnly();
  virtual CString name() const;
  // Retrieves the filter type.
  virtual Acm::FilterType type() const;
  virtual bool evaluate(const AcDbObjectId& rowId) const;
  virtual Acad::ErrorStatus makeFilterReady();
  virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler* pFiler);
  virtual bool excluded() const;

  virtual Acad::ErrorStatus subErase(Adesk::Boolean erasing);

protected:
  // Retrieves the COM class ID.
  virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const;
};

// Utility class for Parts List filters.
class DllImpExp AmdtItemFilterUtil
{
public:
  AmdtItemFilterUtil();
  virtual ~AmdtItemFilterUtil();

public:
  // Retrieves the filter name of a specified filter type.
  CString filterName(Acm::FilterType enType) const;

  // Retrieves the filter type of a specified filter name.
  bool filterType(CString strName, Acm::FilterType& enType) const;

  // Indicates whether a filter type is excluded from use in the current context.
  bool filterExcluded(Acm::FilterType enType, bool bUpdate = true);

  // Checks if a filter type is valid for use by a Parts List in the current context.
  bool filterValid(Acm::FilterType enType, const AcmPartList* pPartList = NULL);

private:
  AmdtItemFilterUtilImp* m_pFilterUtilImp;
};

#endif