
Adobe Acrobat SDK
Working with Acrobat Extended APIs
Developing Plug-ins and Applications
Importing the consultant HFTs into a plug-in 223
Avoiding agent collisions
When running multiple agents on a document, the order in which you register your agents is the order in
which the consultant will hand them objects. If your earlier agents modify objects, they may change the
objects in such a way that they are missing important information or are of a different type than they were
originally. For example, one agent might consider it correct to remove a given field of an object, while
another would complain that the field was not present and would want to add it. If the first agent modified
the object type, subsequent agents would no longer think they were interested in it, and their processing
would not take place. You must group your agents so that you do not run multiple agents with conflicting
goals at the same time.
A rarer problem could occur with self-referential objects. For example, if
DictA
contains a reference to
itself and the first agent replaces
DictA
with
DictB
(which would still contain a reference to
DictA
),
another agent cannot work with
DictB
until the internal reference is changed. But if you are running the
agents concurrently, there will be a collision. This would be a case best handled by the consultant.
Avoiding visitation collisions
Objects that have multiple classifications can be reached from multiple paths. In such cases you might
allow the consultant to revisit such objects if, and only if, they have been reclassified on a new path.
However, you must take care not to allow revisitation under other circumstances, or the consultant could
miss objects, which would defeat the reason for using a mode that considers object classification.
Importing the consultant HFTs into a plug-in
The consultant exports its functions using an HFT. The variable name your plug-in uses for the HFT must
be of type HFT and named
gConsultantHFT
. The consultant’s HFT allows you to create consultants. The
consultant exports an HFT that deals with the general operation of the consultant, including the creation
and deletion of consultant objects and agent registration. You must load the consultant plug-in before the
HFTs plug-ins can import it. Importing the consultant’s HFT is the same as importing any other plug-in’s
HFT. For information, see
“Importing an existing HFT” on page 173
.
To access the HFT, you must include the ConsHFT.h file into your project. In a plug-in, the
PluginImportReplaceAndRegister
method should contain the code that imports the HFT.
Example 20.1
Importing consultant HFTs
HFT gConsultantHFT= (HFT)NULL;
ACCB1 ASBool ACCB2 PluginImportReplaceAndRegister(void)
{
ASBool bRetVal = false;
//Import the Consultant's main HFT
gConsultantHFT = Init_PDFConsultantHFT; // Macro in ConsHFT.h
if(gConsultantHFT != (HFT)NULL)
bRetVal = true;
else
//Put in error message about the absence of the Consultant HFT
return bRetVal;
};