示例#1
0
int CellmlModelDefinition::loadModel(const std::string &url)
{
    std::cout << "Creating CellML Model Definition from the URL: "
              << url << std::endl;
    mUrl = url;
    if (mUrl.empty()) return -1;
    std::wstring urlW = s2ws(url);
    ObjRef<iface::cellml_api::CellMLBootstrap> cb = CreateCellMLBootstrap();
    ObjRef<iface::cellml_api::DOMModelLoader> ml = cb->modelLoader();
    int code;
    try
    {
        ObjRef<iface::cellml_api::Model> model = ml->loadFromURL(urlW);
        model->fullyInstantiateImports();
        // we have a model, so we can start grabbing hold of the CellML API objects
        mCapi = new CellmlApiObjects();
        mCapi->model = model;
        code = instantiateCellmlApiObjects();
    }
    catch (...)
    {
      std::wcerr << L"Error loading model: " << urlW << std::endl;
      return -1;
    }
    return code;
}
示例#2
0
int CellmlModelDefinition::loadModelFromString(const std::string &ms)
{
    std::cout << "Creating CellML Model Definition from the given model string"
              << std::endl;
    mUrl = "";
    std::wstring msW = s2ws(ms);
    ObjRef<iface::cellml_api::CellMLBootstrap> cb = CreateCellMLBootstrap();
    ObjRef<iface::cellml_api::DOMModelLoader> ml = cb->modelLoader();
    int code;
    try
    {
        ObjRef<iface::cellml_api::Model> model = ml->createFromText(msW);
        model->fullyInstantiateImports();
        // we have a model, so we can start grabbing hold of the CellML API objects
        mCapi = new CellmlApiObjects();
        mCapi->model = model;
        code = instantiateCellmlApiObjects();
    }
    catch (...)
    {
      std::wcerr << L"Error loading model from string." << std::endl;
      return -1;
    }
    return code;
}