To create a new registered application, declare a variable of the OdDbRegAppTableRecordPtr
type and use the pseudo-constructor of the registered application record object.
This pseudo-constructor is the static method that creates a new dynamic instance
of the registered application record and
returns the smart pointer to it. For example:
The created instance exists independently from the database. Many properties of the
registered application record object are invalid
initially, and the registered application instance does not get an ID until the
registered application is added in the database. The registered application
table object cannot manipulate the new application data without the OdDbObjectId
instance associated with the created registered application record object. The
new registered application instance gets an empty name by default. The
registered application table object cannot identify a registered application without a name.
Therefore, after creation, the program must assign a name for the new registered
application, and then the program must add it in the
registered application table of the database.
The application name is an arbitrary nonempty string that can be up to 255 characters long and can contain letters, digits,
blank spaces, underscores, and some special characters, but cannot contain inadmissible letters
(see Naming objects). The database contains
the predefined registered application with fixed name: "ACAD" that identifies
the extended data for AutoCAD application. The registered application record object has the getName() method for getting the name and the setName() method
for setting the name.
To get the name, use the getName() method of the registered application record object; it does not have arguments and returns the
application
name as an OdString value. For example:
OdString sName = pRegApp->getName();
odPrintConsoleString(L"\nRegistered application has the name: %s", sName.c_str());
To set the name, use the setName() method of the registered application record object; it requires the
application name as a nonempty OdString
value and does not return a value. For example:
pRegApp->setName("ODA");
If the application name contains inadmissible letters, the setName() method generates the exception:
«37 - Invalid Symbol Table name». If the application name is an empty string, the setName()
method generates the exception: «106 - Empty Record name».
To add an application in the registered application table, use the add() method of the
registered application table object which requires one argument —
the pointer to the registered application instance to be added — and returns the OdDbObjectId instance associated with the added
registered application record object. In the examples below, the pRegApps variable stores a pointer to the
registered application table object. For example:
OdDbObjectId idRegApp = pRegApps->add(pRegApp);
If the registered application table already contains a registered application with a name that coincides with the new name, the add() and setName()
methods generate the exception: "104 - Duplicate Record name object [10]". The
exception message contains a handle of the duplicate registered application in the square brackets. To check whether the
registered application table contains an application with the specified name, use
the has() method of the registered application table object.
To catch exceptions, use the try … catch statement when the program adds the
registered application record object in the table.
The following example demonstrates the procedure: