100 lines
2.0 KiB
C++
100 lines
2.0 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TAcDbObjectPtr.h
|
|
// = Version : ver2.0
|
|
// = Author : xlc
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: ÀàµÄÉùÃ÷
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#ifndef _TACDBOBJECTPTR_H_
|
|
#define _TACDBOBJECTPTR_H_
|
|
|
|
class GEOAPI TAcDbObjectPtr
|
|
{
|
|
public:
|
|
|
|
TAcDbObjectPtr(const ads_name ent, AcDb::OpenMode mode, Adesk::Boolean bOpErased = Adesk::kFalse);
|
|
|
|
TAcDbObjectPtr(AcDbObjectId nId, AcDb::OpenMode mode, Adesk::Boolean bOpErased = Adesk::kFalse);
|
|
|
|
TAcDbObjectPtr(AcDbObject *pObj);
|
|
|
|
~TAcDbObjectPtr();
|
|
|
|
operator AcDbObject & ();
|
|
|
|
operator AcDbEntity & ();
|
|
|
|
bool operator !();
|
|
|
|
void Close();
|
|
|
|
public:
|
|
|
|
AcDbObject *m_pObject;
|
|
};
|
|
|
|
|
|
inline TAcDbObjectPtr::TAcDbObjectPtr(const ads_name ent, AcDb::OpenMode mode, Adesk::Boolean bOpErased)
|
|
: m_pObject(NULL)
|
|
{
|
|
AcDbObjectId nId;
|
|
if (acdbGetObjectId(nId, (TLong_ptr *)ent) == Acad::eOk)
|
|
{
|
|
bool bVal = bOpErased ? true : false;
|
|
acdbOpenObject(m_pObject, nId, mode, bVal);
|
|
}
|
|
}
|
|
|
|
inline TAcDbObjectPtr::TAcDbObjectPtr(AcDbObjectId nId, AcDb::OpenMode mode, Adesk::Boolean bOpErased)
|
|
: m_pObject(NULL)
|
|
{
|
|
bool bVal = bOpErased ? true : false;
|
|
acdbOpenObject(m_pObject, nId, mode, bVal);
|
|
}
|
|
|
|
inline TAcDbObjectPtr::TAcDbObjectPtr(AcDbObject *pObj)
|
|
: m_pObject(pObj)
|
|
{
|
|
|
|
}
|
|
|
|
inline TAcDbObjectPtr::~TAcDbObjectPtr()
|
|
{
|
|
if (m_pObject)
|
|
{
|
|
m_pObject->close();
|
|
}
|
|
}
|
|
|
|
inline TAcDbObjectPtr::operator AcDbObject &()
|
|
{
|
|
assert(m_pObject);
|
|
|
|
return *m_pObject;
|
|
}
|
|
|
|
inline TAcDbObjectPtr::operator AcDbEntity & ()
|
|
{
|
|
assert(m_pObject && m_pObject->isKindOf(AcDbEntity::desc()));
|
|
|
|
return *(AcDbEntity *)m_pObject;
|
|
}
|
|
|
|
inline bool TAcDbObjectPtr::operator !()
|
|
{
|
|
return (m_pObject == NULL) ? true : false;
|
|
}
|
|
|
|
inline void TAcDbObjectPtr::Close()
|
|
{
|
|
if (m_pObject)
|
|
{
|
|
m_pObject->close();
|
|
}
|
|
|
|
m_pObject = NULL;
|
|
}
|
|
#endif |