Share
 
 

Registering an Application

Application names are saved with the extended data of each entity that uses them and in the APPID table. An application must register the name or names it uses. In ObjectARX, this is done by a call to acdbRegApp(). The acdbRegApp() function specifies a string to use as an application name. It returns RTNORM if it can successfully add the name to APPID; otherwise, it returns RTERROR. A result of RTERROR usually indicates that the name is already in the symbol table. This is not an actual error condition but a normally expected return value, because the application name needs to be registered only once per drawing.

To register itself, an application should first check that its name is not already in the APPID table, because acdbRegApp() needs to be called only once per drawing. If the name is not there, the application must register it; otherwise, it can go ahead and use the data.

The following sample code fragment shows the typical use of acdbRegApp().

#define APPNAME "Local_Operation_App_3-2" 
struct resbuf *rbp; 
static char *local_appname = APPNAME; 
// The static declaration prevents a copy being made of the string
// every time it's referenced.
. 
. 
. 
if ((rbp = acdbTblSearch("APPID", local_appname, 0)) == NULL) { 
    if (acdbRegApp(APPNAME) != RTNORM) { // Some other
                                         // problem
        acutPrintf("Can't register XDATA for %s.",
                    local_appname); 
        return BAD; 
    } 
} else { 
    acutRelRb(rbp); 
} 

Was this information helpful?