The reactor classes derive from Acrxobject instead of Acdbobject because they are not database objects, have no ID, and do not have an owning relationship.
Different types of reactors receive different types of notification events. database reactor, derived from Acdbdatabasereactor, receives events related to the state of the database, when an object is added to the database, modified or deleted in the database. The notification sender of this reactor is a database, so it is added to the list of reactors in the database. object reactor, derived from Acdbobjectreactor, is responsible for receiving object-level events such as copying, deleting, and modifying an object. It can be added to the list of reactors for any Acdbobject object. Editor reactor, which derives from Aceditorreactor,is responsible for receiving special AutoCAD events, such as loading or unloading a diagram, starting or ending a command, and other types of user interaction. the only notification sender for the Aceditor object aceditorreactor. Here is the inheritance diagram for the reactor class:
The reactors above are temporary reactor classes. If you want your program to receive event notifications, you typically use a staging reactor to monitor database object events, database events, user interactions, and other system events while the application is running.
Another type of reactor is called a permanent reactor, with a database object (aninstance of the Acdbobject class and its derived classes) as a reactor. Database objects can receive notifications as if they were sent. The permanent reactors ' dependencies within the database are part of the database, so they are stored in dwg and dxf files and rebuilt when the files are loaded.
Use Acdbobject as a reactor
1. Derive a new Acdbobject class and implement your object's notification function to be responsible for the event.
2. Instantiate the object reactor.
3. Add the object reactor to the database and give him an owner, preferably a container object, so that he can be properly stored out.
4. Use the addpersistentreactor () function to add the object reactor to the list of reactors that inform the sender. This function requires you to pass in the ID of the object reactor , which you created in step 2.
Note: When you copy an object, any permanent reactors attached to the object will also be duplicated, and the attachment relationship of the temporary reactors will not be duplicated.
Using a staging reactor, derive a new class from the following base class:
Acapdocmanagerreactor
Monitor document management Series events.
Acaplongtransactionreactor
Monitor long transaction-related actions.
Acdbdatabasereactor
Monitors the creation, modification, and deletion of database objects.
Acdbentityreactor
Monitor some additional entity-specific events, such as modifying an image.
Acdblayoutmanagerreactor
Monitor events related to layout management.
Acdbobjectreactor
Monitors events related to specific database objects, such as creation, modification, and deletion.
Acdbsummaryinforeactor
Monitor changes related to summary information.
Acedinputcontextreactor
Monitors events related to prompts when user input.
Aceditorreactor
Monitor AutoCAD-specific events, such as commands,autolisp assignments.
Acrxdlinkerreactor
Monitor the loading and unloading of OBJECTARX applications.
Acrxeventreactor
Monitor the events used by Objectarx and objectdbx.
Actransactionreactor
Monitor events related to transaction management, such as the start, Abort, and end of a transaction.
In most cases, you can create a new temporary reactor class with just standard C + + technology. A Objectarx macro that creates a class descriptor object for a new reactor class is generally not used to derive these reactor classes.
Each parent class contains a series of virtual notification functions that can be implemented in a new derived class. For example,Acdbobjectreactor contains the following notification functions for object-related events:
· cancelled ()
· copied ()
· erased ()
· Goodbye ()
· openedformodify ()
· modified ()
· subobjmodified ()
· Modifyundone ()
· Modifiedxdata ()
· unappended ()
· reappended ()
· objectclosed ()
Each function requires a pointer to the sender of the notification. The base class Acdbobjectreactor has an empty implementation of each function. In your derived reactor class, implement the notification type function that you are interested in. Then instantiate the reactor and use the acdbobject::addreactor () function to add him to any number of database objects. Add or remove a temporary reactor, the object can be any state (read, write, notification). Adding or removing temporary objects is not monitored by the undomechanism. (For a permanent reactor, the notification sending object must be open as write, and adding or removing the reactor will be monitored by the undomechanism.) You create a temporary reactor object, and you are responsible for deleting it.
When an object is deleted, for example, it calls the erased () notification function to notify each reactor in his list of reactors. If you implement the erased () function for your reactor, the database object will call this function, then when the object is deleted, you can take the task special action corresponding to your program.
The use of reactor reactor in Objectarx