コード例 #1
0
ファイル: BuildDAG.cpp プロジェクト: dgu123/factplusplus
void TBox :: addConceptToHeap ( TConcept* pConcept )
{
	// choose proper tag by concept
	DagTag tag = pConcept->isPrimitive() ?
		(pConcept->isSingleton() ? dtPSingleton : dtPConcept):
		(pConcept->isSingleton() ? dtNSingleton : dtNConcept);

	// NSingleton is a nominal
	if ( tag == dtNSingleton && !pConcept->isSynonym() )
		static_cast<TIndividual*>(pConcept)->setNominal();

	// new concept's addition
	DLVertex* ver = new DLVertex(tag);
	ver->setConcept(pConcept);
	pConcept->pName = DLHeap.directAdd(ver);

	BipolarPointer desc = bpTOP;

	// translate body of a concept
	if ( pConcept->Description != NULL )	// complex concept
		desc = tree2dag(pConcept->Description);
	else			// only primivive concepts here
		fpp_assert ( pConcept->isPrimitive() );

	// update concept's entry
	pConcept->pBody = desc;
	ver->setChild(desc);
	if ( !pConcept->isSynonym() && pConcept->index() == 0 )
		setConceptIndex(pConcept);
}
コード例 #2
0
ファイル: BuildDAG.cpp プロジェクト: dgu123/factplusplus
/// register data expression in the DAG
BipolarPointer TBox :: addDataExprToHeap ( TDataEntry* p )
{
	if ( isValid(p->getBP()) )	// already registered value
		return p->getBP();

	// determine the type of an entry
	DagTag dt = p->isBasicDataType() ? dtDataType : p->isDataValue() ? dtDataValue : dtDataExpr;
	BipolarPointer hostBP = bpTOP;

	// register host type first (if any)
	if ( p->getType() != NULL )
		hostBP = addDataExprToHeap(const_cast<TDataEntry*>(p->getType()));

	// create new DAG entry for the data value
	DLVertex* ver = new DLVertex ( dt, hostBP );
	ver->setConcept(p);
	p->setBP(DLHeap.directAdd(ver));

	return p->getBP();
}