Enregistrement d'adaptateur et table virtuelle de bibliothèque
La première étape requise pour développer un adaptateur consiste à ajouter l'adaptateur au fichier d'enregistrement .xml.
La ligne suivante est un exemple d'ajout d'adaptateur au fichier adapters.xml :
<UserAdapter name="File Sample" alias="SFILE" id="201" type="file"
library="filesamp" vendor="abc"/>Il contient une zone clé : le nom de la bibliothèque (library="filesamp"). Notez que le nom ne doit pas contenir d'extension .DLL, .SO, .SL ou autre extension de bibliothèque.
L'adaptateur doit exporter la table virtuelle de la bibliothèque, qui doit recevoir le même nom que la bibliothèque, avec le suffixe _config. Par exemple, filesamp_config.
La table virtuelle de la bibliothèque contient plusieurs pointeurs vers les méthodes et informations de configuration pour l'adaptateur. Sa structure est la suivante :
struct MPI_LIBRARY_VTABLE
{
size_t nSize; /* size of this structure */
MPIRC (*pfInitializeLibrary)(void);
MPIRC (*pfDestroyLibrary)(void);
MPIRC (*pfCreateAdapterInstance)(HMPIADAPT *phAdapter, HMPICARD hCard);
MPIRC (*pfDestroyAdapterInstance)(HMPIADAPT hAdapter);
MPIRC (*pfCreateConnectionInstance)(HMPICONNECT *phConnection);
MPIRC (*pfDestroyConnectionInstance)(HMPICONNECT hConnection);
MPIRC (*pfCombinedListen)(HMPIADAPTCOLL hColl,HMPICONNECT hConn);
char lpszCommandMask; /* Mask of command line arguments defining connection
*/
int nTransMode; /* single, multiple or non-transactional */
int nBurstType; /* Unit of work - message or logical */
int bListener; /* Does the adapter support listener interface */
int bListenerBlocks; /* Does the listener block */
int bListenerTrans; /* Is the listener transactional? */
int bRetries; /* Does the adapter support retries */
/* Source settings */
int bSourceManage; /* Should RM manage the source? */
int bSourceWarnings; /* Does the adapter return warnings on sources? */
int nSourceScopes; /* Which adapter Scope settings are supported for source?
*/
int nSourceOnSuccess; /* Which OnSuccess settings are supported for source?
*/
int nSourceOnFailure; /* Which OnFailure settings are supported for source?
*/
int nDefSourceScope; /* Default Scope setting for source */
int nDefSourceOnSuccess; /* Default OnSuccess setting for source */
int nDefSourceOnFailure; /* Default OnFailure setting for source */
/* Target settings */
int bTargetManage; /* Should RM manage the target? */
int bTargetWarnings; /* Does the adapter return warnings on targets? */
int nTargetScopes; /* Which adapter scope settings are supported for target?
*/
int nTargetOnSuccess; /* Which OnSuccess settings are supported for target?
*/
int nTargetOnFailure; /* Which OnFailure settings are supported for target?
*/
int nDefTargetScope; /* Default Scope setting for target */
int nDefTargetOnSuccess; /* Default OnSuccess setting for target */
int nDefTargetOnFailure; /* Default OnFailure setting for target */
};
typedef struct MPI_LIBRARY_VTABLE MPI_LIBRARY_VTABLE;