示例#1
0
	//传过来的数值和百分比都是对敏捷造成的影响
	void Buff_AttackSpeed::ExcuteLogic( bool pExcute )
	{
		//攻速 = 2 - (敏捷*0.2/400)
		float tAgility = ( 2-getRole()->getAtkInterval() )*400/0.2f;			//当前敏捷值
		if ( getBF_Number() )//影响武将攻击速度数值
		{
			if ( getDBuff() == pExcute )
			{
				tAgility -= getBF_Number();
			}else{
				tAgility += getBF_Number();
			}
			getRole()->setAtkInterval(2-(tAgility*0.2f/400));
		}
		if ( getBF_Rate() )//影响武将移动速度百分比
		{
			float BeingAgility = ( 2-getRole()->getBaseData()->getAttackSpeed() )*400/0.2f;		//增减的敏捷值
			if ( getDBuff() == pExcute )
			{
				tAgility -= getBF_Rate() *0.01f* BeingAgility;
			}else{
				tAgility += getBF_Rate() *0.01f* BeingAgility;
			}
			getRole()->setAtkInterval(2-(tAgility*0.2f/400));
		}
	}
示例#2
0
void PmpComponentManager::checkWaitingServices()
{
    LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__ );
    if (PMP_ROLE_NONE == getRole())
    {
        LOG4CPLUS_INFO(mLogger, "NONE ROLE");
        return;
    }
    else if  (PMP_ROLE_MASTER == getRole())
    {
        LOG4CPLUS_INFO(mLogger, "MASTER");
        if (mSessionManager->isLocalWaitingServicesSet() &&
                mSessionManager->isRemoteWaitingServicesSet())
        {
            mEventFactory->startWaitingService(true);
        }
    }
    else
    {
        LOG4CPLUS_INFO(mLogger, "SLAVE");
        if (mSessionManager->isLocalWaitingServicesSet())
        {
            mEventFactory->startWaitingService(false);
        }
    }
}
示例#3
0
	int Buff_Blood::bloodChange()
	{
		int tHpNum = 0;
		if (getBF_Number())//血量按数值变化
		{
			tHpNum = getBF_Number();
			if (getDBuff())
			{
				getRole()->setHp(getRole()->getHp() - tHpNum);
			}else{
				getRole()->setHp(getRole()->getHp() + tHpNum);
			}
		}
		if (getBF_Rate())//影响武将血量百分比
		{
			tHpNum += getBF_Rate() * 0.01f * getRole()->getHp();
			if (getDBuff())
			{
				getRole()->setHp(getRole()->getHp() - tHpNum);			//扣血和加血统一显示一次即可
			}else{
				getRole()->setHp(getRole()->getHp() + tHpNum);
			}
		}
		return tHpNum;
	}
示例#4
0
	void Buff_MoveSpeed::ExcuteLogic( bool pExcute)
	{
		if ( getBF_Number() )//影响武将移动速度数值    
		{
			if (getDBuff() == pExcute)
			{
				getRole()->setMoveSpeed(getRole()->getMoveSpeed() + getBF_Number() );
			}else{
				float speed = getRole()->getMoveSpeed() - getBF_Number();
				if (speed <= 0.2f)
					speed = 0.2f;				//武将移动最快速度极限值处理
				getRole()->setMoveSpeed(speed);
			}
		}
		if (getBF_Rate())//影响武将移动速度百分比
		{
			float tSpeed =getRole()->getBaseData()->getMoveSpeed();					//s/格
			if (getDBuff() == pExcute)
			{
				float tNewSpeed = tSpeed/(tSpeed/getRole()->getMoveSpeed()-getBF_Rate());
				if (tNewSpeed < 0.2f)
					tNewSpeed = 0.2f;
				getRole()->setMoveSpeed(tNewSpeed);
			}else{
				float tNewSpeed = tSpeed/(tSpeed/getRole()->getMoveSpeed()+getBF_Rate());
				if (tNewSpeed < 0.2f)
					tNewSpeed = 0.2f;
				getRole()->setMoveSpeed(tNewSpeed);
			}
		}
	}
//npc攻击角色和释放技能
void FightManager::npcAttack(NPC* npc)
{
	if (npcCanAttackRole(npc))
	{
		getRole()->playHurt(npc->getNpcAttackPenalty());
	}
}
示例#6
0
/// set RESULT into set of instances of A such that they do have data roles R and S
void
ReasoningKernel :: getDataRelatedIndividuals ( TDRoleExpr* R, TDRoleExpr* S, int op, IndividualSet& Result )
{
	preprocessKB();	// ensure KB is ready to answer the query
	Result.clear();
	const TRole* r = getRole ( R, "Role expression expected in the getDataRelatedIndividuals()" );
	const TRole* s = getRole ( S, "Role expression expected in the getDataRelatedIndividuals()" );

	// prepare DT reasoners
	const DLDag& dag = getTBox()->getDag();
	const DataTypeCenter& dtc = getTBox()->getDataTypeCenter();

	DataTypeReasoner Op1(dag);
	DataTypeReasoner Op2(dag);
	dtc.initDataTypeReasoner(Op1);
	dtc.initDataTypeReasoner(Op2);

	// vector of individuals
	typedef TDLNAryExpression<TDLIndividualExpression> IndVec;
	IndVec Individuals ("individual expression","data related individuals");
	Individuals.add(getExpressionManager()->getArgList());
	for ( IndVec::iterator q = Individuals.begin(), q_end = Individuals.end(); q != q_end; ++q )
	{
		const TIndividual* ind = getIndividual ( *q, "individual name expected in getDataRelatedIndividuals()" );
		const DlCompletionTree* vR = NULL;
		const DlCompletionTree* vS = NULL;
		for ( DlCompletionTree::const_edge_iterator p = ind->node->begin(), p_end = ind->node->end(); p != p_end; ++p )
		{
			const DlCompletionTreeArc* edge = *p;
			if ( edge->isNeighbour(r) )
				vR = edge->getArcEnd();
			else if ( edge->isNeighbour(s) )
				vS = edge->getArcEnd();
			if ( vR && vS )
			{
				if ( fillDTReasoner ( Op1, vR ) )
					break;
				if ( fillDTReasoner ( Op2, vS ) )
					break;
				if ( checkDataRelation ( Op1, Op2, op ) )
					Result.push_back(ind);
				break;
			}
		}
	}
}
bool FightManager::enoughAnger()
{
	if (currentAnger >= getRole()->getSkillCost())
	{
		int skillNum = INSTANCE(UserData)->getSkillNum();
		INSTANCE(UserData)->setSkillNum(skillNum + 1);
		return true;
	}
	return false;
}
bool FightManager::npcCanAttackRole(NPC* npc)
{
	auto rR = getRole()->getHurtRect();
	auto nR = npc->getAttackRect();
	if (attackabel(nR,rR))
	{
		return true;
	}
	return false;
}
示例#9
0
文件: logger.c 项目: jkew/intheory
void log_state(state s, enum role_t r) {
  if (log_level < TRACE) return;
  int line_size = (num_nodes()) * 9 + 6;
  char line[line_size];
  draw_base_graph(line, line_size);

  int meidx = graph_index(my_id(), r);

  line[meidx] = getStateName(s.state)[2];

  printf("GRAPH: %s STATE %s %s %ld %ld %ld dead %ld\n", line, getRole(r), getStateName(s.state), s.ticket, s.slot, s.value, s.deadline);
}
示例#10
0
Move FirstPlayer::selectMove(qint64 timeout){
    (void)timeout;
    qDebug() << "FirstPlayer::selectMove current state " << currentState.toString();

    QList<Move> moves = stateMachine->getLegalMoves(getCurrentState(), getRole());

    Move move = moves[qrand() % moves.size()];
    moveSelected(move);
    qDebug() << "FirstPlayer::selectMove selected move " << move.toString();

    return move;
}
		TEST(ReplicateInstanceMessage, CorrectlySetRoleInReplicatedObject)
		{
			REGISTER_MESSAGE(ReplicateInstanceMessage);
			REGISTER_CONSTRUCTOR(MockNetworkGameObject);

			int arbitraryID = 3;
			MockNetworkGameObject networkObject;
			networkObject.setInstanceId(arbitraryID);

			serverManager->sendMessage(ReplicateInstanceMessage(&networkObject, Role_Proxy), clientAddress1);
			serverManager->sendMessage(ReplicateInstanceMessage(&networkObject, Role_Simulated), clientAddress2);

			clientManager1->update();
			clientManager2->update();

			auto replicatedObject1 = dynamic_cast<const MockNetworkGameObject *> (clientManager1->findNetworkGameObject(networkObject.getInstanceId()));
			auto replicatedObject2 = dynamic_cast<const MockNetworkGameObject *> (clientManager2->findNetworkGameObject(networkObject.getInstanceId()));

			CHECK_EQUAL(Role_Proxy, replicatedObject1->getRole());
			CHECK_EQUAL(Role_Simulated, replicatedObject2->getRole());
		}
示例#12
0
//求tactics最大长度
uint Play::length()
{
	uint l = 0;
	for (uint i=0; i<roles.size(); i++)
	{
		PlayRole &r = getRole(i);
		if (r.tactics.size() > l)
		{
			l = r.tactics.size();
		}
	}
	return l;
}
示例#13
0
	RequiredServicePort* GetRequiredServicePort(const std::string& serviceName)
	{
		auto pPort = mpComponent->getPort(serviceName);

		if (pPort->getType() != OPROS_SERVICE)
			return false;

		auto pServicePort = static_cast<ServicePort*>(pPort);

		if (pServicePort->getRole() != OPROS_SERVICE_PORT_REQUIRED)
			return nullptr;

		return static_cast<RequiredServicePort*>(pServicePort);
	}
示例#14
0
	void Buff_Dodge::ExcuteLogic( bool pExcute )
	{
		if (getBF_Number())//影响武将暴击数值
		{
			if (getDBuff() == pExcute)
			{
				getRole()->setDoge(getRole()->getDoge() - getBF_Number());
			}else{
				getRole()->setDoge(getRole()->getDoge() + getBF_Number());
			}
		}
		if ( getBF_Rate() )//影响武将暴击百分比
		{
			float tRate = getBF_Rate() * getRole()->getBaseData()->getRoleDodge();
			if (getDBuff() == pExcute)
			{
				getRole()->setDoge(getRole()->getDoge() - tRate);
			}else{
				getRole()->setDoge(getRole()->getDoge() + tRate);
			}
		}
	}
示例#15
0
	void Buff_Attack::ExcuteLogic( bool pExcute )
	{
		if (getBF_Number())		//影响武将攻击数值
		{
			if (getDBuff() == pExcute)
			{
				getRole()->setAtk(getRole()->getAtk() - getBF_Number());
			}else{
				getRole()->setAtk(getRole()->getAtk() + getBF_Number());
			}
		}
		if ( getBF_Rate() )		//影响武将攻击百分比
		{
			float tRate = getBF_Rate() * getRole()->getBaseData()->getRoleAttack();
			if (getDBuff() == pExcute)
			{
				getRole()->setAtk(getRole()->getAtk() - tRate);
			}else{
				getRole()->setAtk(getRole()->getAtk() + tRate);
			}
		}
	}
示例#16
0
	void Buff_HitRate::ExcuteLogic( bool pExcute )
	{
		if (getBF_Number())//影响武将命中数值
		{
			if (getDBuff() == pExcute)
			{
				getRole()->setHit(getRole()->getHit() - getBF_Number());
			}else{
				getRole()->setHit(getRole()->getHit() + getBF_Number());
			}
		}
		if (getBF_Rate())//影响武将命中百分比
		{
			float tRate = getBF_Rate() * getRole()->getBaseData()->getRoleHit();
			if (getDBuff() == pExcute)
			{
				getRole()->setHit(getRole()->getHit() - tRate);
			}else{
				getRole()->setHit(getRole()->getHit() + tRate);
			}
		}
	}
示例#17
0
	bool Connect(const std::string& serviceName, RequiredServicePort* pRequiredService)
	{
		auto pPort = mpComponent->getPort(serviceName);
		
		if (pPort->getType() != OPROS_SERVICE)
			return false;

		auto pServicePort = static_cast<ServicePort*>(pPort);
		
		if (pServicePort->getRole() != OPROS_SERVICE_PORT_PROVIDED)
			return false;

		if(pRequiredService->setPeer(pServicePort) != OPROS_SUCCESS)
			return false;

		return true;
	}
示例#18
0
	void Buff_Blood::ExcuteLogic(bool pExcute)
	{
		if ( !pExcute ) return;
		if (getRole()->getMonsterSpecies() == sMonsterSpecies::eWorldBoss)
			return;			//世界boss免疫buff效果
		bNotification->postNotification(B_UpdateBuffEffect,getRole());				//每次加减血时显示一次buff的特效
		if (getDBuff())
		{			
			getRole()->playBooldNum(PlayHpType::generalType, bloodChange() );
		}else{
			getRole()->playBooldNum(PlayHpType::gainType, bloodChange() );
		}
		if (getRole()->getHp()<=0)						//掉血类buff才会出现这样的情况
			getRole()->roleDie();
	}
示例#19
0
void AccessibilityUIElement::roleGetterCallback(CppVariant* result)
{
    result->set(getRole(accessibilityObject()));
}
示例#20
0
//~~ void init_implicite_members() [activity_element] ~~
bool isDirect;
role_element* r = dynamic_cast<role_element*>(getRole(&isDirect));

if (r != 0)
{
    r->add_activity(this,isDirect);

    if (isDirect)
    {
        process_element* p = dynamic_cast<process_element*>(getProcess());

        if (p != 0)
            p->addImpliciteRole(r);
    }
}

tool_element* t = dynamic_cast<tool_element*>(getTool(&isDirect));

if (t != 0)
{
    t->add_activity(this,isDirect);

    if (isDirect)
    {
        process_element* p = dynamic_cast<process_element*>(getProcess());

        if (p != 0)
            p->addImpliciteTool(t);
    }
}
示例#21
0
bool Player::isLord() const{
    return getRole() == "lord";
}
示例#22
0
TEST(SSLManager, MongoDBRolesParser) {
    /*
    openssl asn1parse -genconf mongodbroles.cnf -out foo.der

    -------- mongodbroles.cnf --------
    asn1 = SET:MongoDBAuthorizationGrant

    [MongoDBAuthorizationGrant]
    grant1 = SEQUENCE:MongoDBRole

    [MongoDBRole]
    role  = UTF8:role_name
    database = UTF8:Third field
    */
    // Positive: Simple parsing test
    {
        unsigned char derData[] = {0x31, 0x1a, 0x30, 0x18, 0x0c, 0x09, 0x72, 0x6f, 0x6c, 0x65,
                                   0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x0c, 0x0b, 0x54, 0x68, 0x69,
                                   0x72, 0x64, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64};
        auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData),
                                                    std::extent<decltype(derData)>::value));
        ASSERT_OK(swPeer.getStatus());
        auto item = *(swPeer.getValue().begin());
        ASSERT_EQ(item.getRole(), "role_name");
        ASSERT_EQ(item.getDB(), "Third field");
    }

    // Positive: Very long role_name, and long form lengths
    {
        unsigned char derData[] = {
            0x31, 0x82, 0x01, 0x3e, 0x30, 0x82, 0x01, 0x3a, 0x0c, 0x82, 0x01, 0x29, 0x72, 0x6f,
            0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61,
            0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c,
            0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d,
            0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65,
            0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65,
            0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f,
            0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72,
            0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e,
            0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f,
            0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61,
            0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c,
            0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d,
            0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65,
            0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65,
            0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f,
            0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72,
            0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e,
            0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f,
            0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61,
            0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c,
            0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d,
            0x65, 0x0c, 0x0b, 0x54, 0x68, 0x69, 0x72, 0x64, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64};
        auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData),
                                                    std::extent<decltype(derData)>::value));
        ASSERT_OK(swPeer.getStatus());

        auto item = *(swPeer.getValue().begin());
        ASSERT_EQ(item.getRole(),
                  "role_namerole_namerole_namerole_namerole_namerole_namerole_namerole_namerole_"
                  "namerole_namerole_namerole_namerole_namerole_namerole_namerole_namerole_"
                  "namerole_namerole_namerole_namerole_namerole_namerole_namerole_namerole_"
                  "namerole_namerole_namerole_namerole_namerole_namerole_namerole_namerole_name");
        ASSERT_EQ(item.getDB(), "Third field");
    }

    // Negative: Encode MAX_INT64 into a length
    {
        unsigned char derData[] = {0x31, 0x88, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
                                   0xff, 0x3e, 0x18, 0x0c, 0x09, 0x72, 0x6f, 0x6c, 0x65, 0x5f,
                                   0x6e, 0x61, 0x6d, 0x65, 0x0c, 0x0b, 0x54, 0x68, 0x69, 0x72,
                                   0x64, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64};

        auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData),
                                                    std::extent<decltype(derData)>::value));
        ASSERT_NOT_OK(swPeer.getStatus());
    }

    // Negative: Runt, only a tag
    {
        unsigned char derData[] = {0x31};
        auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData),
                                                    std::extent<decltype(derData)>::value));
        ASSERT_NOT_OK(swPeer.getStatus());
    }

    // Negative: Runt, only a tag and short length
    {
        unsigned char derData[] = {0x31, 0x0b};
        auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData),
                                                    std::extent<decltype(derData)>::value));
        ASSERT_NOT_OK(swPeer.getStatus());
    }

    // Negative: Runt, only a tag and long length with wrong missing length
    {
        unsigned char derData[] = {
            0x31, 0x88, 0xff, 0xff,
        };
        auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData),
                                                    std::extent<decltype(derData)>::value));
        ASSERT_NOT_OK(swPeer.getStatus());
    }

    // Negative: Runt, only a tag and long length
    {
        unsigned char derData[] = {
            0x31, 0x82, 0xff, 0xff,
        };
        auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData),
                                                    std::extent<decltype(derData)>::value));
        ASSERT_NOT_OK(swPeer.getStatus());
    }

    // Negative: Single UTF8 String
    {
        unsigned char derData[] = {
            0x0c, 0x0b, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64};
        auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData),
                                                    std::extent<decltype(derData)>::value));
        ASSERT_NOT_OK(swPeer.getStatus());
    }

    // Negative: Unknown type - IAString
    {
        unsigned char derData[] = {
            0x16, 0x0b, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64};
        auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData),
                                                    std::extent<decltype(derData)>::value));
        ASSERT_NOT_OK(swPeer.getStatus());
    }

    // Positive: two roles
    {
        unsigned char derData[] = {0x31, 0x2b, 0x30, 0x0f, 0x0c, 0x06, 0x62, 0x61, 0x63,
                                   0x6b, 0x75, 0x70, 0x0c, 0x05, 0x61, 0x64, 0x6d, 0x69,
                                   0x6e, 0x30, 0x18, 0x0c, 0x0f, 0x72, 0x65, 0x61, 0x64,
                                   0x41, 0x6e, 0x79, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61,
                                   0x73, 0x65, 0x0c, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e};
        auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData),
                                                    std::extent<decltype(derData)>::value));
        ASSERT_OK(swPeer.getStatus());

        auto roles = getSortedRoles(swPeer.getValue());
        ASSERT_EQ(roles[0].getRole(), "backup");
        ASSERT_EQ(roles[0].getDB(), "admin");
        ASSERT_EQ(roles[1].getRole(), "readAnyDatabase");
        ASSERT_EQ(roles[1].getDB(), "admin");
    }
}
// checks if the IO profile is compatible with specified parameters.
// Sampling rate, format and channel mask must be specified in order to
// get a valid a match
bool IOProfile::isCompatibleProfile(audio_devices_t device,
                                    const String8& address,
                                    uint32_t samplingRate,
                                    uint32_t *updatedSamplingRate,
                                    audio_format_t format,
                                    audio_format_t *updatedFormat,
                                    audio_channel_mask_t channelMask,
                                    audio_channel_mask_t *updatedChannelMask,
                                    uint32_t flags) const
{
    const bool isPlaybackThread =
            getType() == AUDIO_PORT_TYPE_MIX && getRole() == AUDIO_PORT_ROLE_SOURCE;
    const bool isRecordThread =
            getType() == AUDIO_PORT_TYPE_MIX && getRole() == AUDIO_PORT_ROLE_SINK;
    ALOG_ASSERT(isPlaybackThread != isRecordThread);


    if (device != AUDIO_DEVICE_NONE) {
        // just check types if multiple devices are selected
        if (popcount(device & ~AUDIO_DEVICE_BIT_IN) > 1) {
            if ((mSupportedDevices.types() & device) != device) {
                return false;
            }
        } else if (mSupportedDevices.getDevice(device, address) == 0) {
            return false;
        }
    }

    if (!audio_is_valid_format(format) ||
            (isPlaybackThread && (samplingRate == 0 || !audio_is_output_channel(channelMask))) ||
            (isRecordThread && (!audio_is_input_channel(channelMask)))) {
         return false;
    }

    audio_format_t myUpdatedFormat = format;
    audio_channel_mask_t myUpdatedChannelMask = channelMask;
    uint32_t myUpdatedSamplingRate = samplingRate;
    if (isRecordThread)
    {
        if (checkCompatibleAudioProfile(
                myUpdatedSamplingRate, myUpdatedChannelMask, myUpdatedFormat) != NO_ERROR) {
            return false;
        }
    } else {
        if (checkExactAudioProfile(samplingRate, channelMask, format) != NO_ERROR) {
            return false;
        }
    }

    if (isPlaybackThread && (getFlags() & flags) != flags) {
        return false;
    }
    // The only input flag that is allowed to be different is the fast flag.
    // An existing fast stream is compatible with a normal track request.
    // An existing normal stream is compatible with a fast track request,
    // but the fast request will be denied by AudioFlinger and converted to normal track.
    if (isRecordThread && ((getFlags() ^ flags) &
            ~AUDIO_INPUT_FLAG_FAST)) {
        return false;
    }

    if (updatedSamplingRate != NULL) {
        *updatedSamplingRate = myUpdatedSamplingRate;
    }
    if (updatedFormat != NULL) {
        *updatedFormat = myUpdatedFormat;
    }
    if (updatedChannelMask != NULL) {
        *updatedChannelMask = myUpdatedChannelMask;
    }
    return true;
}
示例#24
0
文件: Bind.cpp 项目: jgrande/ginga
std::string Bind::toString() {
	return (getRole()->getLabel() + '/' + getNode()->getId() + '/' + getInterfacePoint()->getId());
}
示例#25
0
void
DLVertex :: Print ( std::ostream& o ) const
{
	o << "[d(" << getDepth(true) << "/" << getDepth(false)
	  << "),s(" << getSize(true) << "/" << getSize(false)
	  << "),b(" << getBranch(true) << "/" << getBranch(false)
	  << "),g(" << getGener(true) << "/" << getGener(false)
	  << "),f(" << getFreq(true) << "/" << getFreq(false) << ")] ";
	o << getTagName();

	switch ( Type() )
	{
	case dtAnd:		// nothing to do (except for printing operands)
	case dtSplitConcept:
		break;

	case dtTop:		// nothing to do
	case dtNN:
		return;

	case dtDataExpr:
		o << ' ' << *static_cast<const TDataEntry*>(getConcept())->getFacet();
		return;

	case dtDataValue:	// named entry -- just like concept names
	case dtDataType:

	case dtPConcept:
	case dtNConcept:
	case dtPSingleton:
	case dtNSingleton:
		o << '(' << getConcept()->getName() << ") " << (isNNameTag(Type()) ? "=" : "[=") << ' ' << getC();
		return;

	case dtLE:
		o << ' ' << getNumberLE() << ' ' << getRole()->getName() << ' ' << getC();
		return;

	case dtForall:
		o << ' ' << getRole()->getName() << '{' << getState() << '}' << ' ' << getC();
		return;

	case dtIrr:
		o << ' ' << getRole()->getName();
		return;

	case dtProj:
		o << ' ' << getRole()->getName() << ", " << getC() << " => " << getProjRole()->getName();
		return;

	case dtChoose:
		o << ' ' << getC();
		return;

	default:
		std::cerr << "Error printing vertex of type " << getTagName() << "(" << Type() << ")";
		fpp_unreachable();
	}

	// print operands of the concept constructor
	for ( const_iterator q = begin(); q != end(); ++q )
		o << ' ' << *q;
}
示例#26
0
bool MiscPlugin::parseMessage(gloox::Stanza* s, const QStringList& flags)
{
    Q_UNUSED(flags);

    MessageParser parser(s, getMyNick(s));
    parser.nextToken();
    QString cmd=parser.nextToken().toUpper();
    qDebug() << "Got CMD: " << cmd << "; length=" << cmd.length();

    if (cmd=="TEST")
    {
        reply(s, "passed");
        return true;
    }
    if (cmd=="DATE")
    {
        reply(s, QDate::currentDate().toString(Qt::LocaleDate));
        return true;
    }
    if (cmd=="TIME")
    {
        reply(s, QTime::currentTime().toString(Qt::LocaleDate));
        return true;
    }
    if (!sayJidDisabled_ && cmd=="SAYJID")
    {
        if (getRole(s)<ROLE_ADMIN)
        {
            reply(s,"You should be moderator to do this");
            return true;
        }
        QString dst=parser.nextToken();
        if (dst.isEmpty())
        {
            reply(s,"No dest. JID specified");
            return true;
        }
        QString body=parser.joinBody();
        gloox::Stanza* out=gloox::Stanza::createMessageStanza(gloox::JID(dst.toStdString()),body.toStdString());
        bot()->client()->send(out);
        return true;
    }
    if (cmd=="SAY")
    {
        if (getRole(s)<ROLE_MODERATOR)
        {
            reply(s,"You should be moderator to do this");
            return true;
        }
        QString body=parser.joinBody();
        reply(s,body,false, false);
        return true;
    }
    if (cmd=="BC")
    {
        BcRequest *req = new BcRequest(this, new gloox::Stanza(s), parser);
        bot()->asyncRequests()->append(req);
        req->exec();
        return true;
    }
    if (cmd=="DECIDE")
    {
        QStringList choices = parser.getTokens();
        if (choices.count() <= 3)
        {
            reply(s, "You have no choice.");
            return true;
        }
        srand( time(NULL) );
        int r = random() % (choices.count()-2); // strip misc and decide tokens
        reply(s, choices[r+2]);
        return true;
    }
    return false;
}
示例#27
0
float FightManager::getAnger()
{
	return float(currentAnger) / float(getRole()->getSkillCost());
}