Public Member Functions | Protected Member Functions | Private Attributes | List of all members
SurgSim::Framework::Asset Class Referenceabstract

This class is used to facilitate file loading. More...

#include <SurgSim/Framework/Asset.h>

Inheritance diagram for SurgSim::Framework::Asset:
SurgSim::DataStructures::OctreeNode< Data > SurgSim::DataStructures::TriangleMesh SurgSim::Math::MeshShape SurgSim::Math::OctreeShape

Public Member Functions

 Asset ()
 Constructor. More...
 
virtual ~Asset ()
 Destructor. More...
 
void load (const std::string &fileName, const SurgSim::Framework::ApplicationData &data)
 Load a file with given name using 'data' as look up path(s). More...
 
void load (const std::string &fileName)
 Overloaded function using SurgSim::Framework::Runtime::getApplicationData() as look up path(s). More...
 
std::string getFileName () const
 Return the name of file loaded by this class. More...
 

Protected Member Functions

virtual bool doLoad (const std::string &filePath)=0
 Derived classes will overwrite this method to do actual loading. More...
 
void serializeFileName (SurgSim::Framework::Accessible *accessible)
 Derived classes (which also inherit from SurgSim::Framework::Accessible) should call this function with 'this' pointer as the parameter in their constructors to register file name property for serialization. More...
 

Private Attributes

friend AssetTest
 
std::string m_fileName
 Name of the file to be loaded. More...
 

Detailed Description

This class is used to facilitate file loading.

It uses the static ApplicationData in SurgSim::Framework::Runtime to load file. Classes not in SurgSim::Framework::Component hierarchy should inherit this class in order to load a file.

Constructor & Destructor Documentation

SurgSim::Framework::Asset::Asset ( )

Constructor.

SurgSim::Framework::Asset::~Asset ( )
virtual

Destructor.

Member Function Documentation

virtual bool SurgSim::Framework::Asset::doLoad ( const std::string &  filePath)
protectedpure virtual

Derived classes will overwrite this method to do actual loading.

Note
This method is not required to do any check on the validity or the existence of the file.
Parameters
filePathAbsolute path to the file.
Returns
True if loading is successful; Otherwise, false.

Implemented in SurgSim::DataStructures::OctreeNode< Data >, SurgSim::Math::MeshShape, SurgSim::DataStructures::TriangleMesh, and SurgSim::Math::OctreeShape.

std::string SurgSim::Framework::Asset::getFileName ( ) const

Return the name of file loaded by this class.

Returns
Name of the file loaded by this class.
void SurgSim::Framework::Asset::load ( const std::string &  fileName,
const SurgSim::Framework::ApplicationData data 
)

Load a file with given name using 'data' as look up path(s).

If 'fileName' is not empty and the file is found, this method calls 'doLoad()' to load the file. Assertions will fail if 'fileName' is empty or file is not found or file loading is unsuccessful.

Note
As a side effect, the name of the file will be recorded in
Asset::m_fileName and can be retrieved by Asset::getFileName().
Parameters
fileNameName of the file to be loaded.
dataApplicationData which provides the runtime look up path(s).
void SurgSim::Framework::Asset::load ( const std::string &  fileName)

Overloaded function using SurgSim::Framework::Runtime::getApplicationData() as look up path(s).

Parameters
fileNameName of the file to be loaded.
void SurgSim::Framework::Asset::serializeFileName ( SurgSim::Framework::Accessible accessible)
protected

Derived classes (which also inherit from SurgSim::Framework::Accessible) should call this function with 'this' pointer as the parameter in their constructors to register file name property for serialization.

Parameters
accessible'this' pointer of derived class.

Member Data Documentation

friend SurgSim::Framework::Asset::AssetTest
private
std::string SurgSim::Framework::Asset::m_fileName
private

Name of the file to be loaded.


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