Chaste  Release::2017.1
CellMLToSharedLibraryConverter Class Reference

#include <CellMLToSharedLibraryConverter.hpp>

+ Collaboration diagram for CellMLToSharedLibraryConverter:

Public Member Functions

 CellMLToSharedLibraryConverter (bool preserveGeneratedSources=false, std::string component="heart")
 
DynamicCellModelLoaderPtr Convert (const FileFinder &rFilePath, bool isCollective=true)
 

Static Public Member Functions

static void CreateOptionsFile (const OutputFileHandler &rHandler, const std::string &rModelName, const std::vector< std::string > &rArgs, const std::string &rExtraXml="")
 

Private Member Functions

void ConvertCellmlToSo (const std::string &rCellmlFullPath, const std::string &rCellmlFolder)
 

Private Attributes

bool mPreserveGeneratedSources
 
std::string mComponentName
 

Static Private Attributes

static const std::string msSoSuffix = "so"
 

Friends

class TestDynamicallyLoadedCellModels
 

Detailed Description

This class encapsulates all the complexity needed to generate a loadable module from a CellML file.

Definition at line 50 of file CellMLToSharedLibraryConverter.hpp.

Constructor & Destructor Documentation

CellMLToSharedLibraryConverter::CellMLToSharedLibraryConverter ( bool  preserveGeneratedSources = false,
std::string  component = "heart" 
)

Create a converter.

Parameters
preserveGeneratedSourceswhether to save copies of generated C++ source files in the directory containing the .cellml file.
componentthe name of the Chaste component (or project) in which to build the loadable module (if required). Allows projects to have specialised base classes for dynamically loaded cell models.

Definition at line 69 of file CellMLToSharedLibraryConverter.cpp.

Member Function Documentation

DynamicCellModelLoaderPtr CellMLToSharedLibraryConverter::Convert ( const FileFinder rFilePath,
bool  isCollective = true 
)
Returns
a loadable module from the given file, and return a loader for it. The file can be a .so, in which case there isn't much to do, just create the loader. The interesting case comes when it is a .cellml file. If the file has any other extension, an exception is thrown.
Parameters
rFilePaththe model to load
isCollectivewhether this method is being called collectively. If it is not, then we require the .so to already exist, rather than trying to avoid race conditions.
Note
If you do not pass isCollective=false, must be called collectively.

Definition at line 76 of file CellMLToSharedLibraryConverter.cpp.

References RelativeTo::Absolute, ConvertCellmlToSo(), EXCEPTION, FileFinder::Exists(), FileFinder::GetAbsolutePath(), DynamicModelLoaderRegistry::GetLoader(), DynamicModelLoaderRegistry::Instance(), FileFinder::IsNewerThan(), msSoSuffix, and FileFinder::SetPath().

Referenced by HeartConfigRelatedCellFactory< SPACE_DIM >::LoadDynamicModel().

void CellMLToSharedLibraryConverter::ConvertCellmlToSo ( const std::string &  rCellmlFullPath,
const std::string &  rCellmlFolder 
)
private
void CellMLToSharedLibraryConverter::CreateOptionsFile ( const OutputFileHandler rHandler,
const std::string &  rModelName,
const std::vector< std::string > &  rArgs,
const std::string &  rExtraXml = "" 
)
static

Create a PyCml options file for the given model.

Parameters
rHandlerwhere to create the file
rModelNamebase name of the model file (which will be "rModelName.cellml")
rArgsextra command-line arguments for the model conversion
rExtraXmlany extra XML to go in the config file (e.g. LT settings)

Definition at line 276 of file CellMLToSharedLibraryConverter.cpp.

References PetscTools::AmMaster(), PetscTools::Barrier(), and OutputFileHandler::OpenOutputFile().

Friends And Related Function Documentation

friend class TestDynamicallyLoadedCellModels
friend

Test gets access to the msSoSuffix variable

Definition at line 54 of file CellMLToSharedLibraryConverter.hpp.

Member Data Documentation

std::string CellMLToSharedLibraryConverter::mComponentName
private

Which component to build the loadable module in.

Definition at line 112 of file CellMLToSharedLibraryConverter.hpp.

Referenced by ConvertCellmlToSo().

bool CellMLToSharedLibraryConverter::mPreserveGeneratedSources
private

Whether to save copies of generated C++ source files.

Definition at line 109 of file CellMLToSharedLibraryConverter.hpp.

Referenced by ConvertCellmlToSo().

const std::string CellMLToSharedLibraryConverter::msSoSuffix = "so"
staticprivate

The .so suffix is nearly always "so" (as you might expect). On Mac OSX this is redefined to "dylib"

Set the .so suffix

Definition at line 115 of file CellMLToSharedLibraryConverter.hpp.

Referenced by Convert(), and ConvertCellmlToSo().


The documentation for this class was generated from the following files: