当前位置: 首页>>代码示例>>C++>>正文


C++ ObjRef类代码示例

本文整理汇总了C++中ObjRef的典型用法代码示例。如果您正苦于以下问题:C++ ObjRef类的具体用法?C++ ObjRef怎么用?C++ ObjRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: retrieveCmetaIdsFromCellmlElement

void CellmlFile::retrieveCmetaIdsFromCellmlElement(iface::cellml_api::CellMLElement *pElement)
{
    // Keep track of the given CellML element's cmeta:id

    QString cmetaId = QString::fromStdWString(pElement->cmetaId());

    if (!cmetaId.isEmpty())
        mUsedCmetaIds << cmetaId;

    // Do the same for all the child elements of the given CellML element

    ObjRef<iface::cellml_api::CellMLElementSet> childElements = pElement->childElements();
    ObjRef<iface::cellml_api::CellMLElementIterator> childElementsIter = childElements->iterate();

    try {
        for (ObjRef<iface::cellml_api::CellMLElement> childElement = childElementsIter->next();
             childElement; childElement = childElementsIter->next()) {
            retrieveCmetaIdsFromCellmlElement(childElement);
        }
    } catch (...) {
        // Note: we should never reach this point, but it may still happen if a
        //       CellML file contains a child element that is not known to the
        //       CellML API. We are taking the view that this is a limitation of
        //       the CellML API and shouldn't therefore generate an error for
        //       something that should have been working fine in the first
        //       place...
    }
}
开发者ID:hsorby,项目名称:opencor,代码行数:28,代码来源:cellmlfile.cpp

示例2: CreateCodeGeneratorBootstrap

void CellmlFileRuntime::retrieveDaeCodeInformation(iface::cellml_api::Model *pModel)
{
    // Get a code generator bootstrap and create a DAE code generator

    ObjRef<iface::cellml_services::CodeGeneratorBootstrap> codeGeneratorBootstrap = CreateCodeGeneratorBootstrap();
    ObjRef<iface::cellml_services::IDACodeGenerator> codeGenerator = codeGeneratorBootstrap->createIDACodeGenerator();

    // Generate some code for the model

    try {
        mDaeCodeInformation = codeGenerator->generateIDACode(pModel);

        // Check that the code generation went fine

        checkCodeInformation(mDaeCodeInformation);
    } catch (iface::cellml_api::CellMLException &exception) {
        couldNotGenerateModelCodeIssue(Core::formatMessage(QString::fromStdWString(exception.explanation)));
    } catch (...) {
        unknownProblemDuringModelCodeGenerationIssue();
    }

    // Check the outcome of the DAE code generation

    if (mIssues.count())
        resetDaeCodeInformation();
}
开发者ID:fethio,项目名称:opencor,代码行数:26,代码来源:cellmlfileruntime.cpp

示例3: compModel

double SingleCellViewSimulation::requiredMemory()
{
    // Determine and return the amount of required memory to run our simulation
    // Note #1: we return the amount as a double rather than a qulonglong (as we
    //          do when retrieving the total/free amount of memory available;
    //          see [OpenCOR]/src/plugins/misc/Core/src/coreutils.cpp) in case a
    //          simulation requires an insane amount of memory...
    // Note #2: the 1 is for mPoints in SingleCellViewSimulationResults...

    iface::cellml_services::CellMLCompiledModel*
        compModel(mData->isDAETypeSolver() ?
                  static_cast<iface::cellml_services::CellMLCompiledModel*>
                  (mRuntime->daeCompiledModel()) :
                  static_cast<iface::cellml_services::CellMLCompiledModel*>
                  (mRuntime->odeCompiledModel()));
    ObjRef<iface::cellml_services::CodeInformation> codeInfo
        (compModel->codeInformation());

    // This is not very accurate at all, because the solver caches a lot more
    // information about the problem being solved, some of it bigger than any
    // of the below (e.g. Jacobian matricies. Given the solver dependence of
    // this size, I'm not sure this function is that useful.
    return 
        size() *
        (1 + codeInfo->constantIndexCount() + codeInfo->rateIndexCount() * 3 +
         codeInfo->algebraicIndexCount())
        * sizeof(double);
}
开发者ID:A1kmm,项目名称:opencor,代码行数:28,代码来源:singlecellviewsimulation.cpp

示例4: QStringList

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());
}
开发者ID:fethio,项目名称:opencor,代码行数:29,代码来源:cellmlfileruntime.cpp

示例5: loadAndExecute

//! (static)
std::pair<bool, ObjRef> loadAndExecute(Runtime & runtime, const std::string & filename) {
	ObjRef script;
	try {
		script = loadScriptFile(filename);
	} catch (Exception * error) {
		std::cerr << "\nError occurred while loading file '" << filename << "':\n" << error->toString() << std::endl;
		return std::make_pair(false, error);
	}
	bool success = true;
	ObjRef result;
	try {
		runtime.executeObj(script.get());
		result = runtime.getResult();
		if(runtime.getState() == Runtime::STATE_EXCEPTION) {
			std::cout << "\nException caught (1):\n" << result.toString() << std::endl;
			success = false;
		}
	} catch (Object * o) {
		result = o;
		std::cout << "\nException caught (2):\n" << result.toString() << std::endl;
		success = false;
	} catch (...) {
		std::cout << "\nCaught unknown C++ exception." << std::endl;
		success = false;
	}
	return std::make_pair(success, result);
}
开发者ID:BackupTheBerlios,项目名称:escript-svn,代码行数:28,代码来源:Helper.cpp

示例6: xmlBase

QString CellmlFile::xmlBase()
{
    // Return the CellML file's base URI

    if (load()) {
        ObjRef<iface::cellml_api::URI> baseUri = mModel->xmlBase();

        return QString::fromStdWString(baseUri->asText());
    } else {
        return QString();
    }
}
开发者ID:hsorby,项目名称:opencor,代码行数:12,代码来源:cellmlfile.cpp

示例7: QueryInterface

bool CellmlFile::load()
{
    // Check whether the file is already loaded and without any issues

    if (!mLoadingNeeded)
        return mIssues.isEmpty();

    // Consider the file loaded
    // Note: even when we can't load the file, we still consider it 'loaded'
    //       since we at least tried to load it, so unless the file gets
    //       modified (and we are to reload it), we are 'fine'...

    mLoadingNeeded = false;

    // Try to load the model

    if (!doLoad(mFileName, QString(), &mModel, mIssues))
        return false;

    // Retrieve all the RDF triples associated with the model and initialise our
    // list of original RDF triples

    ObjRef<iface::cellml_api::RDFRepresentation> rdfRepresentation = mModel->getRDFRepresentation(L"http://www.cellml.org/RDF/API");

    if (rdfRepresentation) {
        mRdfApiRepresentation = QueryInterface(rdfRepresentation);

        if (mRdfApiRepresentation) {
            mRdfDataSource = mRdfApiRepresentation->source();
            ObjRef<iface::rdf_api::TripleSet> rdfTriples = mRdfDataSource->getAllTriples();
            ObjRef<iface::rdf_api::TripleEnumerator> rdfTriplesEnumerator = rdfTriples->enumerateTriples();

            for (ObjRef<iface::rdf_api::Triple> rdfTriple = rdfTriplesEnumerator->getNextTriple();
                 rdfTriple; rdfTriple = rdfTriplesEnumerator->getNextTriple()) {
                mRdfTriples << new CellmlFileRdfTriple(this, rdfTriple);
            }

            mRdfTriples.updateOriginalRdfTriples();
        }
    }

    // Determine which cmeta:ids are currently in use, be they in the various
    // CellML elements or RDF triples

    retrieveCmetaIdsFromCellmlElement(mModel);

    foreach (CellmlFileRdfTriple *rdfTriple, mRdfTriples)
        mUsedCmetaIds << rdfTriple->metadataId();

    mUsedCmetaIds.removeDuplicates();

    return true;
}
开发者ID:hsorby,项目名称:opencor,代码行数:53,代码来源:cellmlfile.cpp

示例8: simulationComplete

void SingleCellViewSimulationData::startNextRepeat()
{
    mCurrentRepeat++;
    if (mCurrentRepeat >= solverProperties()["nrepeats"].toInt()) {
        emit simulationComplete();
        return;
    }

    if (mCurrentRepeat == 0)
      mStatesWhenRun = mStates;
    else
      mStates = mStatesWhenRun;

    newIntegrationRun();

    if (!mIntegrationRun)
        return;

    mState = SingleCellViewSimulationData::SIMSTATE_WAITING_RESULTS;

    iface::cellml_services::CellMLCompiledModel*
        compModel(isDAETypeSolver() ?
                  static_cast<iface::cellml_services::CellMLCompiledModel*>
                  (mRuntime->daeCompiledModel()) :
                  static_cast<iface::cellml_services::CellMLCompiledModel*>
                  (mRuntime->odeCompiledModel()));
    ObjRef<iface::cellml_services::CodeInformation> codeInfo
        (compModel->codeInformation());

    mResultReceiver = new ResultListener(mIntegrationRun, codeInfo->rateIndexCount(),
                                         codeInfo->algebraicIndexCount());
    mResultReceiver->delay(mDelay);

    mIntegrationRun->setStepSizeControl(mSolverProperties["absTol"].toDouble(),
                                        mSolverProperties["relTol"].toDouble(),
                                        1.0, // Scaling factor: states
                                        1.0, // Scaling factor: rates
                                        mSolverProperties["maxStep"].toDouble());
    mIntegrationRun->setResultRange(mStartingPoint, mEndingPoint,
                                    10000.0 // Maximum density of points in bvar, as an upper bound on the number
                                            // of points returned.
                                   );
    mIntegrationRun->setProgressObserver(mResultReceiver);

    QObject::connect(mResultReceiver, SIGNAL(constantsAvailable(const QList<double>)), this, SIGNAL(constantsAvailable(const QList<double>)));
    QObject::connect(mResultReceiver, SIGNAL(solveDone()), this, SLOT(startNextRepeat()));
    QObject::connect(mResultReceiver, SIGNAL(solveFailure(QString)), this, SIGNAL(simulationFailed(QString)));
    QObject::connect(mResultReceiver, SIGNAL(solvePointAvailable(double,QList<double>,QList<double>,QList<double>)), this, SIGNAL(simulationDataAvailable(double,QList<double>,QList<double>,QList<double>)));

    setupOverrides();
    mIntegrationRun->start();
}
开发者ID:A1kmm,项目名称:opencor,代码行数:52,代码来源:singlecellviewsimulation.cpp

示例9: loadAndExecute

//! (static)
std::pair<bool, ObjRef> loadAndExecute(Runtime & runtime, const std::string & filename) {
	try {
		ObjRef result = _loadAndExecute(runtime,filename);
		ObjRef exitResult = runtime.fetchAndClearExitResult();
		return std::make_pair(true,exitResult.isNotNull() ? exitResult : result);
	} catch (Object * error) {
		std::ostringstream os;
		os << "Error occurred while loading file '" << filename << "':\n" << error->toString() << std::endl;
		runtime.log(Logger::LOG_ERROR,os.str());
		return std::make_pair(false, error);
	}
//	}catch(...){
//		std::cout << "\nCaught unknown C++ exception." << std::endl;
//		return std::make_pair(false, result.detachAndDecrease());
}
开发者ID:BackupTheBerlios,项目名称:escript-svn,代码行数:16,代码来源:RuntimeHelper.cpp

示例10: CreateCellMLBootstrap

bool CellmlFileManager::canLoadFileContents(const QString &pFileContents) const
{
    // Try to load the CellML file contents

    ObjRef<iface::cellml_api::CellMLBootstrap> cellmlBootstrap = CreateCellMLBootstrap();
    ObjRef<iface::cellml_api::DOMModelLoader> modelLoader = cellmlBootstrap->modelLoader();
    ObjRef<iface::cellml_api::Model> model;

    try {
        model = modelLoader->createFromText(pFileContents.toStdWString());

        return true;
    } catch (iface::cellml_api::CellMLException &) {
        return false;
    }
}
开发者ID:hsorby,项目名称:opencor,代码行数:16,代码来源:cellmlfilemanager.cpp

示例11: throw

void
CDA_CellMLElement::addEventListener
(
 const std::wstring& aType,
 iface::events::EventListener* aListener,
 bool aUseCapture
)
  throw(std::exception&)
{
  // Only bubbling is supported, as these events can't be cancelled.
  if (aUseCapture)
    throw iface::cellml_api::CellMLException(L"Only bubbling events are supported.");

  int32_t event = FindEventByName(aType);
  // Unknown events are silently ignored, as per the DOM Events specification.
  if (event == -1)
    return;

  // Find the adaptor, if there is one...
  ListenerToAdaptor_t::iterator i = mListenerToAdaptor.find(aListener);

  ObjRef<CDA_CellMLElementEventAdaptor> adaptor;

  if (i == mListenerToAdaptor.end())
  {
    // We add a refcount, putting the total to 2...
    adaptor = new CDA_CellMLElementEventAdaptor(this, aListener);
    // One refcount is used for the map, the other belongs to the ObjRef and
    // will be automatically dropped.
    mListenerToAdaptor.insert(std::pair<iface::events::EventListener*,
                              CDA_CellMLElementEventAdaptor*>
                              (aListener, adaptor)
                             );
  }
  else
    adaptor = (*i).second;

  try
  {
    adaptor->newEventType(event);
  }
  catch (std::exception& e)
  {
    adaptor->considerDestruction();
    throw e;
  }
}
开发者ID:OpenCMISS-Dependencies,项目名称:libcellml,代码行数:47,代码来源:CellMLEvents.cpp

示例12: 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();
}
开发者ID:nickerso,项目名称:flattenCellML,代码行数:27,代码来源:compactorreport.cpp

示例13: findFile

/*! Tries to locate the given __filename__ with the current searchPath set in the runtime.
	@return the path to the file or the original __filename__ if the file could not be found.	*/
static std::string findFile(Runtime & runtime, const std::string & filename){
	static const StringId seachPathsId("__searchPaths");

	std::string file(IO::condensePath(filename));
	if( IO::getEntryType(file)!=IO::TYPE_FILE ){
		if(Array * searchPaths = dynamic_cast<Array*>(runtime.getAttribute(seachPathsId).getValue())){
			for(ERef<Iterator> itRef=searchPaths->getIterator();!itRef->end();itRef->next()){
				ObjRef valueRef = itRef->value();
				std::string s(IO::condensePath(valueRef.toString()+'/'+filename));
				if( IO::getEntryType(s)==IO::TYPE_FILE ){
					file = s;
					break;
				}
			}
		}
	}
	return file;
}
开发者ID:BackupTheBerlios,项目名称:escript-svn,代码行数:20,代码来源:StdLib.cpp

示例14: findFile

/*! Tries to locate the given __filename__ with the current searchPath set in the runtime.
	@return the path to the file or the original __filename__ if the file could not be found.	*/
static std::string findFile(Runtime & runtime, const std::string & filename){
	static const identifierId seachPathsId=stringToIdentifierId("__searchPaths");

	std::string file(FileUtils::condensePath(filename));
	if( FileUtils::isFile(file)!=1 ){
		if(Array * searchPaths = dynamic_cast<Array*>(runtime.getAttribute(seachPathsId))){
			for(ERef<Iterator> itRef=searchPaths->getIterator();!itRef->end();itRef->next()){
				ObjRef valueRef = itRef->value();
				std::string s(FileUtils::condensePath(valueRef.toString()+"/"+filename));
				if( FileUtils::isFile(s)==1 ){
					file = s;
					break;
				}
			}
		}
	}
	return file;
}
开发者ID:BackupTheBerlios,项目名称:escript-svn,代码行数:20,代码来源:StdLib.cpp

示例15: CreateCellMLBootstrap

bool CellmlFile::doLoad(const QString &pFileName, const QString &pFileContents,
                        ObjRef<iface::cellml_api::Model> *pModel,
                        CellmlFileIssues &pIssues)
{
    // Make sure that pIssues is empty

    pIssues.clear();

    // Get a bootstrap object and its model loader

    ObjRef<iface::cellml_api::CellMLBootstrap> cellmlBootstrap = CreateCellMLBootstrap();
    ObjRef<iface::cellml_api::DOMModelLoader> modelLoader = cellmlBootstrap->modelLoader();

    // Try to create the model

    try {
        if (pFileContents.isEmpty())
            *pModel = modelLoader->loadFromURL(QUrl::fromPercentEncoding(QUrl::fromLocalFile(pFileName).toEncoded()).toStdWString());
        else
            *pModel = modelLoader->createFromText(pFileContents.toStdWString());
    } catch (iface::cellml_api::CellMLException &exception) {
        // Something went wrong with the loading of the model

        if (pFileContents.isEmpty()) {
            pIssues << CellmlFileIssue(CellmlFileIssue::Error,
                                       QObject::tr("the model could not be loaded (%1)").arg(Core::formatMessage(QString::fromStdWString(exception.explanation))));
        } else {
            pIssues << CellmlFileIssue(CellmlFileIssue::Error,
                                       QObject::tr("the model could not be created (%1)").arg(Core::formatMessage(QString::fromStdWString(exception.explanation))));
        }

        return false;
    }

    // Update the base URI, should the CellML file be a remote one or its
    // contents be directly passed onto us

    Core::FileManager *fileManagerInstance = Core::FileManager::instance();
    ObjRef<iface::cellml_api::URI> baseUri = (*pModel)->xmlBase();

    if (fileManagerInstance->isRemote(pFileName)) {
        // We are dealing with a remote file, so its XML base value should point
        // to its remote location

        baseUri->asText(fileManagerInstance->url(pFileName).toStdWString());
    } else if (!pFileContents.isEmpty()) {
        // We are dealing with a file which contents was directly passed onto
        // us, so its XML base value should point to its actual location

        baseUri->asText(pFileName.toStdWString());
    }

    return true;
}
开发者ID:hsorby,项目名称:opencor,代码行数:54,代码来源:cellmlfile.cpp


注:本文中的ObjRef类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。