本文整理汇总了C++中ObjRef::type方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjRef::type方法的具体用法?C++ ObjRef::type怎么用?C++ ObjRef::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjRef
的用法示例。
在下文中一共展示了ObjRef::type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
//.........这里部分代码省略.........
ObjRef<iface::cellml_api::CellMLComponentIterator> localComponentsIter = localComponents->iterateComponents();
if (hasComponentImports) {
for (ObjRef<iface::cellml_api::CellMLComponent> component = localComponentsIter->nextComponent();
component; component = localComponentsIter->nextComponent()) {
ObjRef<iface::cellml_api::CellMLVariableSet> variables = component->variables();
ObjRef<iface::cellml_api::CellMLVariableIterator> variablesIter = variables->iterateVariables();
for (ObjRef<iface::cellml_api::CellMLVariable> variable = variablesIter->nextVariable();
variable; variable = variablesIter->nextVariable()) {
ObjRef<iface::cellml_api::CellMLVariable> sourceVariable = variable->sourceVariable();
mainVariables.insert(sourceVariable, variable);
}
}
}
// Go through all our computation targets and determine which ones are
// referenced in our main CellML file, and sort them by component and
// variable name
ObjRef<iface::cellml_services::ComputationTargetIterator> computationTargetIter = genericCodeInformation->iterateTargets();
for (ObjRef<iface::cellml_services::ComputationTarget> computationTarget = computationTargetIter->nextComputationTarget();
computationTarget; computationTarget = computationTargetIter->nextComputationTarget()) {
// Make sure that our computation target is defined or referenced in our
// main CellML file, if it has imports
ObjRef<iface::cellml_api::CellMLVariable> variable = computationTarget->variable();
iface::cellml_api::CellMLVariable *mainVariable = mainVariables.value(variable);
iface::cellml_api::CellMLVariable *realVariable = mainVariable?mainVariable:variable.getPointer();
if ( hasComponentImports && !mainVariable
&& (computationTarget->type() != iface::cellml_services::VARIABLE_OF_INTEGRATION)) {
continue;
}
// Determine the type of our computation target
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()) {
// The computed target doesn't have an initial value, so it must
// be a 'computed' constant
parameterType = CellmlFileRuntimeParameter::ComputedConstant;
} else if (computationTarget->degree()) {
// The computed target has a degree, so it is effectively a rate
parameterType = CellmlFileRuntimeParameter::Rate;
示例2: instantiateCellmlApiObjects
int CellmlModelDefinition::instantiateCellmlApiObjects()
{
try
{
// create an annotation set to manage our variable usages
ObjRef<iface::cellml_services::AnnotationToolService> ats = CreateAnnotationToolService();
ObjRef<iface::cellml_services::AnnotationSet> as = ats->createAnnotationSet();
mCapi->annotations = as;
// mapping the connections between variables is a very expensive operation, so we want to
// only do it once and keep hold of the mapping (tracker item 3294)
ObjRef<iface::cellml_services::CeVASBootstrap> cvbs = CreateCeVASBootstrap();
ObjRef<iface::cellml_services::CeVAS> cevas = cvbs->createCeVASForModel(mCapi->model);
std::wstring msg = cevas->modelError();
if (msg != L"")
{
std::cerr << "loadModel: Error creating CellML Variable Association Service: "
<< ws2s(msg) << std::endl;
return -2;
}
mCapi->cevas = cevas;
// now check we can generate code and grab hold of the initial code information
ObjRef<iface::cellml_services::CodeGeneratorBootstrap> cgb = CreateCodeGeneratorBootstrap();
ObjRef<iface::cellml_services::CodeGenerator> cg = cgb->createCodeGenerator();
try
{
cg->useCeVAS(cevas);
ObjRef<iface::cellml_services::CodeInformation> cci = cg->generateCode(mCapi->model);
msg = cci->errorMessage();
if (msg != L"")
{
std::cerr << "CellmlModelDefintion::loadModel: Error generating code: "
<< ws2s(msg) << std::endl;
return -4;
}
// TODO: we are only interested in models we can work with?
if (cci->constraintLevel() != iface::cellml_services::CORRECTLY_CONSTRAINED)
{
std::cerr << "CellmlModelDefintion::loadModel: Model is not correctly constrained: "
<< std::endl;
return -5;
}
mCapi->codeInformation = cci;
// always flag all state variables and the variable of integration
ObjRef<iface::cellml_services::ComputationTargetIterator> cti = cci->iterateTargets();
while (true)
{
ObjRef<iface::cellml_services::ComputationTarget> ct = cti->nextComputationTarget();
if (ct == NULL) break;
if (ct->degree() > 0) break; // only want to initialise the base variables not the differential
ObjRef<iface::cellml_api::CellMLVariable> v(ct->variable());
if (ct->type() == iface::cellml_services::STATE_VARIABLE)
{
mVariableTypes[getVariableUniqueId(v)] = csim::StateType;
mVariableIndices[getVariableUniqueId(v)][csim::StateType] = mStateCounter;
mStateCounter++;
}
else if (ct->type() == iface::cellml_services::VARIABLE_OF_INTEGRATION)
{
mVariableTypes[getVariableUniqueId(v)] = csim::IndependentType;
mNumberOfIndependentVariables++;
}
else
{
// need to initialise the variable type
mVariableTypes[getVariableUniqueId(v)] = csim::UndefinedType;
}
}
}
catch (...)
{
std::cerr << "loadModel: Error generating the code information for the model" << std::endl;
return -3;
}
// if we get to here, everything worked.
mModelLoaded = true;
}
catch (...)
{
std::wcerr << L"Error instantiating CellML API objects." << std::endl;
return -1;
}
return csim::CSIM_OK;
}