FRX SDK Documentation 2025 SP0
Loading...
Searching...
No Matches
AcAxObjectRef.h
Go to the documentation of this file.
1#pragma once
2
3//
4// (C) Copyright 2005-2024 by Graebert GmbH.
5//
6// Permission to use, copy, modify, and distribute this software in
7// object code form for any purpose and without fee is hereby granted,
8// provided that the above copyright notice appears in all copies and
9// that both that copyright notice and the limited warranty and
10// restricted rights notice below appear in all supporting
11// documentation.
12//
13// GRAEBERT PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
14// GRAEBERT SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
15// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. GRAEBERT GMBH
16// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
17// UNINTERRUPTED OR ERROR FREE.
18
19class AcDbObjectId;
20class AcDbObject;
21#include "..\addclass.h"
22
24{
25public:
29 Acad::ErrorStatus acquire( AcDbObjectId );
30 Acad::ErrorStatus acquire( AcDbObject*& );
31 Acad::ErrorStatus release( AcDbObjectId&, AcDbObject*& );
32 bool isNull( void );
34
35private:
36 AcDbObjectId m_objectId;
37 AcDbObject* m_pObject;
38};
39
40template<typename Param1>
41class AcAxObjectRefPtr : public AcDbObjectPointer<Param1>
42{
43public:
45 {
46 if (NULL != this->m_ptr && this->m_ptr->objectId().isNull()) {
47 Param1* pObject = NULL;
48 this->release(pObject);
49 m_pRef->acquire(reinterpret_cast<AcDbObject*&>(pObject));
50 }
51 }
52
54 {
55 m_pRef = NULL;
56 }
57
59 {
60 if (NULL == param_1)
61 {
62 this->m_status = Acad::eNullObjectPointer;
63 return;
64 }
65
66 AcDbObjectId objectId = param_1->objectId();
67 if (!objectId.isNull())
68 {
69 this->m_status = acdbOpenObject(this->m_ptr, objectId, param_2, param_3);
70 }
71 else
72 {
73 AcDbObject* pObj = NULL;
74 m_pRef->release(objectId, pObj);
75
76 Param1* pTyped = Param1::cast(pObj);
77 if (NULL == pTyped) {
78 this->m_ptr = NULL;
79 m_pRef->acquire(pObj);
80 this->m_status = Acad::eNotThatKindOfClass;
81 }
82 else
83 this->acquire(pTyped);
84 }
85 }
86
87private:
88 AcAxObjectRef* const m_pRef;
89};
90
AcAxObjectRefPtr< AcDbObject > AcDbObjectRefPtr
AcAxObjectRefPtr< AcDbEntity > AcDbEntityRefPtr
Acad::ErrorStatus acdbOpenObject(T *&pObj, AcDbObjectId id, AcDb::OpenMode mode, bool openErased=false)
Definition AddGlobals.h:36
Acad::ErrorStatus release(AcDbObjectId &, AcDbObject *&)
AcAxObjectRef(AcDbObject *&)
Acad::ErrorStatus acquire(AcDbObject *&)
Acad::ErrorStatus acquire(AcDbObjectId)
bool isNull(void)
AcAxObjectRef(AcDbObjectId)
AcDbObjectId objectId(void)
AcAxObjectRefPtr(AcAxObjectRef *const param_1, AcDb::OpenMode param_2, bool param_3=false)
bool isNull() const
Acad::ErrorStatus m_status
Definition addclass.h:254
Acad::ErrorStatus release(Param1 *&pReleasedObj)
Definition addclass.h:185
Acad::ErrorStatus acquire(Param1 *&pObjToAcquire)
Definition addclass.h:163