/***************************************************************************
 *                          Zanoza Modeler v2.x                            *
 *      This is unpublished propietary source code of Zanoza Software.     *
 *      The copyright notice does not evidence any actual or intended      *
 *                    publication of such source code.                     *
 *                                                                         *
 *                   Copyright (c) 2002 Zanoza Software.                   *
 *                                                                         *
 *                        All rights reserved.                             *
 ***************************************************************************
 *--------------------------------------------------------------------------
 * @author:   Oleg M.
 *--------------------------------------------------------------------------
 * @purpose:  ZModeler 2.x base definitions
 *--------------------------------------------------------------------------
 * @histroy: 17.10.2002. Created
 */
#ifndef zmbase_h_included
#define zmbase_h_included

//------------------------------------------------------
// opaque module handle;
typedef HINSTANCE         tModuleHandle;

//------------------------------------------------------
// opaque datatype
typedef void   ZOpaque;


//------------------------------------------------------
//      Node, Vertex, Poly base class
//------------------------------------------------------
class DLL_LINKAGE ZEntityBase
{
public:
  ZEntityBase() 
  {
    m_dwStatus      = 0;
    m_dwExtension   = 0;
    m_UserDefined.m_dwUserDefined = 0;
  } 
public:
  //
  // status
  //
  virtual DWORD  getStatus() const { return m_dwStatus; }
  virtual DWORD& status() { return m_dwStatus; } //get/set accessor
  virtual DWORD  setStatus(const DWORD dwStatus) { return m_dwStatus = dwStatus; }
  virtual DWORD  changeStatus(const DWORD dwAdd, const DWORD dwRemove)
    { return m_dwStatus = (m_dwStatus & ~dwRemove) | dwAdd; }
  virtual bool   checkStatus(const DWORD dwStatus)
    { return dwStatus == (m_dwStatus & dwStatus); }

public:
  //
  // user-defined:
  //
  inline DWORD& userDword()     { return m_UserDefined.m_dwUserDefined;  }
  inline float& userFloat()     { return m_UserDefined.m_fUserDefined;   }
  inline WORD&  userWord1()     { return m_UserDefined.m_wUserDefined[0];}
  inline WORD&  userWord2()     { return m_UserDefined.m_wUserDefined[1];}
  //
  // extensions
  //
  inline DWORD& extension()     { return m_dwExtension;                  }
  inline WORD&  ID()            { return ((WORD*)&m_dwExtension)[1];     }
  inline BYTE&  rendExt()       { return ((BYTE*)&m_dwExtension)[1];     }
  inline BYTE&  compatibility() { return ((BYTE*)&m_dwExtension)[0];     }

protected:
  //
  // data members
  //
  DWORD   m_dwStatus;
  // user-defined
  union
  {
    DWORD   m_dwUserDefined;
    WORD    m_wUserDefined[2];
    float   m_fUserDefined;
  }m_UserDefined;
  DWORD     m_dwExtension;
};

//generic pointer type:
typedef ZEntityBase* tZEntityBasePtr;

#endif //zmbase_h_included
