bool FlowController::PrepareRequest(Context &ctx) { StartTrace(FlowController.PrepareRequest); long reqNr = GetRequestNr(ctx); // number of runs of pre depends on number of slots in anything long nrOfPreRunRequests = fConfig["PreRun"].GetSize(); Anything tmpStore = ctx.GetTmpStore(); Anything flowState = tmpStore["FlowState"]; if (!flowState["PreRunDone"].AsBool(1)) { Trace("PRE RUN NOT DONE "); if (reqNr < nrOfPreRunRequests) { DoPrepare(tmpStore, fConfig["PreRun"][reqNr]); flowState["RequestNr"] = ++reqNr; TraceAny(tmpStore["FlowState"], "Flow State on exit"); return true; } else { // PreRun done , reset for normal run reqNr = 0; flowState["RunNr"] = 0L; flowState["PreRunDone"] = true; } } long nrOfRuns = 0; String appName; Application *application = Application::GetGlobalApplication(appName); if (application) { nrOfRuns = application->Lookup("NumberOfRuns", fConfig["NumberOfRuns"].AsLong(1)); Trace(appName << " application found" ); } else { nrOfRuns = fConfig["NumberOfRuns"].AsLong(1); } long runNr = flowState["RunNr"].AsLong(0); Trace("INIT Number of Run: " << runNr << " of " << nrOfRuns); while (runNr < nrOfRuns) { // loop thru steps and incr. runNr after each batch has been processed Trace("Number of Run: " << runNr << " of " << nrOfRuns); TraceAny(fConfig["Run"], "Config Run"); long nrOfRequests = fConfig["Run"].GetSize(); if (reqNr < nrOfRequests) { DoPrepare(tmpStore, fConfig["Run"][reqNr]); flowState["RequestNr"] = ++reqNr; TraceAny(tmpStore, "tmpStore on exit"); TraceAny(tmpStore["FlowState"], "Flow State on exit"); return true; } reqNr = 0; // reset request number flowState["RunNr"] = ++runNr; } TraceAny(tmpStore["FlowState"], "Flow State on exit with false"); return false; }
//------------------------------------------------------------------------------- // // PluginMain // // All calls to the plug in module come through this routine. // // Inputs: // const int16 selector Host provides selector indicating what // command to do. // // Inputs and Outputs: // FilterRecord *filterRecord Host provides a pointer to parameter block // containing pertinent data and callbacks. // See PIFilter.h // // intptr_t *data Use this to store a handle or pointer to our global // data structure, which is maintained by the // host between calls to the plug in. // // Outputs: // int16 *result Returns error result. Some errors are handled // by the host, some are silent, and some you // must handle. See PIGeneral.h. // //------------------------------------------------------------------------------- DLLExport MACPASCAL void PluginMain(const int16 selector, FilterRecordPtr filterRecord, intptr_t * data, int16 * result) { // update our global parameters gFilterRecord = filterRecord; gDataHandle = data; gResult = result; if (selector == filterSelectorAbout) { sSPBasic = ((AboutRecord*)gFilterRecord)->sSPBasic; } else { sSPBasic = gFilterRecord->sSPBasic; if (gFilterRecord->bigDocumentData != NULL) gFilterRecord->bigDocumentData->PluginUsing32BitCoordinates = true; } // do the command according to the selector switch (selector) { case filterSelectorAbout: DoAbout(); break; case filterSelectorParameters: DoParameters(); break; case filterSelectorPrepare: DoPrepare(); break; case filterSelectorStart: DoStart(); break; case filterSelectorContinue: DoContinue(); break; case filterSelectorFinish: DoFinish(); break; default: break; } // unlock our handles used by gData and gParams if (selector != filterSelectorAbout) UnlockHandles(); }
DLLExport SPAPI void PluginMain(const int16 selector, FilterRecordPtr filterRecord, intptr_t * data, int16 * result) { gData = data; gResult = result; if (selector == filterSelectorAbout) { sSPBasic = ((AboutRecordPtr)filterRecord)->sSPBasic; } else { gFilterRecord = filterRecord; sSPBasic = gFilterRecord->sSPBasic; if (gFilterRecord->bigDocumentData != NULL) gFilterRecord->bigDocumentData->PluginUsing32BitCoordinates = true; } switch (selector) { case filterSelectorAbout: DoAbout(); break; case filterSelectorParameters: DoParameters(); break; case filterSelectorPrepare: DoPrepare(); break; case filterSelectorStart: DoStart(); break; case filterSelectorContinue: DoContinue(); break; case filterSelectorFinish: DoFinish(); break; default: *gResult = filterBadParameters; break; } }
DLLExport MACPASCAL void PluginMain (const int16 selector, FilterRecordPtr filterParamBlock, intptr_t *data, int16 *result) { //--------------------------------------------------------------------------- // (1) Check for about box request. // // The about box is a special request; the parameter block is not filled // out, none of the callbacks or standard data is available. Instead, // the parameter block points to an AboutRecord, which is used // on Windows. //--------------------------------------------------------------------------- if (selector == filterSelectorAbout) { sSPBasic = ((AboutRecordPtr)filterParamBlock)->sSPBasic; DoAbout((AboutRecordPtr)filterParamBlock); } else { // do the rest of the process as normal: sSPBasic = ((FilterRecordPtr)filterParamBlock)->sSPBasic; Ptr globalPtr = NULL; // Pointer for global structure GPtr globals = NULL; // actual globals //----------------------------------------------------------------------- // (2) Allocate and initalize globals. // // AllocateGlobals requires the pointer to result, the pointer to the // parameter block, a pointer to the handle procs, the size of our local // "Globals" structure, a pointer to the long *data, a Function // Proc (FProcP) to the InitGlobals routine. It automatically sets-up, // initializes the globals (if necessary), results result to 0, and // returns with a valid pointer to the locked globals handle or NULL. //----------------------------------------------------------------------- globalPtr = AllocateGlobals (result, filterParamBlock, filterParamBlock->handleProcs, sizeof(Globals), data, InitGlobals); if (globalPtr == NULL) { // Something bad happened if we couldn't allocate our pointer. // Fortunately, everything's already been cleaned up, // so all we have to do is report an error. *result = memFullErr; return; } // Get our "globals" variable assigned as a Global Pointer struct with the // data we've returned: globals = (GPtr)globalPtr; //----------------------------------------------------------------------- // (3) Dispatch selector. //----------------------------------------------------------------------- switch (selector) { case filterSelectorParameters: DoParameters(globals); break; case filterSelectorPrepare: DoPrepare(globals); break; case filterSelectorStart: DoStart(globals); break; case filterSelectorContinue: DoContinue(globals); break; case filterSelectorFinish: DoFinish(globals); break; } //----------------------------------------------------------------------- // (4) Unlock data, and exit resource. // // Result is automatically returned in *result, which is // pointed to by gResult. //----------------------------------------------------------------------- // unlock handle pointing to parameter block and data so it can move // if memory gets shuffled: if (*data != 0 /* NULL */ ) PIUnlockHandle((Handle)*data); } // about selector special } // end PluginMain
void PVAuthorEngineNodeUtility::Run() { LOG_STACK_TRACE((0, "PVAuthorEngineNodeUtility::Run: Enter")); if (iCmdQueue.empty()) return; PVAENodeUtilCmd cmd = iCmdQueue[0]; if (cmd.iNodes.empty()) { LOG_ERR((0, "PVAuthorEngineNodeUtility::Run: Error - cmd.iNodes is empty")); CompleteUtilityCmd(cmd, PVMFFailure); return; } PVMFStatus status = PVMFFailure; LOG_STACK_TRACE((0, "PVAuthorEngineNodeUtility::Run: cmd.iType=%d", cmd.iType)); switch (cmd.iType) { case PVAENU_CMD_CONNECT: status = DoConnect(cmd); break; case PVAENU_CMD_DISCONNECT: status = DoDisconnect(cmd); break; case PVAENU_CMD_QUERY_UUID: status = DoQueryUuid(cmd); break; case PVAENU_CMD_QUERY_INTERFACE: status = DoQueryInterface(cmd); break; case PVAENU_CMD_INIT: status = DoInit(cmd); break; case PVAENU_CMD_PREPARE: status = DoPrepare(cmd); break; case PVAENU_CMD_START: status = DoStart(cmd); break; case PVAENU_CMD_PAUSE: status = DoPause(cmd); break; case PVAENU_CMD_STOP: status = DoStop(cmd); break; case PVAENU_CMD_FLUSH: status = DoFlush(cmd); break; case PVAENU_CMD_RESET: status = DoReset(cmd); break; default: status = PVMFFailure; break; } if (status != PVMFPending) CompleteUtilityCmd(cmd, status); LOG_STACK_TRACE((0, "PVAuthorEngineNodeUtility::Run: Exit")); }