CFx SDK Documentation  2022 SP0
DbObjectId.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 
25 #ifndef _ODDBOBJECTID_INCLUDED_
26 #define _ODDBOBJECTID_INCLUDED_ /* {Secret } */
27 
28 #include "DbExport.h"
29 #include "DbHandle.h"
30 #include "OdError.h"
31 #include "TD_PackPush.h"
32 
33 class OdDbDatabase;
34 class OdDbObject;
35 class OdRxClass;
36 
37 template <class T> class OdSmartPtr;
38 
43 
44 class OdDbStub;
45 class OdDbStubExt;
46 
51 namespace OdDb
52 {
53  enum OpenMode
54  {
55  kNotOpen = -1, // Object is not open.
56  kForRead = 0, // Object is open for reading.
57  kForWrite = 1, // Object is open for reading and/or writing.
58  kForNotify = 2 // Object is open for notify.
59  };
60 
62  {
63  kSoftPointerRef = 0, // Soft Pointer Reference
64  kHardPointerRef = 1, // Hard Pointer Reference
65  kSoftOwnershipRef = 2, // Soft Ownership Reference
66  kHardOwnershipRef = 3 // Hard Ownership Reference
67  };
68 }
69 
99 {
100 public:
105  OdDbObjectId () : m_Id (0) { }
106 
113  OdDbStub* objectId) : m_Id (objectId) { }
114 
119 
123  bool isNull () const { return m_Id == 0; }
124 
128  void setNull () { m_Id = 0; }
129 
133  bool isValid () const;
134 
135  // VS2015 requires to create copy constructor explicity
136 #if defined(_MSC_VER) && (_MSC_VER > 1800)
137  OdDbObjectId(const OdDbObjectId& objectId) = default;
138  OdDbObjectId& operator = (const OdDbObjectId& objectId) = default;
139 #endif
140 
143  OdDbObjectId& operator = (
144  OdDbStub* objectId) { m_Id = objectId; return *this; }
145 
147  const OdDbObjectId& objectId) const;
148 
150  const OdDbObjectId& objectId) const;
151 
153  const OdDbObjectId& objectId) const;
154 
156  const OdDbObjectId& objectId) const;
157 
159  const OdDbObjectId& objectId) const;
160 
162  const OdDbObjectId& objectId) const;
163 
164  bool operator ! () const { return isNull(); }
165 
171  inline operator OdDbStub* () const { return (OdDbStub*)m_Id; }
172 
178  inline OdDbStubExt* operator -> () const { return (OdDbStubExt*)m_Id; }
179 
187 
199 
205 
209  bool isErased () const;
210 
215  bool isEffectivelyErased () const;
216 
222  bool objectLeftOnDisk () const;
223 
233  const OdDbHandle& getHandle () const;
234 
245 
267  OdDbObjectPtr& pObj,
268  OdDb::OpenMode openMode = OdDb::kForRead,
269  bool openErasedOne = false) const;
291  OdDb::OpenMode openMode = OdDb::kForRead,
292  bool openErasedOne = false) const;
323  OdDb::OpenMode openMode = OdDb::kForRead,
324  bool openErasedOne = false) const;
325 
331  void bindObject (
332  OdDbObject* pObj);
333 
335 
336 protected:
337  friend class OdDbStub;
338  OdDbStub* m_Id;
339 };
340 
356 {
357 public:
358 
360 
362  const OdDbObjectId& objectId) : OdDbObjectId (objectId) {}
363 
366  OdDbStub* objectId) : OdDbObjectId (objectId) {}
367 
368  OdDbHardOwnershipId& operator = (
369  const OdDbObjectId& objectId) { OdDbObjectId::operator= (objectId); return *this; }
370 
371 
373  OdDbHardOwnershipId& operator = (
374  OdDbStub* objectId) { m_Id = objectId; return *this; }
375 
377  const OdDbObjectId& objectId) const { return OdDbObjectId::operator!= (objectId); }
378 
381  OdDbStub* objectId) const { return OdDbObjectId::operator!= (objectId); }
382 
384  const OdDbObjectId& objectId) const { return OdDbObjectId::operator== (objectId); }
385 
388  OdDbStub* objectId) const { return OdDbObjectId::operator== (objectId); }
389 };
390 
406 {
407 public:
408 
410 
412  const OdDbObjectId& objectId) : OdDbObjectId (objectId) {}
413 
416  OdDbStub* objectId) : OdDbObjectId (objectId) {}
417 
418  OdDbSoftOwnershipId& operator = (
419  const OdDbObjectId& objectId) { OdDbObjectId::operator= (objectId); return *this; }
420 
422  OdDbSoftOwnershipId& operator = (
423  OdDbStub* objectId) { m_Id = objectId; return *this; }
424 
426  const OdDbObjectId& objectId) const { return OdDbObjectId::operator!= (objectId); }
427 
430  OdDbStub* objectId) const { return OdDbObjectId::operator!= (objectId); }
431 
433  const OdDbObjectId& objectId) const { return OdDbObjectId::operator== (objectId); }
434 
437  OdDbStub* objectId) const { return OdDbObjectId::operator== (objectId); }
438 
439 };
440 
453 {
454 public:
455 
457 
459  const OdDbObjectId& objectId) : OdDbObjectId (objectId) {}
460 
463  OdDbStub* objectId) : OdDbObjectId (objectId) {}
464 
465  OdDbHardPointerId& operator = (
466  const OdDbHardPointerId& objectId) { OdDbObjectId::operator= (objectId); return *this; }
467 
468  OdDbHardPointerId& operator = (
469  const OdDbObjectId& objectId) { OdDbObjectId::operator= (objectId); return *this; }
470 
472  OdDbHardPointerId& operator = (
473  OdDbStub* objectId) { m_Id = objectId; return *this; }
474 
476  const OdDbObjectId& objectId) const { return OdDbObjectId::operator!= (objectId); }
477 
480  OdDbStub* objectId) const { return OdDbObjectId::operator!= (objectId); }
481 
483  const OdDbObjectId& objectId) const { return OdDbObjectId::operator== (objectId); }
484 
487  OdDbStub* objectId) const { return OdDbObjectId::operator== (objectId); }
488 };
489 
501 {
502 public:
504 
506  const OdDbObjectId& objectId) : OdDbObjectId (objectId) {}
507 
510  OdDbStub* objectId) : OdDbObjectId (objectId) {}
511 
512  OdDbSoftPointerId& operator = (
513  const OdDbSoftPointerId& objectId) { OdDbObjectId::operator= (objectId); return *this; }
514 
515  OdDbSoftPointerId& operator = (
516  const OdDbObjectId& objectId) { OdDbObjectId::operator= (objectId); return *this; }
517 
519  OdDbSoftPointerId& operator = (
520  OdDbStub* objectId) { m_Id = (OdDbStub*)objectId; return *this; }
521 
523  const OdDbObjectId& objectId) const { return OdDbObjectId::operator!= (objectId); }
524 
527  OdDbStub* objectId) const { return OdDbObjectId::operator!= (objectId); }
528 
530  const OdDbObjectId& objectId) const { return OdDbObjectId::operator== (objectId); }
533  OdDbStub* objectId) const { return OdDbObjectId::operator== (objectId); }
534 
535 };
536 
537 #include "TD_PackPop.h"
538 
539 #endif //_ODDBOBJECTID_INCLUDED_
540 
541 
#define TOOLKIT_EXPORT
Definition: DbExport.h:40
#define TOOLKIT_EXPORT_STATIC
Definition: DbExport.h:42
OdSmartPtr< OdDbObject > OdDbObjectPtr
Definition: DbObjectId.h:37
OdResult
Definition: OdResult.h:29
bool operator>=(const OdString &s1, const OdString &s2)
Definition: OdString.h:1351
bool operator<=(const OdString &s1, const OdString &s2)
Definition: OdString.h:1329
bool operator<(const OdString &s1, const OdString &s2)
Definition: OdString.h:1284
bool operator>(const OdString &s1, const OdString &s2)
Definition: OdString.h:1307
OdDbHardOwnershipId(const OdDbObjectId &objectId)
Definition: DbObjectId.h:361
OdDbHardOwnershipId(OdDbStub *objectId)
Definition: DbObjectId.h:365
OdDbHardPointerId(OdDbStub *objectId)
Definition: DbObjectId.h:462
OdDbHardPointerId(const OdDbObjectId &objectId)
Definition: DbObjectId.h:458
bool isValid() const
bool operator==(const OdDbObjectId &objectId) const
OdRxClass * objectClass() const
static TOOLKIT_EXPORT_STATIC const OdDbObjectId kNull
Definition: DbObjectId.h:118
bool isEffectivelyErased() const
void setNull()
Definition: DbObjectId.h:128
OdDbObjectPtr safeOpenObject(OdDb::OpenMode openMode=OdDb::kForRead, bool openErasedOne=false) const
const OdDbHandle & getNonForwardedHandle() const
OdDbObjectPtr openObject(OdDb::OpenMode openMode=OdDb::kForRead, bool openErasedOne=false) const
OdDbStub * m_Id
Definition: DbObjectId.h:338
bool objectLeftOnDisk() const
const OdDbHandle & getHandle() const
bool operator!=(const OdDbObjectId &objectId) const
bool isErased() const
OdDbObjectId & operator=(OdDbStub *objectId)
Definition: DbObjectId.h:143
OdDbObjectId(OdDbStub *objectId)
Definition: DbObjectId.h:112
void bindObject(OdDbObject *pObj)
bool isNull() const
Definition: DbObjectId.h:123
OdDbDatabase * database() const
OdResult openObject(OdDbObjectPtr &pObj, OdDb::OpenMode openMode=OdDb::kForRead, bool openErasedOne=false) const
OdDbDatabase * originalDatabase() const
void convertToRedirectedId()
OdDbSoftOwnershipId(const OdDbObjectId &objectId)
Definition: DbObjectId.h:411
OdDbSoftOwnershipId(OdDbStub *objectId)
Definition: DbObjectId.h:415
OdDbSoftPointerId(const OdDbObjectId &objectId)
Definition: DbObjectId.h:505
OdDbSoftPointerId(OdDbStub *objectId)
Definition: DbObjectId.h:509
bool DAI_EXPORT operator!=(const OdDAI::OdSelect &left, const OdDAI::OdSelect &right)
bool DAI_EXPORT operator==(const OdFileDescriptionAuto &left, const OdFileDescriptionAuto &right)
ReferenceType
Definition: DbObjectId.h:62
@ kHardPointerRef
Definition: DbObjectId.h:64
@ kSoftOwnershipRef
Definition: DbObjectId.h:65
@ kSoftPointerRef
Definition: DbObjectId.h:63
@ kHardOwnershipRef
Definition: DbObjectId.h:66
OpenMode
Definition: DbObjectId.h:54
@ kNotOpen
Definition: DbObjectId.h:55
@ kForRead
Definition: DbObjectId.h:56
@ kForWrite
Definition: DbObjectId.h:57
@ kForNotify
Definition: DbObjectId.h:58