bool InputSystem::GetAnyActiveInputSource ( DeviceChecker& checker, InputSource& inputSource, InputSource::DeviceClass deviceClass, InputSource::DeviceComponent deviceComponent ) const { //Clear output value inputSource.Reset(); //Check keyboard if (inputSource.deviceType == InputSource::NO_TYPE && ((deviceClass & InputSource::KEYBOARD) || (deviceComponent & InputSource::KEY))) { OIS::KeyCode key = checker.GetKeyboardKey(this->Keyboard); if (key != OIS::KC_UNASSIGNED) { inputSource.deviceType = InputSource::KEYBOARD_KEY; inputSource.keyCode = key; } } //Check mouse buttons if (inputSource.deviceType == InputSource::NO_TYPE && ((deviceClass & InputSource::MOUSE) || (deviceComponent & InputSource::BUTTON))) { int buttonIndex = checker.GetMouseButton(this->Mouse); if (buttonIndex != -1) { inputSource.deviceType = InputSource::MOUSE_BUTTON; inputSource.button = buttonIndex; } } //Check mouse axes if (inputSource.deviceType == InputSource::NO_TYPE && ((deviceClass & InputSource::MOUSE) || (deviceComponent & InputSource::AXIS))) { if (checker.GetMouseAxisIndexAndDirection(this->Mouse, inputSource.axis, inputSource.direction)) inputSource.deviceType = InputSource::MOUSE_AXIS; } //Check joystick buttons if (inputSource.deviceType == InputSource::NO_TYPE && ((deviceClass & InputSource::JOYSTICK) || (deviceComponent & InputSource::BUTTON))) { int buttonIndex; for (size_t joystickIndex = 0; joystickIndex < this->joystickCount; joystickIndex++) { buttonIndex = checker.GetJoystickButton(this->joysticks[joystickIndex]); if (buttonIndex != -1) { inputSource.deviceType = InputSource::JOYSTICK_BUTTON; inputSource.button = buttonIndex; inputSource.deviceIndex = (int)joystickIndex; break; } } } //Check joystick axes if (inputSource.deviceType == InputSource::NO_TYPE && ((deviceClass & InputSource::JOYSTICK) || (deviceComponent & InputSource::AXIS))) { for (size_t joystickIndex = 0; joystickIndex < this->joystickCount; joystickIndex++) { if (checker.GetJoystickAxisIndexAndDirection(this->joysticks[joystickIndex], inputSource.axis, inputSource.direction)) { inputSource.deviceType = InputSource::JOYSTICK_AXIS; inputSource.deviceIndex = (int)joystickIndex; break; } } } //Check joystick POV if (inputSource.deviceType == InputSource::NO_TYPE && ((deviceClass & InputSource::JOYSTICK) || (deviceComponent & InputSource::POV))) { for (size_t joystickIndex = 0; joystickIndex < this->joystickCount; joystickIndex++) { if (checker.GetJoystickPovIndexAndDirection(this->joysticks[joystickIndex], inputSource.povIndex, inputSource.direction)) { inputSource.deviceType = InputSource::JOYSTICK_POV; inputSource.deviceIndex = (int)joystickIndex; break; } } } return inputSource.deviceType != InputSource::NO_TYPE; }
void Engine::createOptionGraph(InputSource& input) { int i; char buf1[100],buf2[100]; if (initialized) { errorHandler.error("createOptionGraph(): Don't call this function twice"); return; } if (!input.open()) { errorHandler.error("createOptionGraph(): Can't open input source"); return; } // create internal enumerations int numberOfInternalEnumerations = (int)input.readValue(); for (i=0; i < numberOfInternalEnumerations; i++) { input.readString(buf1, 99); int numberOfElements = (int)input.readValue(); for (int j=0; j < numberOfElements; j++) { input.readString(buf2, 99); registerEnumElement(buf1, buf2, j); if (errorHandler.errorsOccurred) { errorHandler.error("XabslEngine::createOptionGraph(): could not register internal enumeration \"%s\"",buf1); return; } } } // create internal symbols int numberOfInternalSymbols = (int)input.readValue(); for (i=0; i < numberOfInternalSymbols; i++) { char c[2]; input.readString(c,1); switch (c[0]) { case 'd': input.readString(buf1,99); internalDecimalSymbols.append(buf1, 0); registerDecimalOutputSymbol(buf1, &(internalDecimalSymbols.getElement(internalDecimalSymbols.getSize() - 1))); if (errorHandler.errorsOccurred) { errorHandler.error("XabslEngine::createOptionGraph(): could not register internal decimal symbol \"%s\"",buf1); return; } break; case 'b': input.readString(buf1,99); internalBooleanSymbols.append(buf1, false); registerBooleanOutputSymbol(buf1, &(internalBooleanSymbols.getElement(internalBooleanSymbols.getSize() - 1))); if (errorHandler.errorsOccurred) { errorHandler.error("XabslEngine::createOptionGraph(): could not register internal boolean symbol \"%s\"",buf1); return; } break; case 'e': input.readString(buf1,99); if (!enumerations.exists(buf1)) { errorHandler.error("XabslEngine::createOptionGraph(): enumeration \"%s\" was not registered",buf1); return; } const Enumeration* enumeration = enumerations[buf1]; if (enumeration->enumElements.getSize() == 0) { errorHandler.error("XabslEngine::createOptionGraph(): no enumeration elements for \"%s\" were registered",buf1); return; } input.readString(buf2,99); internalEnumeratedSymbols.append(buf2, enumeration->enumElements[0]->v); registerEnumeratedOutputSymbol(buf2, buf1, &(internalEnumeratedSymbols.getElement(internalEnumeratedSymbols.getSize() - 1))); if (errorHandler.errorsOccurred) { errorHandler.error("XabslEngine::createOptionGraph(): could not register internal enumerated symbol \"%s\"",buf2); return; } break; } } // the total number of options in the intermediate code int numberOfOptions = (int)input.readValue(); // create empty options for (i=0; i< numberOfOptions; i++) { input.readString(buf1,99); options.append(buf1,new Option(buf1,input,errorHandler,*this,pTimeFunction,i)); if (errorHandler.errorsOccurred) { errorHandler.error("XabslEngine::createOptionGraph(): could not create option \"%s\"",options[i]->n); return; } } XABSL_DEBUG_INIT(errorHandler.message("registered %i options",numberOfOptions)); // create the options and its states for (i=0; i< numberOfOptions; i++) { XABSL_DEBUG_INIT(errorHandler.message("creating option \"%s\"",options[i]->n)); options[i]->create(input,options,basicBehaviors,*this,agentPriority,synchronizationTicks); if (errorHandler.errorsOccurred) { errorHandler.error("XabslEngine::createOptionGraph(): could not create option \"%s\"",options[i]->n); return; } } // create the agents int numberOfAgents = (int)input.readValue(); for (i=0; i< numberOfAgents; i++) { input.readString(buf1,99); input.readString(buf2,99); agents.append(buf1,new Agent(buf1,options[buf2],errorHandler, i)); } // check for loops in the option graph for (i=0;i<agents.getSize();i++) { if (Option* option = dynamic_cast<Option*>(agents[i]->getRootOption())) { Option* currentOptionPath[1000]; currentOptionPath[0] = option; // call recursively the checkForLoops function if (checkForLoops(currentOptionPath,0)) { errorHandler.error("createOptionGraph(): The created option graph contains loops"); }; } } // create array of cooperating states for (i=0;i<options.getSize();i++) for (int j=0;j<options[i]->states.getSize();j++) if (CoopState* state = dynamic_cast<CoopState*>(options[i]->states[j])) coopStates.append(state); selectedAgent = agents[0]; setRootAction(); XABSL_DEBUG_INIT(errorHandler.message("selected agent: \"%s\"",selectedAgent->n)); input.close(); initialized = true; }
void DXFReader::read(const InputSource &source) { if (!DL_Dxf().in(source.getStream(), this)) THROWS("Failed to read '" << source << "' as DXF"); }
// --------------------------------------------------------------------------- // XSAXMLScanner: XMLScanner virtual methods // --------------------------------------------------------------------------- // This method will reset the scanner data structures, and related plugged // in stuff, for a new scan session. We get the input source for the primary // XML entity, create the reader for it, and push it on the stack so that // upon successful return from here we are ready to go. void XSAXMLScanner::scanReset(const InputSource& src) { fGrammar = fSchemaGrammar; fGrammarType = Grammar::SchemaGrammarType; fRootGrammar = fSchemaGrammar; fValidator->setGrammar(fGrammar); // Reset validation fValidate = true; // And for all installed handlers, send reset events. This gives them // a chance to flush any cached data. if (fDocHandler) fDocHandler->resetDocument(); if (fEntityHandler) fEntityHandler->resetEntities(); if (fErrorReporter) fErrorReporter->resetErrors(); // Clear out the id reference list resetValidationContext(); // Reset the Root Element Name if (fRootElemName) { fMemoryManager->deallocate(fRootElemName);//delete [] fRootElemName; } fRootElemName = 0; // Reset the element stack, and give it the latest ids for the special // URIs it has to know about. fElemStack.reset ( fEmptyNamespaceId, fUnknownNamespaceId, fXMLNamespaceId, fXMLNSNamespaceId ); if (!fSchemaNamespaceId) fSchemaNamespaceId = fURIStringPool->addOrFind(SchemaSymbols::fgURI_XSI); // Reset some status flags fInException = false; fStandalone = false; fErrorCount = 0; fHasNoDTD = true; fSeeXsi = false; fDoNamespaces = true; fDoSchema = true; // Reset the validators fSchemaValidator->reset(); fSchemaValidator->setErrorReporter(fErrorReporter); fSchemaValidator->setExitOnFirstFatal(fExitOnFirstFatal); fSchemaValidator->setGrammarResolver(fGrammarResolver); // Handle the creation of the XML reader object for this input source. // This will provide us with transcoding and basic lexing services. XMLReader* newReader = fReaderMgr.createReader ( src , true , XMLReader::RefFrom_NonLiteral , XMLReader::Type_General , XMLReader::Source_External , fCalculateSrcOfs , fLowWaterMark ); if (!newReader) { if (src.getIssueFatalErrorIfNotFound()) ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId(), fMemoryManager); else ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId(), fMemoryManager); } // Push this read onto the reader manager fReaderMgr.pushReader(newReader, 0); // and reset security-related things if necessary: if(fSecurityManager != 0) { fEntityExpansionLimit = fSecurityManager->getEntityExpansionLimit(); fEntityExpansionCount = 0; } fElemCount = 0; if (fUIntPoolRowTotal >= 32) { // 8 KB tied up with validating attributes... fAttDefRegistry->removeAll(); recreateUIntPool(); } else { // note that this will implicitly reset the values of the hashtables, // though their buckets will still be tied up resetUIntPool(); } fUndeclaredAttrRegistry->removeAll(); }