本文整理汇总了C++中ObjRef::length方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjRef::length方法的具体用法?C++ ObjRef::length怎么用?C++ ObjRef::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjRef
的用法示例。
在下文中一共展示了ObjRef::length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void CellmlFileRuntime::update()
{
// Reset the runtime's properties
reset(true, true);
// Check that the model is either a 'simple' ODE model or a DAE model
// Note #1: we don't check whether a model is valid, since all we want is to
// update its runtime (which has nothing to do with editing or even
// validating a model), so if it can be done then great otherwise
// tough luck (so to speak)...
// Note #2: in order to do so, we need to get a 'normal' code generator (as
// opposed to an IDA, i.e. DAE, code generator) since if the model
// is correctly constrained, then we can check whether some of its
// equations were flagged as needing a Newton-Raphson evaluation,
// in which case we would be dealing with a DAE model...
// Note #3: ideally, there would be a more convenient way to determine the
// type of a model, but there isn't...
iface::cellml_api::Model *model = mCellmlFile->model();
if (!model)
return;
// Retrieve the model's type
// Note: this can be done by checking whether some equations were flagged
// as needing a Newton-Raphson evaluation...
retrieveOdeCodeInformation(model);
if (!mOdeCodeInformation)
return;
ObjRef<iface::mathml_dom::MathMLNodeList> flaggedEquations = mOdeCodeInformation->flaggedEquations();
mModelType = flaggedEquations->length()?CellmlFileRuntime::Dae:CellmlFileRuntime::Ode;
// If the model is of DAE type, then we don't want the ODE-specific code
// information, but the DAE-specific code one
ObjRef<iface::cellml_services::CodeInformation> genericCodeInformation;
if (mModelType == CellmlFileRuntime::Ode) {
genericCodeInformation = mOdeCodeInformation;
} else {
retrieveDaeCodeInformation(model);
if (!mDaeCodeInformation)
return;
genericCodeInformation = mDaeCodeInformation;
}
// Retrieve the number of constants, states/rates, algebraic and conditional
// variables in the model
// Note: this is to avoid having to go through the ODE/DAE code information
// an unnecessary number of times when we want to retrieve either of
// those numbers (e.g. see
// SingleCellViewSimulationResults::addPoint())...
if (mModelType == CellmlFileRuntime::Ode) {
mConstantsCount = mOdeCodeInformation->constantIndexCount();
mStatesRatesCount = mOdeCodeInformation->rateIndexCount();
mAlgebraicCount = mOdeCodeInformation->algebraicIndexCount();
mCondVarCount = 0;
} else {
mConstantsCount = mDaeCodeInformation->constantIndexCount();
mStatesRatesCount = mDaeCodeInformation->rateIndexCount();
mAlgebraicCount = mDaeCodeInformation->algebraicIndexCount();
mCondVarCount = mDaeCodeInformation->conditionVariableCount();
}
// Retrieve all the parameters and sort them by component/variable name
ObjRef<iface::cellml_services::ComputationTargetIterator> computationTargetIter = genericCodeInformation->iterateTargets();
for (ObjRef<iface::cellml_services::ComputationTarget> computationTarget = computationTargetIter->nextComputationTarget();
computationTarget; computationTarget = computationTargetIter->nextComputationTarget()) {
// Determine the type of the parameter
ObjRef<iface::cellml_api::CellMLVariable> variable = computationTarget->variable();
CellmlFileRuntimeParameter::ParameterType parameterType;
switch (computationTarget->type()) {
case iface::cellml_services::VARIABLE_OF_INTEGRATION:
parameterType = CellmlFileRuntimeParameter::Voi;
break;
case iface::cellml_services::CONSTANT:
// We are dealing with a constant, but the question is whether that
// constant is a 'proper' constant, a 'computed' constant or even a
// rate, and this can be determined by checking whether the computed
// target has an initial value or even a degree
// Note: a state variable that is initialised using the initial
// value of another variable will have its rate considered as
// a constant. However, when it comes to the GUI, we really
// want it to be seen as a rate hence we check for the degree
// of the computed target...
if (QString::fromStdWString(variable->initialValue()).isEmpty()) {
//.........这里部分代码省略.........