本文整理汇总了C++中CCopasiObject::getKey方法的典型用法代码示例。如果您正苦于以下问题:C++ CCopasiObject::getKey方法的具体用法?C++ CCopasiObject::getKey怎么用?C++ CCopasiObject::getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCopasiObject
的用法示例。
在下文中一共展示了CCopasiObject::getKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void CMIRIAMInfo::load(const std::string& key)
{
pdelete(mpRDFGraph);
mKey = key;
CCopasiObject * pCopasiObject = dynamic_cast< CCopasiObject * >(CCopasiRootContainer::getKeyFactory()->get(mKey));
if (pCopasiObject != NULL)
{
const std::string * pMiriamAnnotation = NULL;
CAnnotation * pAnnotation = CAnnotation::castObject(pCopasiObject);
if (pAnnotation != NULL)
{
pMiriamAnnotation = &pAnnotation->getMiriamAnnotation();
}
if (pMiriamAnnotation && *pMiriamAnnotation != "")
mpRDFGraph = CRDFParser::graphFromXml(*pMiriamAnnotation);
}
if (mpRDFGraph == NULL)
mpRDFGraph = new CRDFGraph;
// We make sure that we always have an about node.
if (pCopasiObject != NULL)
mTriplet.pObject = mpRDFGraph->createAboutNode(pCopasiObject->getKey());
else
mTriplet.pObject = mpRDFGraph->createAboutNode("");
// Load the created date if set;
CRDFPredicate::Path Path = mTriplet.pObject->getPath();
std::set< CRDFTriplet > Triples =
mTriplet.pObject->getDescendantsWithPredicate(CRDFPredicate::dcterms_created);
if (Triples.size() > 0)
mCreated = *Triples.begin();
else
mCreated = CRDFTriplet(); // This is an invalid triplet, i.e., !mCreated is true.
loadCreators();
loadReferences();
loadModifications();
loadBiologicalDescriptions();
return;
}
示例2: createNewSlider
void SliderDialog::createNewSlider()
{
// allow the user to create more than one slider
std::vector<const CCopasiObject*> objects = CCopasiSelectionDialog::getObjectVector(this,
CQSimpleSelectionTree::InitialTime |
CQSimpleSelectionTree::Parameters);
std::vector<CSlider*>* pVector = getCSlidersForCurrentFolderId();
std::vector<const CCopasiObject*>::const_iterator it = objects.begin(), endit = objects.end();
bool yesToAll = false;
bool noToAll = false;
// create the sliders for all the selected objects
// first we need the task object because we need it later to associate the
// later with the correct task
CCopasiObject* object = (CCopasiObject*)getTaskForFolderId(mCurrentFolderId);
if (!object) return;
CCopasiObject* pTmpObject = NULL;
while (it != endit)
{
// create a new slider
assert((*it) != NULL);
pTmpObject = const_cast<CCopasiObject*>(determineCorrectObjectForSlider(*it));
CSlider* pCSlider = new CSlider("slider", (*CCopasiRootContainer::getDatamodelList())[0]);
if (pCSlider)
{
pCSlider->setSliderObject(pTmpObject);
pCSlider->setAssociatedEntityKey(object->getKey());
// check if a slider for that object already exists and if so, prompt
// the user what to do
CSlider* pEquivalentSlider = equivalentSliderExists(pCSlider);
if (pEquivalentSlider != NULL)
{
CopasiSlider* pCopasiSlider = NULL;
// if the user has specified yesToAll, we reset the ranges of all
// duplicate sliders
if (yesToAll)
{
pEquivalentSlider->resetRange();
// update the slider widget
pCopasiSlider = findCopasiSliderForCSlider(pEquivalentSlider);
assert(pCopasiSlider != NULL);
if (pCopasiSlider != NULL)
{
pCopasiSlider->updateSliderData();
}
}
// if the user has not specified noToAll, we need to prompt
else if (!noToAll)
{
QMessageBox::StandardButton result = CQMessageBox::information(NULL, "Slider Exists",
"A slider for this object already exists.\n\nDo you want to reset the range of the slider?",
QMessageBox::Yes | QMessageBox::No | QMessageBox::YesToAll | QMessageBox::NoToAll, QMessageBox::No);
// check the answer and maybe set some flags
switch (result)
{
case QMessageBox::YesToAll:
// set the flag
yesToAll = true;
case QMessageBox::Yes:
// reset the range
pEquivalentSlider->resetRange();
// update the slider widget
pCopasiSlider = findCopasiSliderForCSlider(pEquivalentSlider);
assert(pCopasiSlider != NULL);
if (pCopasiSlider != NULL)
{
pCopasiSlider->updateSliderData();
}
break;
case QMessageBox::NoToAll:
// set the flag
noToAll = true;
break;
case QMessageBox::No:
// do nothing else
break;
default:
// do nothing
break;
}
}
delete pCSlider;
}
else
//.........这里部分代码省略.........
示例3: processEnd
// virtual
bool COPASIHandler::processEnd(const XML_Char * pszName)
{
bool finished = false;
switch (mCurrentElement.first)
{
case COPASI:
{
// We need to handle the unmapped parameters of type key.
std::vector< std::string >::iterator it = mpData->UnmappedKeyParameters.begin();
std::vector< std::string >::iterator end = mpData->UnmappedKeyParameters.end();
for (; it != end; ++it)
{
CCopasiParameter * pParameter =
dynamic_cast< CCopasiParameter * >(CCopasiRootContainer::getKeyFactory()->get(*it));
if (pParameter != NULL &&
pParameter->getType() == CCopasiParameter::KEY)
{
CCopasiObject * pObject =
mpData->mKeyMap.get(pParameter->getValue< std::string >());
if (pObject != NULL)
pParameter->setValue(pObject->getKey());
else
pParameter->setValue(std::string(""));
}
}
// We need to remove the no longer needed expression "Objective Function" from the function list.
if (mpData->pFunctionList != NULL &&
mpData->pFunctionList->getIndex("Objective Function") != C_INVALID_INDEX)
{
mpData->pFunctionList->remove("Objective Function");
}
}
finished = true;
break;
case ParameterGroup:
finished = true;
break;
case ListOfFunctions:
case Model:
case ListOfTasks:
case ListOfReports:
case ListOfPlots:
case ListOfLayouts:
case SBMLReference:
case ListOfUnitDefinitions:
break;
case GUI:
if (mpData->pGUI == NULL)
{
CCopasiMessage::getLastMessage();
}
break;
default:
CCopasiMessage(CCopasiMessage::EXCEPTION, MCXML + 2,
mpParser->getCurrentLineNumber(), mpParser->getCurrentColumnNumber(), pszName);
break;
}
return finished;
}
示例4: CCopasiMessage
std::string CODEExporterC::KineticFunction2ODEmember(const CReaction *reac)
{
std::ostringstream equation;
if (reac->getFunction()->getType() != CEvaluationTree::MassAction)
{
const CFunctionParameters & params = reac->getFunctionParameters();
size_t k, params_size = params.size();
const std::vector<std::vector<std::string> > & keyMap = reac->getParameterMappings();
std::string name;
equation << NameMap[reac->getFunction()->getKey()] << "(";
for (k = 0; k < params_size; ++k)
{
CFunctionParameter::Role role = params[k]->getUsage();
CCopasiObject * obj = CCopasiRootContainer::getKeyFactory()->get(keyMap[k][0]);
if ((role == CFunctionParameter::SUBSTRATE)
|| (role == CFunctionParameter::PRODUCT)
|| (role == CFunctionParameter::MODIFIER))
{
if (obj)
name = NameMap[obj->getKey()];
else
name = "unknown";
}
if (role == CFunctionParameter::PARAMETER)
{
if (!(reac->isLocalParameter(k)))
{
CModelValue* modval;
modval = dynamic_cast< CModelValue * >(obj);
name = NameMap[modval->getKey()];
}
else
{
CCopasiParameter* param;
param = dynamic_cast< CCopasiParameter * >(obj);
name = NameMap[param->getKey()];
}
}
if (role == CFunctionParameter::VOLUME)
{
CCompartment* comp;
comp = dynamic_cast< CCompartment * >(obj);
name = NameMap[comp->getKey()];
}
if (role == CFunctionParameter::TIME)
{
name = "T";
}
if (name.empty())
{
std::string message = "Could not export C code, since one of the arguments could not be resolved. Please consider filing a bug with the COPASI tracker: http://www.copasi.org/tracker";
CCopasiMessage(CCopasiMessage::EXCEPTION, message.c_str());
}
equation << name;
if (k != params_size - 1)
equation << ", ";
}
equation << ")";
}
else
{
const CCopasiVector<CChemEqElement> & substrs = reac->getChemEq().getSubstrates();
const CCopasiVector<CChemEqElement> & prods = reac->getChemEq().getProducts();
const std::vector<std::vector<std::string> > & keyMap = reac->getParameterMappings();
CCopasiObject * obj;
size_t substrs_size = substrs.size(), prods_size = prods.size();
size_t k, m, mult;
const CChemEqElement* substr;
const CChemEqElement* prod;
const CMassAction & cMassAction = *static_cast<const CMassAction*>(reac->getFunction());
equation << "(";
obj = CCopasiRootContainer::getKeyFactory()->get(keyMap[0][0]);
if (!(reac->isLocalParameter(0)))
{
CModelValue* modval;
modval = dynamic_cast< CModelValue * >(obj);
equation << NameMap[modval->getKey()];
}
else
{
CCopasiParameter* param;
//.........这里部分代码省略.........
示例5: 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);
}
示例6: sValue
// virtual
CXMLHandler * ParameterHandler::processStart(const XML_Char * pszName,
const XML_Char ** papszAttrs)
{
CXMLHandler * pHandlerToCall = NULL;
const char * cValue = NULL;
const char * cType = NULL;
std::string name;
std::string sValue("");
bool UnmappedKey = false;
void * pValue = NULL;
CCopasiParameter::Type type;
C_FLOAT64 d;
C_INT32 i;
size_t ui;
bool b;
switch (mCurrentElement.first)
{
case Parameter:
// Parameter has attributes name, type and value
name = mpParser->getAttributeValue("name", papszAttrs);
cType = mpParser->getAttributeValue("type", papszAttrs);
type = toEnum(cType, CCopasiParameter::XMLType, CCopasiParameter::INVALID);
cValue = mpParser->getAttributeValue("value", papszAttrs);
if (cValue != NULL)
{
sValue = cValue;
}
switch (type)
{
case CCopasiParameter::DOUBLE:
d = CCopasiXMLInterface::DBL(sValue.c_str());
pValue = &d;
break;
case CCopasiParameter::UDOUBLE:
d = CCopasiXMLInterface::DBL(sValue.c_str());
pValue = &d;
break;
case CCopasiParameter::INT:
i = strToInt(sValue.c_str());
pValue = &i;
break;
case CCopasiParameter::UINT:
ui = strToUnsignedInt(sValue.c_str());
pValue = &ui;
break;
case CCopasiParameter::BOOL:
if (sValue == "0" || sValue == "false")
{
b = false;
}
else
{
b = true;
}
pValue = &b;
break;
case CCopasiParameter::STRING:
case CCopasiParameter::FILE:
case CCopasiParameter::CN:
pValue = &sValue;
break;
case CCopasiParameter::KEY:
{
if (sValue != "" &&
CKeyFactory::isValidKey(sValue))
{
CCopasiObject * pObject = mpData->mKeyMap.get(sValue);
if (pObject)
{
sValue = pObject->getKey();
}
else
{
UnmappedKey = true;
}
}
pValue = &sValue;
}
break;
default:
CCopasiMessage(CCopasiMessage::ERROR, MCXML + 16, name.c_str(), cType, mpParser->getCurrentLineNumber());
//.........这里部分代码省略.........