Overriding a card in a map
This example shows how to set properties of card objects to override the settings of the compiled map.
Note: This example is written to be used with the GZIP adapter ,which is not available
on all platforms. If necessary, override the GZIP adapter type in this example with a substitute
adapter to correctly run the example.
#include "dtxpi.h"
#define CHECK_ERR(rc) if(MPIRC_FAILED(rc))
{ printf("Last error is: %s\n",mpiErrorGetText(rc));
return -1;}
int main()
{
const char *szMsg;
int iRC;
MPIRC rc;
HMPIMAP hMap;
HMPICARD hInputCard1;
HMPIADAPT hAdapter;
rc = mpiInitAPI(NULL);
CHECK_ERR(rc);
rc = mpiMapLoadFile (&hMap, "test3.mmc");
CHECK_ERR(rc);
/* Turn on burst and summary execution audit on the map instance */
rc = mpiPropertySetInteger (hMap, MPIP_MAP_AUDIT_SWITCH, 0,
MPI_SWITCH_ON);
CHECK_ERR(rc);
rc = mpiPropertySetInteger (hMap, MPIP_MAP_AUDIT_BURST_EXECUTION, 0,
MPI_SWITCH_ON);
CHECK_ERR(rc);
rc = mpiPropertySetInteger (hMap, MPIP_MAP_AUDIT_SUMMARY_EXECUTION, 0,
MPI_SWITCH_ON);
CHECK_ERR(rc);
/* Get the adapter object handle */
rc = mpiMapGetInputCardObject (hMap, 1, &hInputCard1);
CHECK_ERR(rc);
rc = mpiCardOverrideAdapter(hInputCard1,"GZIP",0);
CHECK_ERR(rc);
rc = mpiCardGetAdapterObject (hInputCard1, &hAdapter);
CHECK_ERR(rc);
/* set a command line for the adapter */
rc = mpiPropertySetText(hAdapter, MPIP_ADAPTER_COMMANDLINE, 0,
"-FILE Input.gz",
0);
CHECK_ERR(rc);
rc = mpiMapRun (hMap);
CHECK_ERR(rc);
rc = mpiPropertyGetText (hMap, MPIP_OBJECT_ERROR_MSG, 0, &szMsg, NULL);
CHECK_ERR(rc);
rc = mpiPropertyGetInteger (hMap, MPIP_OBJECT_ERROR_CODE, 0, &iRC);
CHECK_ERR(rc);
printf("Map status: %s (%d)\n", szMsg, iRC);
rc = mpiMapUnload (hMap);
CHECK_ERR(rc);
rc = mpiTermAPI();
CHECK_ERR(rc);
return 0;
}