Application-Specific Document Objects

This section outlines how MDI-aware applications need to be structured. Virtually all ObjectARX application developers must maintain a map between the system-supplied document objects and corresponding application-specific data. Any such map should be keyed with specific AcApDocument pointer values (addresses).

This requires that the application at least implement callbacks for the AcApDocManagerReactor methods documentCreated() and documentToBeDestroyed(), to create and delete the corresponding document-specific state. Make sure your AcApDocument pointers are up to date, as they will likely be reused as documents are terminated and created. As an alternative, you can implement handlers for when your acrxEntryPoint() function is invoked with AcRx::kLoadDwgMsg and AcRx::kUnloadDwgMsg messages, which are invoked with the document in question being current.

Such application-specific data should contain any state that must be associated with each open document that must persist across commands. One implementation alternative would be to maintain an AcArray template of a class whose instances consist of an AcApDocument pointer and a pointer to, or instance of, your document-specific state, and whose == operator is overloaded to compare only the AcApDocument* member. Another approach would be to maintain a pair of arrays with corresponding elements, do a find on the document pointers, and fetch the corresponding element out of the other array.