本文整理汇总了C++中CEvent::setTriggerExpression方法的典型用法代码示例。如果您正苦于以下问题:C++ CEvent::setTriggerExpression方法的具体用法?C++ CEvent::setTriggerExpression怎么用?C++ CEvent::setTriggerExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEvent
的用法示例。
在下文中一共展示了CEvent::setTriggerExpression方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: duplicateEvent
void CModelExpansion::duplicateEvent(CEvent* source, const std::string & index, const SetOfModelElements & sourceSet, ElementsMap & emap)
{
//if the source object has already been duplicated: do nothing
if (emap.exists(source))
return;
CEvent* newObj = NULL;
if (expressionContainsObject(source->getTriggerExpressionPtr(), sourceSet)
|| expressionContainsObject(source->getDelayExpressionPtr(), sourceSet))
{
//we need to duplicate the event itself (because the trigger refers to a duplicated object)
//try creating the object until we find a name that is not yet used
std::ostringstream infix;
do
{
std::ostringstream name;
name << source->getObjectName() << infix.str() << index;
newObj = mpModel->createEvent(name.str());
infix << "_";
}
while (!newObj);
//add duplicated object to the map
emap.add(source, newObj);
//now do the trigger
newObj->setTriggerExpression(source->getTriggerExpression());
newObj->getTriggerExpressionPtr()->compile(); //I don't know why this is necessary
updateExpression(newObj->getTriggerExpressionPtr(), index, sourceSet, emap);
//delay
newObj->setDelayExpression(source->getDelayExpression());
newObj->getDelayExpressionPtr()->compile(); //I don't know why this is necessary
updateExpression(newObj->getDelayExpressionPtr(), index, sourceSet, emap);
newObj->setDelayAssignment(source->getDelayAssignment());
}
else
{
newObj = source; //no copying necessary
//add duplicated object to the map
emap.add(source, newObj);
}
//now the event assignments...
size_t i;
for (i = 0; i < source->getAssignments().size(); ++i)
{
const CEventAssignment* pSourceAssignment = source->getAssignments()[i];
//const CModelEntity * pSourceTarget = dynamic_cast<const CModelEntity * >(CCopasiRootContainer::getKeyFactory()->get(pSourceAssignment->getTargetKey()));
if (sourceSet.contains(pSourceAssignment->getTargetKey()))
{
//we assume that the duplicate of the target object already exists.
//this should be true since events are duplicated last.
if (!emap.exists(pSourceAssignment->getTargetKey()))
continue;
//create duplicate of assignment (this can be either in the original event or in the
//duplicate of an event)
CEventAssignment * pNewAssignment = new CEventAssignment(emap.getDuplicateKey(pSourceAssignment->getTargetKey()));
newObj->getAssignments().add(pNewAssignment, true);
//we do an assumption:
//It should not happen that the assignment expression contains a reference to an object that is duplicated,
//but the assignment target is not duplicated.
//now copy the expression
pNewAssignment->setExpression(pSourceAssignment->getExpression());
pNewAssignment->getExpressionPtr()->compile();
updateExpression(pNewAssignment->getExpressionPtr(), index, sourceSet, emap);
}
}
newObj->setNotes(source->getNotes());
newObj->setMiriamAnnotation(source->getMiriamAnnotation(), newObj->getKey(), source->getKey());
}
示例2: if
void CQEventWidget1::addEvent(UndoEventData *pSData)
{
assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
assert(pDataModel != NULL);
CModel * pModel = pDataModel->getModel();
assert(pModel != NULL);
//reinsert the Event
CEvent *pEvent = pModel->createEvent(pSData->getName());
//set the expressions
pEvent->setTriggerExpression(pSData->getTriggerExpression());
pEvent->setDelayExpression(pSData->getDelayExpression());
pEvent->setPriorityExpression(pSData->getPriorityExpression());
QList <UndoEventAssignmentData *> *assignmentData = pSData->getEventAssignmentData();
QList <UndoEventAssignmentData *>::const_iterator i;
for (i = assignmentData->begin(); i != assignmentData->end(); ++i)
{
UndoEventAssignmentData * assignData = *i;
CCopasiObject * pObject = NULL;
bool speciesExist = false;
size_t ci;
for (ci = 0; ci < pModel->getCompartments().size(); ci++)
{
CCompartment * pCompartment = pModel->getCompartments()[ci];
if (pCompartment->getMetabolites().getIndex(assignData->getName()) != C_INVALID_INDEX)
speciesExist = true;
}
if (speciesExist)
{
size_t index = pModel->findMetabByName(assignData->getName());
pObject = pModel->getMetabolites()[index];
}
else if (pModel->getModelValues().getIndex(assignData->getName()) != C_INVALID_INDEX)
{
pObject = pModel->getModelValues()[assignData->getName()];
}
else if (pModel->getReactions().getIndex(assignData->getName()) != C_INVALID_INDEX)
{
pObject = pModel->getReactions()[assignData->getName()];
}
const CModelEntity * pEntity = dynamic_cast< const CModelEntity * >(pObject);
CEventAssignment *eventAssign = new CEventAssignment(pObject->getKey(), pEvent->getObjectParent());
eventAssign->setExpression(assignData->getExpression());
eventAssign->getExpressionPtr()->compile();
pEvent->getAssignments().add(eventAssign);
}
std::string key = pEvent->getKey();
protectedNotify(ListViews::EVENT, ListViews::ADD, key);
mpListView->switchToOtherWidget(C_INVALID_INDEX, key);
}