本文整理汇总了C++中ObjRef::name方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjRef::name方法的具体用法?C++ ObjRef::name怎么用?C++ ObjRef::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjRef
的用法示例。
在下文中一共展示了ObjRef::name方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: componentHierarchy
QStringList CellmlFileRuntime::componentHierarchy(iface::cellml_api::CellMLElement *pElement)
{
// Make sure that we have a given element
if (!pElement)
return QStringList();
// Try to retrieve the component that owns the given element, unless the
// given element is a component itself (which will be the case when we come
// here through recursion)
ObjRef<iface::cellml_api::CellMLComponent> component = QueryInterface(pElement);
ObjRef<iface::cellml_api::CellMLElement> parent = pElement->parentElement();
ObjRef<iface::cellml_api::CellMLComponent> parentComponent = QueryInterface(parent);
if (!component && !parentComponent) {
// The element isn't a component and neither is its parent, so it
// doesn't have a hierarchy
return QStringList();
}
// Check whether this is an imported component and, if so, retrieve its
// imported name
QString componentName = QString::fromStdWString(component?component->name():parentComponent->name());
ObjRef<iface::cellml_api::CellMLElement> componentParent = component?component->parentElement():parentComponent->parentElement();
ObjRef<iface::cellml_api::CellMLElement> componentParentParent = componentParent->parentElement();
if (componentParentParent) {
// The given element comes from or is an imported component, so go
// through our different imported components and look for the one we are
// after
ObjRef<iface::cellml_api::CellMLImport> import = QueryInterface(componentParentParent);
ObjRef<iface::cellml_api::ImportComponentSet> importComponents = import->components();
ObjRef<iface::cellml_api::ImportComponentIterator> importComponentsIter = importComponents->iterateImportComponents();
for (ObjRef<iface::cellml_api::ImportComponent> importComponent = importComponentsIter->nextImportComponent();
importComponent; importComponent = importComponentsIter->nextImportComponent()) {
if (!componentName.compare(QString::fromStdWString(importComponent->componentRef()))) {
// This is the imported component we are after, so retrieve its
// imported name
componentName = QString::fromStdWString(importComponent->name());
break;
}
}
}
// Recursively retrieve the component hierarchy of the given element's
// encapsulation parent, if any
ObjRef<iface::cellml_api::CellMLComponent> componentEncapsulationParent = component?component->encapsulationParent():parentComponent->encapsulationParent();
return componentHierarchy(componentEncapsulationParent) << componentName;
}
示例2: getReport
std::wstring CompactorReport::getReport() const
{
std::wstringstream report;
report << L"Model Compaction Report\n"
<< L"=======================\n\n";
if (! mErrorMessage.empty()) report << L"Error message: " << mErrorMessage << L"\n\n";
std::wstring indent = L"";
if (mVariableForCompaction.size() > 0)
{
report << L"Some variables have not been compacted.\n"
<< L"Uncompacted variables are given below.\n\n";
for (size_t i=0; i<mVariableForCompaction.size(); ++i)
{
ObjRef<iface::cellml_api::CellMLVariable> variable = mVariableForCompaction[i].first;
ObjRef<iface::cellml_api::CellMLVariable> srcVariable = mVariableForCompaction[i].second;
std::wstring modelUri = variable->modelElement()->base_uri()->asText();
std::wstring srcModelUri = srcVariable->modelElement()->base_uri()->asText();
for (size_t j=0;j<i;++j) indent += L"\t";
report << indent << L"Compaction requested for variable: " << modelUri << L" # "
<< variable->componentName() << L" / "
<< variable->name() << L";\n" << indent << L"with the actual source variable being: "
<< srcModelUri << L" # " << srcVariable->componentName() << L" / " << srcVariable->name() << L"\n";
}
}
report.flush();
return report.str();
}
示例3: basicTests
void Tests::basicTests()
{
// Some very basic tests to make sure that we have access to the CellML API
// Get a bootstrap object and its model loader
ObjRef<iface::cellml_api::CellMLBootstrap> cellmlBootstrap = CreateCellMLBootstrap();
ObjRef<iface::cellml_api::DOMModelLoader> modelLoader = cellmlBootstrap->modelLoader();
QVERIFY(cellmlBootstrap);
QVERIFY(modelLoader);
// Create a CellML 1.0 model
ObjRef<iface::cellml_api::Model> cellml10Model = cellmlBootstrap->createModel(L"1.0");
QVERIFY(cellml10Model);
// Create a CellML 1.1 model
ObjRef<iface::cellml_api::Model> cellml11Model = cellmlBootstrap->createModel(L"1.1");
QVERIFY(cellml11Model);
// Create an invalid CellML model
ObjRef<iface::cellml_api::Model> invalidCellmlModel;
try {
invalidCellmlModel = cellmlBootstrap->createModel(L"xxx");
} catch (...) {
QVERIFY(!invalidCellmlModel);
}
// Load an existing model
ObjRef<iface::cellml_api::Model> existingModel = modelLoader->loadFromURL(QUrl::fromPercentEncoding(QUrl::fromLocalFile(QFileInfo(OpenCOR::fileName("models/noble_model_1962.cellml")).canonicalFilePath()).toEncoded()).toStdWString());
QVERIFY(existingModel);
QCOMPARE(QString::fromStdWString(existingModel->name()), QString("noble_model_1962"));
QCOMPARE(QString::fromStdWString(existingModel->cellmlVersion()), QString("1.0"));
// Load a non-existing model
ObjRef<iface::cellml_api::Model> nonExistingModel;
try {
nonExistingModel = modelLoader->loadFromURL(L"xxx");
} catch (...) {
QVERIFY(!nonExistingModel);
}
}
示例4: if
void
WriteCode(iface::cellml_services::CodeInformation* cci, uint32_t useida)
{
iface::cellml_services::ModelConstraintLevel mcl =
cci->constraintLevel();
if (mcl == iface::cellml_services::UNDERCONSTRAINED)
{
ObjRef<iface::cellml_services::ComputationTarget> ctMissingIV(cci->missingInitial());
if (ctMissingIV != NULL)
{
ObjRef<iface::cellml_api::CellMLVariable> v = ctMissingIV->variable();
std::wstring n = v->name();
std::wstring c = v->componentName();
std::wstring str;
uint32_t deg = ctMissingIV->degree();
if (deg != 0)
{
str += L"d^";
wchar_t buf[20];
any_swprintf(buf, 20, L"%u", deg);
str += buf;
str += L"/dt^";
str += buf;
str += L" ";
}
str += n;
str += L" (in ";
str += c;
str += L")\n";
printf("/* Model is underconstrained due to missing initial_value on %S\n", str.c_str());
}
else
{
printf("/* Model is underconstrained.\n"
" * List of undefined targets follows...\n");
iface::cellml_services::ComputationTargetIterator* cti = cci->iterateTargets();
iface::cellml_services::ComputationTarget* ct;
std::vector<std::wstring> messages;
while (true)
{
ct = cti->nextComputationTarget();
if (ct == NULL)
break;
if (ct->type() != iface::cellml_services::FLOATING)
{
ct->release_ref();
continue;
}
iface::cellml_api::CellMLVariable* v = ct->variable();
std::wstring n = v->name();
std::wstring c = v->componentName();
std::wstring str = L" * * ";
uint32_t deg = ct->degree();
if (deg != 0)
{
str += L"d^";
wchar_t buf[20];
any_swprintf(buf, 20, L"%u", deg);
str += buf;
str += L"/dt^";
str += buf;
str += L" ";
}
str += n;
str += L" (in ";
str += c;
str += L")\n";
messages.push_back(str);
v->release_ref();
ct->release_ref();
}
cti->release_ref();
// Sort the messages...
std::sort(messages.begin(), messages.end());
std::vector<std::wstring>::iterator msgi;
for (msgi = messages.begin(); msgi != messages.end(); msgi++)
printf("%S", (*msgi).c_str());
printf(" */\n");
}
return;
}
else if (mcl == iface::cellml_services::OVERCONSTRAINED)
{
printf("/* Model is overconstrained.\n"
" * List variables defined at time of error follows...\n");
iface::cellml_services::ComputationTargetIterator* cti = cci->iterateTargets();
iface::cellml_services::ComputationTarget* ct;
std::vector<std::wstring> messages;
while (true)
{
ct = cti->nextComputationTarget();
if (ct == NULL)
break;
if (ct->type() == iface::cellml_services::FLOATING)
{
ct->release_ref();
continue;
}
iface::cellml_api::CellMLVariable* v = ct->variable();
std::wstring n = v->name();
//.........这里部分代码省略.........
示例5: componentHierarchy
QStringList CellmlFileRuntime::componentHierarchy(iface::cellml_api::CellMLElement *pElement)
{
// Make sure that we have a given element
if (!pElement)
return QStringList();
// Try to retrieve the component that owns the given element, unless the
// given element is a component itself (which will be the case when we come
// here through recursion)
ObjRef<iface::cellml_api::CellMLComponent> component = QueryInterface(pElement);
ObjRef<iface::cellml_api::CellMLElement> parent = pElement->parentElement();
ObjRef<iface::cellml_api::CellMLComponent> parentComponent = QueryInterface(parent);
if (!component && !parentComponent) {
// The element isn't a component and neither is its parent, so it
// doesn't have a hierarchy
return QStringList();
}
// Recursively retrieve the component hierarchy of the given element's
// encapsulation parent, if any
ObjRef<iface::cellml_api::CellMLComponent> componentEncapsulationParent = component?component->encapsulationParent():parentComponent->encapsulationParent();
return componentHierarchy(componentEncapsulationParent) << QString::fromStdWString(component?component->name():parentComponent->name());
}
示例6: update
//.........这里部分代码省略.........
break;
case iface::cellml_services::STATE_VARIABLE:
case iface::cellml_services::PSEUDOSTATE_VARIABLE:
parameterType = CellmlFileRuntimeParameter::State;
break;
case iface::cellml_services::ALGEBRAIC:
// We are dealing with either a 'proper' algebraic variable or a
// rate variable
// Note: if the variable's degree is equal to zero, then we are
// dealing with a 'proper' algebraic variable otherwise we
// are dealing with a rate variable...
if (computationTarget->degree())
parameterType = CellmlFileRuntimeParameter::Rate;
else
parameterType = CellmlFileRuntimeParameter::Algebraic;
break;
case iface::cellml_services::FLOATING:
parameterType = CellmlFileRuntimeParameter::Floating;
break;
case iface::cellml_services::LOCALLY_BOUND:
parameterType = CellmlFileRuntimeParameter::LocallyBound;
break;
}
// Keep track of the parameter, should its type be of interest
if ( (parameterType != CellmlFileRuntimeParameter::Floating)
&& (parameterType != CellmlFileRuntimeParameter::LocallyBound)) {
CellmlFileRuntimeParameter *parameter = new CellmlFileRuntimeParameter(QString::fromStdWString(variable->name()),
computationTarget->degree(),
QString::fromStdWString(variable->unitsName()),
componentHierarchy(variable),
parameterType,
computationTarget->assignedIndex());
if (parameterType == CellmlFileRuntimeParameter::Voi)
mVariableOfIntegration = parameter;
mParameters.append(parameter);
}
}
std::sort(mParameters.begin(), mParameters.end(), sortParameters);
// Generate the model code, after having prepended to it all the external
// functions that may, or not, be needed
// Note: indeed, we cannot include header files since we don't (and don't
// want in order to avoid complications) deploy them with OpenCOR. So,
// instead, we must declare as external functions all the functions
// that we would normally use through header files...
QString modelCode = "extern double fabs(double);\n"
"\n"
"extern double exp(double);\n"
"extern double log(double);\n"
"\n"
"extern double ceil(double);\n"
"extern double floor(double);\n"
"\n"
"extern double factorial(double);\n"
"\n"