Пример #1
0
bool CRusFormatCaller::format_for_modif_adj_groups (CGroup& G)
{
    if (get_maximal_group_no(G.m_iFirstWord) != -1) return  false;    
    int j =  G.m_iFirstWord;

    if( FindInList((const char*)g_strAdjModif, g_AdjModifCount, Wj.get_lemma()) == -1)
        return false;


    if( j+1 >= sent.size() )
        return false;
    const CGroup& H = get_maximal_group(j+1);
    if( !is_morph_adj(sent[H.m_MainWordNo]) )
            return false;

    if( !GetGramTab()->GleicheGenderNumberCase(sent[H.m_MainWordNo].m_type_gram_code, sent[H.m_MainWordNo].m_gramcodes, Wj.m_gramcodes ) )
        return false;

    G.m_iLastWord = H.m_iLastWord;
    G.m_GroupType = MODIF_ADJ;
    G.SetGrammems (H.GetGrammems() & sent[j].GetGrammems());
    G.m_MainGroup =  H;
    change_words_in_group_grammems(G, G.GetGrammems(), (rAllNumbers | rAllCases));  
    create_syn_rel(G, H.m_MainWordNo, j , MODIF_ADJ);
    return true;
}
bool CWindowManager::CoreHandleKey(chtype key)
{
    if (CGroup::CoreHandleKey(key))
        return true;
    
    CWidget *focwidget = GetFocusedWidget();
    if (focwidget)
    {
        CGroup *focgroup = GetGroupWidget(focwidget);
        if (focgroup)
        {
            if (IsTAB(key))
            {
                if (!focgroup->SetNextFocWidget(true))
                    focgroup->SetNextFocWidget(false);
                TUI.UpdateButtonBar();
                return true;
            }
            else if (key == CTRL('p'))
            {
                if (!focgroup->SetPrevFocWidget(true))
                    focgroup->SetPrevFocWidget(false);
                TUI.UpdateButtonBar();
                return true;
            }
        }
    }
    
    return false;
}
Пример #3
0
//---------------------------------------------------------------------------
//	@function:
//		CExpressionHandle::CopyCostCtxtProps
//
//	@doc:
//		Cache plan properties of cost context and its children on the handle
//
//---------------------------------------------------------------------------
void
CExpressionHandle::CopyCostCtxtProps()
{
	GPOS_ASSERT(NULL != m_pcc);
	GPOS_ASSERT(NULL == m_pdrgpdp);
	GPOS_ASSERT(NULL == m_pdp);

	// add-ref context properties
	CDrvdProp *pdp = m_pcc->Pdpplan();
	pdp->AddRef();
	m_pdp = pdp;

	// add-ref child group expressions' properties
	const ULONG ulArity = UlArity();
	m_pdrgpdp = GPOS_NEW(m_pmp) DrgPdp(m_pmp, ulArity);
	for (ULONG ul = 0; ul < ulArity; ul++)
	{
		CGroup *pgroupChild = (*m_pgexpr)[ul];
		if (!pgroupChild->FScalar())
		{
			COptimizationContext *pocChild = (*m_pcc->Pdrgpoc())[ul];
			GPOS_ASSERT(NULL != pocChild);

			CCostContext *pccChild = pocChild->PccBest();
			GPOS_ASSERT(NULL != pccChild);

			pdp = pccChild->Pdpplan();
			pdp->AddRef();
			m_pdrgpdp->Append(pdp);
		}
	}
}
Пример #4
0
CGroup* CMilitary::requestGroup(MilitaryGroupBehaviour type) {
	CGroup *group = ReusableObjectFactory<CGroup>::Instance();
	group->ai = ai;
	group->reset();
	group->reg(*this);
	
	LOG_II("CMilitary::requestGroup " << (*group))

	switch(type) {
		case SCOUT:
			activeScoutGroups[group->key] = group;
			break;
		case BOMBER:
			activeBomberGroups[group->key] = group;
			break;
		case ENGAGE:
			activeAttackGroups[group->key] = group;
			break;
		case AIRFIGHTER:
			activeAirFighterGroups[group->key] = group;
			break;
		default:
			LOG_EE("CMilitary::requestGroup invalid group behaviour: " << type)
	}

	return group;
}
Пример #5
0
		CGroup* CGroup::FindGroup(const std::string& szName
			, const int& depth) const
		{
			//TODO once we get a depth first traversal func we should use that here

			int size = this->m_vChildren.size();
			for (int i = 0; i < size; ++i)
			{
				if (this->m_vChildren[i]->GetName() == szName && this->m_vChildren[i]->IsGroup())
				{
					return dynamic_cast<CGroup*>(this->m_vChildren[i]);
				}
			}

			//If we get here then search our children's children for the object
			for (int i = 0; i < size; ++i)
			{
				if (this->m_vChildren[i]->IsGroup())
				{
					CGroup* pGroup = static_cast<CGroup*>(this->m_vChildren[i]);
					CGroup* ret = pGroup->FindGroup(szName);
					if (ret)
						return ret;
				}
			}
			return null;
		}
Пример #6
0
size_t GetRestrictedPhysicalMemoryLimit()
{
    CGroup cgroup;
    size_t physical_memory_limit;
 
    if (!cgroup.GetPhysicalMemoryLimit(&physical_memory_limit))
         physical_memory_limit = SIZE_T_MAX;

    struct rlimit curr_rlimit;
    size_t rlimit_soft_limit = RLIM_INFINITY;
    if (getrlimit(RLIMIT_AS, &curr_rlimit) == 0)
    {
        rlimit_soft_limit = curr_rlimit.rlim_cur;
    }
    physical_memory_limit = (physical_memory_limit < rlimit_soft_limit) ? 
                            physical_memory_limit : rlimit_soft_limit;

    // Ensure that limit is not greater than real memory size
    long pages = sysconf(_SC_PHYS_PAGES);
    if (pages != -1) 
    {
        long pageSize = sysconf(_SC_PAGE_SIZE);
        if (pageSize != -1)
        {
            physical_memory_limit = (physical_memory_limit < (size_t)pages * pageSize)?
                                    physical_memory_limit : (size_t)pages * pageSize;
        }
    }

    return physical_memory_limit;
}
Пример #7
0
void getName_c_s(CStateInstance* entity, CScriptStack& stack)
{
	IScriptContext* ctx = (IScriptContext*)stack.top();
	CGroup* group = dynamic_cast<CGroup*>(ctx);
	if (group)
		stack.top() = group->getName();
	else
		stack.top() = string();
}
Пример #8
0
bool GetCpuLimit(uint32_t* val)
{
    CGroup cgroup;

    if (val == nullptr)
        return false;

    return cgroup.GetCpuLimit(val);
}
Пример #9
0
void CEconomy::addUnitOnFinished(CUnit &unit) {
	LOG_II("CEconomy::addUnitOnFinished " << unit)

	unitCategory c = unit.type->cats;

	if ((c&BUILDER).any() || ((c&ASSISTER).any() && (c&MOBILE).any())) {
		CGroup *group = requestGroup();
		group->addUnit(unit);
	}
}
Пример #10
0
CGroup* CEconomy::requestGroup() {
	CGroup *group = ReusableObjectFactory<CGroup>::Instance();
	group->ai = ai;
	group->reset();
	group->reg(*this);

	activeGroups[group->key] = group;
	
	return group;
}
Пример #11
0
BOOL
PALAPI
PAL_GetCpuLimit(UINT* val)
{
    CGroup cgroup;

    if (val == nullptr)
        return FALSE;

    return cgroup.GetCpuLimit(val);
}
Пример #12
0
void CGroupHandler::GroupCommand(int num, const std::string& cmd)
{
	GML_RECMUTEX_LOCK(grpsel); // GroupCommand

	CGroup* group = groups[num];

	if ((cmd == "set") || (cmd == "add")) {
		if (cmd == "set") {
			group->ClearUnits();
		}
		const CUnitSet& selUnits = selectedUnits.selectedUnits;
		CUnitSet::const_iterator ui;
		for(ui = selUnits.begin(); ui != selUnits.end(); ++ui) {
			(*ui)->SetGroup(group);
		}
	}
	else if (cmd == "selectadd")  {
		// do not select the group, just add its members to the current selection
		CUnitSet::const_iterator ui;
		for (ui = group->units.begin(); ui != group->units.end(); ++ui) {
			selectedUnits.AddUnit(*ui);
		}
		return;
	}
	else if (cmd == "selectclear")  {
		// do not select the group, just remove its members from the current selection
		CUnitSet::const_iterator ui;
		for (ui = group->units.begin(); ui != group->units.end(); ++ui) {
			selectedUnits.RemoveUnit(*ui);
		}
		return;
	}
	else if (cmd == "selecttoggle")  {
		// do not select the group, just toggle its members with the current selection
		const CUnitSet& selUnits = selectedUnits.selectedUnits;
		CUnitSet::const_iterator ui;
		for (ui = group->units.begin(); ui != group->units.end(); ++ui) {
			if (selUnits.find(*ui) == selUnits.end()) {
				selectedUnits.AddUnit(*ui);
			} else {
				selectedUnits.RemoveUnit(*ui);
			}
		}
		return;
	}

	if ((selectedUnits.selectedGroup == num) && !group->units.empty()) {
		const float3 groupCenter = group->CalculateCenter();
		camHandler->GetCurrentController().SetPos(groupCenter);
	}

	selectedUnits.SelectGroup(num);
}
Пример #13
0
void CEconomy::remove(ARegistrar &object) {
	CGroup *group = dynamic_cast<CGroup*>(&object);
	LOG_II("CEconomy::remove " << (*group))

	activeGroups.erase(group->key);
	takenMexes.erase(group->key);
	takenGeo.erase(group->key);

	group->unreg(*this);
	
	ReusableObjectFactory<CGroup>::Release(group);
}
Пример #14
0
void AttackTask::onUpdate() {
	CGroup *group = firstGroup();

	if (group->isMicroing() && group->isIdle()) {
		targetAlt = -1; // for sure
		group->micro(false);
	}

	if (isMoving) {
		/* Keep tracking the target */
		pos = ai->cbc->GetUnitPos(target);

		float3 gpos = group->pos();
		float dist = gpos.distance2D(pos);
		float range = group->getRange();

		/* See if we can attack our target already */
		if (dist <= range) {
			bool canAttack = true;

			/*
			// for ground units prevent shooting across hill...
			if ((group->cats&AIR).none()) {
				// FIXME: improve
				dist = ai->pathfinder->getPathLength(*group, pos);
				canAttack = (dist <= range * 1.1f);
			}
			*/

			if (canAttack) {
				if ((group->cats&BUILDER).any())
					group->reclaim(target);
				else
					group->attack(target);
				isMoving = false;
				ai->pathfinder->remove(*group);
				group->micro(true);
			}
		}
	}

	/* See if we can attack a target we found on our path */
	if (!(group->isMicroing() || urgent())) {
		if ((group->cats&BUILDER).any())
			resourceScan(); // builders should not be too aggressive
		else
			enemyScan(targetAlt);
	}
}
Пример #15
0
bool CGerFormatCaller :: format_for_geo_names (CGroup& G)
{
	size_t j =  get_main_word(G.m_iFirstWord);
	if (!CanBeCityType(Wj))
		return false;
	size_t i = j;

	if( ++i >= sent.size() )
		return false;

	int main_word = get_main_word(i);
	if (main_word == -1) return false;

	if	(		!sent[main_word].HasFlag(fl_morph_predicted)
			&&	!sent[main_word].has_grammem(gStd)	
		)
		return false;

	G.m_iLastWord = get_maximal_group(i).m_iLastWord;
	G.m_GroupType = gGEOGR;
	G.SetGrammems(  get_maximal_group(j).GetGrammems() );
	G.m_MainGroup =  get_maximal_group(j);
	create_syn_rel(G, j, main_word, gGEOGR);
	return true;

};
Пример #16
0
// Kanzler Gerhard Schröder
// Bundeskanzler Alexey Sokirko
// A-Techniker Gerhard Schroder
bool CGerFormatCaller :: format_for_rank_fam (CGroup& G)
{
    int i =  get_main_word(G.m_iFirstWord);
    if (!Wi.m_lemma) return false;
    if ( !Wi.HasFlag(fl_ranknoun) ) return false;

    size_t j = 0;
    const CGroup& main_gr = get_maximal_group(G.m_iFirstWord);
    j = main_gr.m_iLastWord+1;

    if ( j == sent.size() ) return false;

    const CGroup& next_gr =  get_maximal_group(j);

    if (	next_gr.m_GroupType!= gFAMILIE_GROUP
            &&	next_gr.m_GroupType!= gSPNAME
            &&	next_gr.m_GroupType!= gPNAME
       )	  return false;

    G.m_iLastWord = next_gr.m_iLastWord;
    G.SetGrammems(  Wi.GetGrammems() );
    G.m_MainGroup = main_gr;
    G.m_GroupType = gBERUF_NP;
    create_syn_rel(G,i,j,gBERUF_NP);

    return true;
};
Пример #17
0
bool CGroup::CanFocusChilds(CWidget *w)
{
    if (!IsGroupWidget(w))
        return false;
    
    CGroup *group = GetGroupWidget(w);
    const TChildList &childs = group->GetChildList();
    
    for (TChildList::const_iterator it=childs.begin(); it!=childs.end(); it++)
    {
        if ((*it)->Enabled() && ((*it)->CanFocus() || group->CanFocusChilds(*it)))
            return true;
    }
    
    return false;
}
Пример #18
0
// Правила для БОЛЕЕ или МЕНЕЕ + прил или кр.прил
bool CRusFormatCaller::format_for_anat_compar(CGroup& G)
{
	//более  извращенная  любительница
	size_t i = G.m_iFirstWord;
	const CGroup& MaxGrp = get_maximal_group(i);
	if (MaxGrp.m_iFirstWord != MaxGrp.m_iLastWord) return false;

    if (   !Wi.is_word_upper("БОЛЕЕ") 
		&& !Wi.is_word_upper("МЕНЕЕ") 
	   ) return false;
	size_t j = i + 1;
	if (j >= sent.size()) return false;
	if (get_maximal_group_size(j) != 1) return false;
	if (is_morph_adj(Wj) || is_morph_participle (Wj))
	{
		G.m_GroupType = ANAT_COMPAR;
		G.m_iLastWord = j;
		G.m_MainGroup.m_iFirstWord = j;
		G.m_MainGroup.m_iLastWord = j;
		G.SetGrammems( Wj.GetGrammems() );
		create_syn_rel(G, j, i, ANAT_COMPAR);
		return true;		
	}

	return false;		
};
Пример #19
0
bool CRusFormatCaller :: format_for_rank_surname (CGroup& G)
{
    const CGroup& main_gr = get_maximal_group(G.m_iFirstWord);
    int i =  main_gr.m_MainWordNo;
	if (!Wi.get_lemma()) return false;
	if ( !Wi.HasFlag(fl_ranknoun) ) return false;
	
	size_t j = main_gr.m_iLastWord+1;
	if ( j == sent.size() ) return false;

	j = get_main_word(j);

	if ( !Wj.has_grammem( rSurName ) && !Wj.has_grammem( rName ) ) return false;

	if ( !GetGramTab()->GleicheCaseNumber(Wi.GetGramcodes(), Wj.GetGramcodes()) ) return false;

	G.m_iLastWord = get_maximal_group(j).m_iLastWord;
	G.SetGrammems( Wi.GetGrammems() );
	G.m_MainGroup = main_gr;
    G.m_GroupType = RANK_NAMES;
	G.m_Cause = "Правила сборки Должность+ФИО";   
	create_syn_rel(G,i,j,RANK_NAMES);
	
	return true;
};
Пример #20
0
void MergeTask::onUpdate() {
	/* See which groups can be merged already */
	std::list<CGroup*>::iterator it;
	for (it = groups.begin(); it != groups.end(); ++it) {
		CGroup *g = *it;
		
		if (g->isMicroing())
			continue;
		
		if (pos.distance2D(g->pos()) < range) {
			mergable[g->key] = g;
			g->micro(true);
		}
	}
	
	/* We have at least two groups, now we can merge */
	if (mergable.size() >= 2) {
		std::vector<int> keys;
		std::map<int, CGroup*>::iterator it;
		
		// get keys because while merging "mergable" is reducing...
		for (it = mergable.begin(); it != mergable.end(); ++it) {
			keys.push_back(it->first);
		}
		
		for (int i = 0; i < keys.size(); i++) {
			int key = keys[i];
			if (key != masterGroup->key) {
				CGroup *g = mergable[key];
				LOG_II("MergeTask::update merging " << (*g) << " with " << (*masterGroup))
				// NOTE: group being merged is automatically removed
				masterGroup->merge(*g);
			}
		}
		
		assert(mergable.size() == 1);
		mergable.clear();
		masterGroup->micro(false);
	}

	// if only one (or none) group remains, merging is no longer possible,
	// remove the task, unreg groups...
	if (groups.size() <= 1)
		ATask::remove();
}
Пример #21
0
void AssistTask::onUpdate() {
    CGroup *group = firstGroup();

    if (group->isMicroing() && group->isIdle()) {
        targetAlt = -1; // for sure
        group->micro(false);
    }

    if (!assisting) {
        if (isMoving) {
            /* Keep tracking the target */
            pos = assist->pos;

            float3 gpos = group->pos();
            float dist = gpos.distance2D(pos);
            float range = group->getRange();

            if (dist <= range) {
                bool canAssist = true;
                /*
                // for ground units prevent assisting across hill...
                if ((group->cats&AIR).none()) {
                	dist = ai->pathfinder->getPathLength(*group, pos);
                	canAssist = (dist <= range * 1.1f);
                }
                */
                if (canAssist) {
                    isMoving = false;
                    ai->pathfinder->remove(*group);
                }
            }
        }

        if (!isMoving) {
            group->assist(*assist);
            group->micro(true);
            assisting = true;
        }
    }

    if (!group->isMicroing()) {
        if ((group->cats&BUILDER).any())
            resourceScan(); // builders should not be too aggressive
        else if ((group->cats&AIR).none()) {
            enemyScan(targetAlt);
        }
    }
}
Пример #22
0
bool CMilitary::addUnit(CUnit& unit) {
	LOG_II("CMilitary::addUnit " << unit)
	
	assert(unit.group == NULL);

	unitCategory c = unit.type->cats;

	if ((c&ATTACKER).any() && (c&MOBILE).any() && (c&DEFENSE).none()) {
		unitCategory wishedCats = ai->unittable->unitsUnderConstruction[unit.key];
		CGroup* group;
		
		if ((c&SCOUTER).any() && wishedCats.any() && (wishedCats&SCOUTER).none())
			c &= ~SCOUTER; // scout was not requested

		if ((c&SCOUTER).any()) {
			group = requestGroup(SCOUT);
		}
		else if((c&AIR).any() && (c&ARTILLERY).any()) {
			group = requestGroup(BOMBER);
		}
		else if((c&AIR).any() && (c&ASSAULT).none()) {
			group = requestGroup(AIRFIGHTER);
		}
		else {
			/* If there is a new factory, or the current group is busy, request
			   a new group */
			std::map<int,CGroup*>::iterator i = assemblingGroups.find(unit.builtBy);
			if (i == assemblingGroups.end()	|| i->second->busy || !i->second->canAdd(&unit)) {
				group = requestGroup(ENGAGE);
				assemblingGroups[unit.builtBy] = group;
			} else {
				group = i->second;
			}
		}
		group->addUnit(unit);

		return true;
	}

	return false;
}
Пример #23
0
//---------------------------------------------------------------------------
//	@function:
//		CGroupExpression::SetOptimizationLevel
//
//	@doc:
//		Set optimization level of group expression
//
//
//---------------------------------------------------------------------------
void
CGroupExpression::SetOptimizationLevel()
{
	// a sequence expression with a first child group that contains a CTE
	// producer gets a higher optimization level. This is to be sure that the
	// producer gets optimized before its consumers
	if (COperator::EopPhysicalSequence == m_pop->Eopid())
	{
		CGroup *pgroupFirst = (*this)[0];
		if (pgroupFirst->FHasCTEProducer())
		{
			m_eol = EolHigh;
		}
	}
	else if (CUtils::FHashJoin(m_pop))
	{
		// optimize hash join first to minimize plan cost quickly
		m_eol = EolHigh;
	}
	else if (CUtils::FPhysicalAgg(m_pop))
	{
		BOOL fPreferMultiStageAgg = GPOS_FTRACE(EopttracePreferMultiStageAgg);
		if (!fPreferMultiStageAgg && COperator::EopPhysicalHashAgg == m_pop->Eopid())
		{
			// if we choose agg plans based on cost only (no preference for multi-stage agg), 
			// we optimize hash agg first to to minimize plan cost quickly
			m_eol = EolHigh;
			return;
		}

		// if we prefer plans with multi-stage agg, we optimize any multi-stage agg
		// first to avoid later optimization of one stage agg if possible                                   
		BOOL fMultiStage = CPhysicalAgg::PopConvert(m_pop)->FMultiStage();
		if (fPreferMultiStageAgg && fMultiStage)
		{
			// optimize multi-stage agg first to allow avoiding one-stage agg if possible
			m_eol = EolHigh;
		}
	}
}
Пример #24
0
void CMemberListPopLayer::_AddMemberList()
{
	int bgTitleH = 75;
	int bgBorderW = 16;
	int headH = 40;

	Node *bg = getChildByTag( E_Tag_Bg );
	CCAssert( bg, "bg is null" );
	Size szBg = bg->getContentSize();
	Size szCell( szBg.width-2*bgBorderW, headH );
	Size szList( szCell.width, szBg.height-bgTitleH-bgBorderW );

	CGroup *group = CUserManager::Instance().GetViewData().GetSelectGroup();
	if( !group )
	{
		CCLog( "not found select group" );
		return;
	}

	vector<string> vecMember;
	group->Dump( vecMember );

	vector<TableViewData> vecData;
	vector<string>::iterator it = vecMember.begin();
	for( ; it != vecMember.end(); ++it )
	{
		CGroupMember *member = group->FindMember( (*it) );
		CCAssert( member, "can not believe it, member not found" );
		char icon[64] = {0};
		sprintf( icon, "syshead.png");
		TableViewData data;
		data.text = member->GetName();
		CalcUserHead( member->GetHead(), E_Sex_Male, data.icon, data.iconRect, data.useRect );
		vecData.push_back( data ); 
	}
	m_memberList = CMyTableView::create(szList, szCell, vecData, "selectbg.png" );
    CCAssert( m_memberList, "CMemberListPopLayer GetTableView Failed" );
	m_memberList->SetPosition( ccp(szBg.width/2, szList.height/2+bgBorderW) );
	bg->addChild( m_memberList );
}
Пример #25
0
void CMilitary::remove(ARegistrar &object) {
	CGroup *group = dynamic_cast<CGroup*>(&object);
	
	LOG_II("CMilitary::remove " << (*group))
	
	activeScoutGroups.erase(group->key);
	activeAttackGroups.erase(group->key);
	activeBomberGroups.erase(group->key);
	activeAirFighterGroups.erase(group->key);
	mergeGroups.erase(group->key);
	
	for (std::map<int,CGroup*>::iterator i = assemblingGroups.begin(); i != assemblingGroups.end(); ++i) {
		if (i->second->key == group->key) {
			assemblingGroups.erase(i->first);
			break;
		}
	}

	group->unreg(*this);

	ReusableObjectFactory<CGroup>::Release(group);
}
Пример #26
0
MergeTask::MergeTask(AIClasses *_ai, std::list<CGroup*>& groups): ATask(_ai) {
	t = TASK_MERGE;
	isRetreating = false;
	range = 0.0f;
	masterGroup = NULL;

	std::list<CGroup*>::iterator it;
	for (it = groups.begin(); it != groups.end(); ++it) {
		CGroup *group = *it;
		addGroup(*group);
		range += group->radius();
	}
	
	unitCategory cats = firstGroup()->cats;
	if ((cats&AIR).any() && (cats&ASSAULT).none()) {
		// FIXME: prefer no hardcoding
		range = 1000.0f;
	}
	else {
		range = range + groups.size() * FOOTPRINT2REAL;
	}
}
Пример #27
0
// Правила для обособ. прил. в постпозиции\\Этим вопросом, давно и надолго забытым, \\.
bool CRusFormatCaller::format_for_noun_detached_adj_postposition(CGroup& G)
{
	size_t i, j;
	i = G.m_iFirstWord;
	const CGroup& MaxGrp = get_maximal_group(i);
	if (MaxGrp.m_iFirstWord != MaxGrp.m_iLastWord)
		i = MaxGrp.m_MainWordNo;
	else
		i = MaxGrp.m_iFirstWord;
	if ( !Wi.is_morph_noun() && !is_morph_pronoun(Wi)) return false;
	j = MaxGrp.m_iLastWord + 1;
	if (j == sent.size()) return false;
	if (!Wj.HasFlag(fl_comma)) return false;
	j++;
	if (j == sent.size()) return false;
	const CGroup& MaxGrpAdj = get_maximal_group(j);
	if (MaxGrpAdj.m_iFirstWord != MaxGrpAdj.m_iLastWord)
		j = MaxGrpAdj.m_MainWordNo;
	else
		j = MaxGrpAdj.m_iFirstWord;
	if (!is_morph_adj(Wj)) return false;
	if (    !(MaxGrpAdj.m_iLastWord == sent.size()-1) 
		&&  !sent[MaxGrpAdj.m_iLastWord+1].HasFlag(fl_comma)
	   )
		return false;
	bool bGr = false;
	if (  GetGramTab()->GleicheGenderNumberCase(Wi.m_type_gram_code, Wi.GetGramcodes(),Wj.GetGramcodes()) )
		bGr = true;

	if ((Wi.GetGrammems() & (1 <<rPlural)) && (Wj.GetGrammems() & (1 <<rSingular)))
		if ( GetGramTab()->GleicheCase(Wi.GetGramcodes(), Wj.GetGramcodes()))
			bGr = true;

	if ((Wi.GetGrammems() & (1 <<rSingular)) && (Wj.GetGrammems() & (1 <<rPlural)))
		if (GetGramTab()->GleicheCase(Wi.GetGramcodes(), Wj.GetGramcodes()))
			bGr = true;

	if (bGr == true)
	{
		G.m_GroupType = NOUN_DETACHED_ADJ;
		G.m_iFirstWord = MaxGrp.m_iFirstWord;
		G.m_iLastWord = MaxGrpAdj.m_iLastWord;
		G.m_MainGroup = MaxGrp;
		G.SetGrammems( Wi.GetGrammems() );
		create_syn_rel(G, i, j, NOUN_DETACHED_ADJ);
		return true;
	}
		
	return false;
};
Пример #28
0
//---------------------------------------------------------------------------
//	@function:
//		CExpressionHandle::DeriveProducerStats
//
//	@doc:
//		If the child (ulChildIndex) is a CTE consumer, then derive is corresponding
//		producer statistics.
//
//---------------------------------------------------------------------------
void
CExpressionHandle::DeriveProducerStats
	(
	ULONG ulChildIndex,
	CColRefSet *pcrsStats
	)
{
	// check to see if there are any CTE consumers in the group whose properties have
	// to be pushed to its corresponding CTE producer
	CGroupExpression *pgexpr = Pgexpr();
	if (NULL != pgexpr)
	{
		CGroup *pgroupChild = (*pgexpr)[ulChildIndex];
		if (pgroupChild->FHasAnyCTEConsumer())
		{
			CGroupExpression *pgexprCTEConsumer = pgroupChild->PgexprAnyCTEConsumer();
			CLogicalCTEConsumer *popConsumer = CLogicalCTEConsumer::PopConvert(pgexprCTEConsumer->Pop());
			COptCtxt::PoctxtFromTLS()->Pcteinfo()->DeriveProducerStats(popConsumer, pcrsStats);
		}

		return;
	}

	// statistics are also derived on expressions representing the producer that may have
	// multiple CTE consumers. We should ensure that their properties are to pushed to their
	// corresponding CTE producer
	CExpression *pexpr = Pexpr();
	if (NULL != pexpr)
	{
		CExpression *pexprChild = (*pexpr)[ulChildIndex];
		if (COperator::EopLogicalCTEConsumer == pexprChild->Pop()->Eopid())
		{
			CLogicalCTEConsumer *popConsumer = CLogicalCTEConsumer::PopConvert(pexprChild->Pop());
			COptCtxt::PoctxtFromTLS()->Pcteinfo()->DeriveProducerStats(popConsumer, pcrsStats);
		}
	}
}
Пример #29
0
//---------------------------------------------------------------------------
//	@function:
//		CJobGroupOptimization::EevtStartOptimization
//
//	@doc:
//		Start group optimization
//
//---------------------------------------------------------------------------
CJobGroupOptimization::EEvent
CJobGroupOptimization::EevtStartOptimization
	(
	CSchedulerContext *psc,
	CJob *pjOwner
	)
{
	// get a job pointer
	CJobGroupOptimization *pjgo = PjConvert(pjOwner);
	CGroup *pgroup = pjgo->m_pgroup;
	GPOS_ASSERT(COptimizationContext::estUnoptimized == pjgo->m_poc->Est() &&
				"Group is already optimized under this context");

	if (!pgroup->FImplemented())
	{
		// schedule a group implementation child job
		CJobGroupImplementation::ScheduleJob(psc, pgroup, pjgo);
		return eevImplementing;
	}

	// move optimization context to optimizing state
	pjgo->m_poc->SetState(COptimizationContext::estOptimizing);

	// if this is the root, release implementation jobs
	if (psc->Peng()->FRoot(pgroup))
	{
		psc->Pjf()->Truncate(EjtGroupImplementation);
		psc->Pjf()->Truncate(EjtGroupExpressionImplementation);
	}

	// at this point all group expressions have been added to group,
	// we set current job optimization level as the max group optimization level
	pjgo->m_eolCurrent = pgroup->EolMax();

	return eevImplemented;
}
Пример #30
0
bool AttackTask::onValidate() {
	CGroup *group = firstGroup();

	if (targetAlt >= 0) {
		if (ai->cbc->IsUnitCloaked(targetAlt) || !group->canAttack(targetAlt)) {
			group->stop();
		}
	}

	const UnitDef *eud = ai->cbc->GetUnitDef(target);
	if (eud == NULL)
		return false;

	if (!isMoving) {
		if (ai->cbc->IsUnitCloaked(target))
			return false;
		return true;
	}

	if (!group->canAttack(target))
		return false;

	// don't chase scout groups too long if they are out of base...
	bool scoutGroup = (group->cats&SCOUTER).any();
	if (!scoutGroup && lifeTime() > 20.0f) {
		const unitCategory ecats = UC(eud->id);
		if ((ecats&SCOUTER).any() && !ai->defensematrix->isPosInBounds(pos))
			return false;
	}

	float targetDistance = pos.distance2D(group->pos());
	if (targetDistance > 1000.0f)
		return true; // too far to panic

	if (ai->cbc->IsUnitCloaked(target))
		return false;

	bool isBaseThreat = ai->defensematrix->isPosInBounds(pos);

	// if there is no threat to our base then prevent useless attack for groups
	// which are not too cheap
	if (!isBaseThreat && (group->costMetal / group->units.size()) >= 100.0f) {
		float threatRange;
		if (scoutGroup)
			threatRange = 300.0f;
		else
			threatRange = 0.0f;

		if (group->getThreat(pos, threatRange) > group->strength)
			return false;
	}

	return true;
}