/* input block, this is per port */ void input_block(int port_number) { ETHERNET_FRAME buf; //an abstract type to store a received Ethernet frame int port_mask; int priority; int address; while(1) { if( receive(&buf,port_number) == TRUE ) { // ask Routing Table Unit rtu(&buf, &port_mask, &priority); //acquire address of the first page address = mmu(); //store in memory fbm_memory[address].buf = buf; // forward a pointer to the frame to all the appropriate ports // waits until all the appropriate ports read the data arbiter(port_mask, priority, address); } } }
void checkPropertyUpdates() { // GIVEN QScopedPointer<Qt3DRender::QFrameGraph> frameGraph(new Qt3DRender::QFrameGraph()); TestArbiter arbiter(frameGraph.data()); // WHEN MyFrameGraphNode *activeFrameGraph1 = new MyFrameGraphNode(); frameGraph->setActiveFrameGraph(activeFrameGraph1); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 1); Qt3DCore::QScenePropertyChangePtr change = arbiter.events.first().staticCast<Qt3DCore::QScenePropertyChange>(); QCOMPARE(change->propertyName(), "activeFrameGraph"); QCOMPARE(change->subjectId(), frameGraph->id()); QCOMPARE(change->value().value<Qt3DCore::QNodeId>(), activeFrameGraph1->id()); QCOMPARE(change->type(), Qt3DCore::NodeUpdated); arbiter.events.clear(); // WHEN frameGraph->setActiveFrameGraph(activeFrameGraph1); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 0); // WHEN MyFrameGraphNode *activeFrameGraph2 = new MyFrameGraphNode(); frameGraph->setActiveFrameGraph(activeFrameGraph2); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 1); change = arbiter.events.first().staticCast<Qt3DCore::QScenePropertyChange>(); QCOMPARE(change->propertyName(), "activeFrameGraph"); QCOMPARE(change->subjectId(), frameGraph->id()); QCOMPARE(change->value().value<Qt3DCore::QNodeId>(), activeFrameGraph2->id()); QCOMPARE(change->type(), Qt3DCore::NodeUpdated); arbiter.events.clear(); // WHEN frameGraph->setActiveFrameGraph(Q_NULLPTR); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 1); change = arbiter.events.first().staticCast<Qt3DCore::QScenePropertyChange>(); QCOMPARE(change->propertyName(), "activeFrameGraph"); QCOMPARE(change->subjectId(), frameGraph->id()); QCOMPARE(change->value().value<Qt3DCore::QNodeId>(), Qt3DCore::QNodeId()); QCOMPARE(change->type(), Qt3DCore::NodeUpdated); }
DWORD CActionMover::_ProcessMsgDmg( DWORD dwMsg, CMover* pAttacker, DWORD dwAtkFlags, int nParam, BOOL bTarget, int nReflect ) { #if defined(__WORLDSERVER) CAttackArbiter arbiter( dwMsg, pAttacker, GetMover(), dwAtkFlags, nParam, bTarget, nReflect ); return arbiter.OnDamageMsgW(); #elif defined(__CLIENT) return OnDamageMsgC( dwMsg, pAttacker, dwAtkFlags, nParam ); #else return 0; #endif }
void checkPropertyUpdates() { // GIVEN QScopedPointer<Qt3DRender::QBoundingVolumeDebug> bvD(new Qt3DRender::QBoundingVolumeDebug()); TestArbiter arbiter(bvD.data()); // WHEN bvD->setRecursive(true); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 1); Qt3DCore::QNodePropertyChangePtr change = arbiter.events.last().staticCast<Qt3DCore::QNodePropertyChange>(); QCOMPARE(change->propertyName(), "recursive"); QCOMPARE(change->value().toBool(), true); QCOMPARE(change->type(), Qt3DCore::NodeUpdated); arbiter.events.clear(); // WHEN bvD->setRecursive(true); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 0); // WHEN bvD->setRecursive(false); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 1); change = arbiter.events.last().staticCast<Qt3DCore::QNodePropertyChange>(); QCOMPARE(change->propertyName(), "recursive"); QCOMPARE(change->value().toBool(), false); QCOMPARE(change->type(), Qt3DCore::NodeUpdated); arbiter.events.clear(); }
void ActionPattern::xmlInit(const QDomNode& _node, const ActionPatternMap& _apMap) { ArbiterRepository * ar = ArbiterRepository::instance(); BehaviourRepository * br = BehaviourRepository::instance(); // first pass // retrieve arbiter // we need it to register the behaviours there QDomNode n = _node.firstChild(); while( !n.isNull() ) { QDomElement e = n.toElement(); // try to convert the node to an element. if( !e.isNull() ) { // the node was really an element. QDomAttr attribute = e.attributeNode("name"); // retrieve arbiter if (e.tagName()=="arbiter") { if (arbiter_ == NULL) { if (!attribute.isNull() && !attribute.value().isEmpty()) { string name(attribute.value()); Arbiter* a; if ((a = ar->getArbiter(name)) != 0) { ArbiterParameters * params = a->getParametersInstance(); arbiter(a, params); } else { std::string error("Arbiter not registered: " + name); throw BehaviourEngine::EMalformedPolicy(CORBA::string_dup(error.c_str())); } } else { throw BehaviourEngine::EMalformedPolicy(CORBA::string_dup("Arbiter without name.")); } } else { throw BehaviourEngine::EMalformedPolicy(CORBA::string_dup("Multiple arbiters specified.")); } } // syntax checking else if (e.tagName() != "behaviour" && e.tagName() != "transition") { std::string error("Unknown tag name: " + string(e.tagName())); throw BehaviourEngine::EMalformedPolicy(CORBA::string_dup(error.c_str())); } } n = n.nextSibling(); } // There has to be exact one arbiter if (arbiter_ == NULL) { std::string error("ActionPattern without an arbiter: " + actionPatternName_); throw BehaviourEngine::EMalformedPolicy(CORBA::string_dup(error.c_str())); } // second pass // retrieve behaviours and transitions n = _node.firstChild(); while( !n.isNull() ) { QDomElement e = n.toElement(); // try to convert the node to an element. if( !e.isNull() ) { // the node was really an element. QDomAttr attribute = e.attributeNode("name"); // retrieve behaviours if (e.tagName() == "behaviour") { if (!attribute.isNull() && !attribute.value().isEmpty()) { string name(attribute.value()); Behaviour * behaviour; BehaviourParameters * parameters; if ((behaviour = br->getBehaviour(name)) != 0) { parameters = behaviour->getParametersInstance(); KeyValueList params; params <<= n; *parameters <<= params; addBehaviour(behaviour, parameters); } else { std::string error("Behaviour not registered: " + name); throw BehaviourEngine::EMalformedPolicy(CORBA::string_dup(error.c_str())); } } else { throw BehaviourEngine::EMalformedPolicy(CORBA::string_dup("Behaviour without name.")); } } // retrieve transitions else if (e.tagName() == "transition") { QDomAttr attrMessage = e.attributeNode("message"); string message; if (!attrMessage.isNull() && !attrMessage.value().isEmpty()) { message = string(attrMessage.value()); } else { throw BehaviourEngine::EMalformedPolicy(CORBA::string_dup("Transition without message.")); } QDomAttr attrPattern = e.attributeNode("target"); if (!attrPattern.isNull() && !attrPattern.value().isEmpty()) { string patternname = string(attrPattern.value()); ActionPatternMap::const_iterator iter = _apMap.find(patternname); if (iter != _apMap.end()) addTransition(message, iter->second); else { std::string error("ActionPattern for transition not registered: " + message + " --> " + patternname + "."); throw BehaviourEngine::EMalformedPolicy(CORBA::string_dup(error.c_str())); } } else throw BehaviourEngine::EMalformedPolicy(CORBA::string_dup("Transition without target.")); } } n = n.nextSibling(); } }
void checkPropertyUpdates() { // GIVEN QScopedPointer<Qt3DRender::QTechniqueFilter> techniqueFilter(new Qt3DRender::QTechniqueFilter()); TestArbiter arbiter(techniqueFilter.data()); // WHEN Qt3DRender::QParameter *param1 = new Qt3DRender::QParameter(); techniqueFilter->addParameter(param1); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 1); Qt3DCore::QScenePropertyChangePtr change = arbiter.events.first().staticCast<Qt3DCore::QScenePropertyChange>(); QCOMPARE(change->propertyName(), "parameter"); QCOMPARE(change->subjectId(),techniqueFilter->id()); QCOMPARE(change->value().value<Qt3DCore::QNodeId>(), param1->id()); QCOMPARE(change->type(), Qt3DCore::NodeAdded); arbiter.events.clear(); // WHEN techniqueFilter->addParameter(param1); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 0); // WHEN techniqueFilter->removeParameter(param1); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 1); change = arbiter.events.first().staticCast<Qt3DCore::QScenePropertyChange>(); QCOMPARE(change->propertyName(), "parameter"); QCOMPARE(change->subjectId(), techniqueFilter->id()); QCOMPARE(change->value().value<Qt3DCore::QNodeId>(), param1->id()); QCOMPARE(change->type(), Qt3DCore::NodeRemoved); arbiter.events.clear(); // WHEN Qt3DRender::QAnnotation *annotation1 = new Qt3DRender::QAnnotation(); techniqueFilter->addRequirement(annotation1); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 1); change = arbiter.events.first().staticCast<Qt3DCore::QScenePropertyChange>(); QCOMPARE(change->propertyName(), "require"); QCOMPARE(change->subjectId(),techniqueFilter->id()); QCOMPARE(change->value().value<Qt3DCore::QNodeId>(), annotation1->id()); QCOMPARE(change->type(), Qt3DCore::NodeAdded); arbiter.events.clear(); // WHEN techniqueFilter->addRequirement(annotation1); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 0); // WHEN techniqueFilter->removeRequirement(annotation1); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 1); change = arbiter.events.first().staticCast<Qt3DCore::QScenePropertyChange>(); QCOMPARE(change->propertyName(), "require"); QCOMPARE(change->subjectId(), techniqueFilter->id()); QCOMPARE(change->value().value<Qt3DCore::QNodeId>(), annotation1->id()); QCOMPARE(change->type(), Qt3DCore::NodeRemoved); arbiter.events.clear(); }