API Reference > Classes > PRC Base Data Types Classes > OdPrcObjectId Class > OdPrcObjectId Methods > OdPrcObjectId::safeOpenObject Method
OdPrcObjectId::safeOpenObject Method
Syntax
C++
OdPrcObjectPtr safeOpenObject(OpenMode openMode = kForRead, bool openErasedOne = false) const;
Parameters 
Description 
OpenMode openMode = kForRead 
[in] Mode in which the object must be opened.  
bool openErasedOne = false 
[in] Specifies whether erased objects are also opened (true) or not (false).
 

Returns a smart pointer to the opened object if successful or throws an exception in other case.

Safely opens the database object associated with the identifier. 

 

openMode must be one of the following:

Identifier 
Value 
Description 
kNotOpen 
-1 
Object is open for reading. 
kForRead 
Object is open for reading. 
kForWrite 
Object is open for reading and/or writing. 
kForNotify 
Object is open for notifying. 

 

Can throw one of the following exceptions:

Exception 
Cause 
eNullObjectId 
The identifier is null. 
ePermanentlyErased 
Object was not opened (in case when openErasedOne is true) 
eWasErased 
Not was not opened (in case when openErasedOne is false) 
Copyright (c) 2002-2020. Open Design Alliance. All rights reserved.