📄 stafvariableservice.cpp
字号:
/*****************************************************************************//* Software Testing Automation Framework (STAF) *//* (C) Copyright IBM Corp. 2001, 2004, 2005 *//* *//* This software is licensed under the Common Public License (CPL) V1.0. *//*****************************************************************************/ #include "STAF.h"#include "STAFProc.h"#include "STAFProcUtil.h"#include "STAFUtil.h"#include "STAFVariableService.h"#include "STAFVariablePool.h"#include "STAFHandleManager.h"#include "STAFRequestManager.h"// XXX: Might want to think about being able to create other "system" variable// pools by name, and then adding a POOL <Name> option to the above.STAFVariableService::STAFVariableService() : STAFService("VAR"){ // var options fVarParser.addOption("SET", 1, STAFCommandParser::kValueNotAllowed); fVarParser.addOption("GET", 1, STAFCommandParser::kValueNotAllowed); fVarParser.addOption("DELETE", 1, STAFCommandParser::kValueNotAllowed); fVarParser.addOption("LIST", 1, STAFCommandParser::kValueNotAllowed); fVarParser.addOption("RESOLVE", 1, STAFCommandParser::kValueNotAllowed); fVarParser.addOption("SYSTEM", 1, STAFCommandParser::kValueNotAllowed); fVarParser.addOption("SHARED", 1, STAFCommandParser::kValueNotAllowed); fVarParser.addOption("HANDLE", 1, STAFCommandParser::kValueRequired); fVarParser.addOption("ASHANDLE", 1, STAFCommandParser::kValueRequired); fVarParser.addOption("REQUEST", 1, STAFCommandParser::kValueAllowed); fVarParser.addOption("VAR", 0, STAFCommandParser::kValueRequired); fVarParser.addOption("STRING", 0, STAFCommandParser::kValueRequired); fVarParser.addOption("HELP", 1, STAFCommandParser::kValueNotAllowed); // var groups fVarParser.addOptionGroup("SET GET DELETE LIST RESOLVE HELP", 1, 1); fVarParser.addOptionGroup("SYSTEM SHARED HANDLE ASHANDLE REQUEST", 0, 1); // var needs fVarParser.addOptionNeed("SET GET DELETE", "VAR"); fVarParser.addOptionNeed("REQUEST ASHANDLE", "RESOLVE LIST"); fVarParser.addOptionNeed("RESOLVE", "STRING"); fVarParser.addOptionNeed("STRING", "RESOLVE"); // Construct map-class for resolve var info fResolveStringClass = STAFMapClassDefinition::create( "STAF/Service/Var/ResolveString"); fResolveStringClass->addKey("rc", "RC"); fResolveStringClass->addKey("result", "Result");}STAFVariableService::~STAFVariableService(){ /* Do Nothing */}STAFString STAFVariableService::info(unsigned int) const{ return name() + ": Internal";}STAFServiceResult STAFVariableService::acceptRequest( const STAFServiceRequest &requestInfo){ STAFCommandParseResultPtr parsedResult = fVarParser.parse(requestInfo.fRequest); if (parsedResult->rc != kSTAFOk) { return STAFServiceResult(kSTAFInvalidRequestString, parsedResult->errorBuffer); } DEFINE_VAR_POOL_LIST(varPoolList, varPoolListSize, requestInfo); STAFString errorBuffer; STAFRC_t rc = kSTAFOk; STAFHandle_t theHandle = 0; STAFRequestNumber_t theRequest = 0; STAFVariablePoolPtr handleVarPoolPtr; // Maximum number of pools that could be used const unsigned int MAX_VARIABLE_POOLS = 6; const STAFVariablePool *varPoolListMain[MAX_VARIABLE_POOLS]; unsigned int varPoolListSizeMain = 0; if (parsedResult->optionTimes("HANDLE") != 0) { // Use handle pool only, for all commands rc = RESOLVE_OPTIONAL_UINT_OPTION("HANDLE", theHandle); if (rc) return STAFServiceResult(rc, errorBuffer); rc = gHandleManagerPtr->variablePool(theHandle, handleVarPoolPtr); if (rc != kSTAFOk) return STAFServiceResult(rc); varPoolListMain[varPoolListSizeMain] = handleVarPoolPtr; varPoolListSizeMain++; } else if (parsedResult->optionTimes("SYSTEM") != 0) { // Use local system pool only, for all commands varPoolListMain[varPoolListSizeMain] = requestInfo.fLocalSystemVarPool; varPoolListSizeMain++; } else if (parsedResult->optionTimes("SHARED") != 0) { // Use local shared pool only, for all commands varPoolListMain[varPoolListSizeMain] = requestInfo.fLocalSharedVarPool; varPoolListSizeMain++; } else if (parsedResult->optionTimes("ASHANDLE") != 0) { // For LIST and resolve commands only // Use local handle, local shared, local system pools rc = RESOLVE_OPTIONAL_UINT_OPTION("ASHANDLE", theHandle); if (rc) return STAFServiceResult(rc, errorBuffer); rc = gHandleManagerPtr->variablePool(theHandle, handleVarPoolPtr); if (rc != kSTAFOk) return STAFServiceResult(rc); varPoolListMain[varPoolListSizeMain] = handleVarPoolPtr; varPoolListSizeMain++; varPoolListMain[varPoolListSizeMain] = requestInfo.fLocalSharedVarPool; varPoolListSizeMain++; varPoolListMain[varPoolListSizeMain] = requestInfo.fLocalSystemVarPool; varPoolListSizeMain++; } else if (parsedResult->optionTimes("REQUEST") != 0 || (parsedResult->optionTimes("REQUEST") == 0 && (parsedResult->optionTimes("LIST") != 0 || parsedResult->optionTimes("RESOLVE") != 0))) { // For LIST and RESOLVE commands only // If request was from local system, // use local handle, shared, system pools; // Else if request was from remote system, // use local request, remote shared, local shared, local system pools; // If no value or none of the option was specified, // use the request's own request number, itself. rc = RESOLVE_OPTIONAL_UINT_OPTION("REQUEST", theRequest); if (rc) return STAFServiceResult(rc, errorBuffer); if (theRequest == 0) theRequest = requestInfo.fRequestNumber; STAFRequestManager::RequestMap requestMap = gRequestManagerPtr->getRequestMapCopy(); STAFServiceRequestPtr serviceRequest; if (requestMap.find(theRequest) != requestMap.end()) { serviceRequest = requestMap[theRequest]; } else { return STAFServiceResult(kSTAFRequestNumberNotFound); } // In the request came from local system, // the source shared pool and local shared pool are the same varPoolListMain[varPoolListSizeMain] = serviceRequest->fRequestVarPool; varPoolListSizeMain++; varPoolListMain[varPoolListSizeMain] = serviceRequest->fSourceSharedVarPool; varPoolListSizeMain++; varPoolListMain[varPoolListSizeMain] = serviceRequest->fLocalSharedVarPool; varPoolListSizeMain++; varPoolListMain[varPoolListSizeMain] = serviceRequest->fLocalSystemVarPool; varPoolListSizeMain++; } else { // For SET, GET, DELETE commands only, // (RESOLVE and LIST commands have been handled earlier) // When none of the options was specified,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -