Ocular Engine
Ocular::Core::ResourceExplorer Class Reference

#include <ResourceExplorer.hpp>

Public Member Functions

void setBlacklist (std::list< std::string > const &blacklist)
 
void setResourceDirectoryName (std::string const &name)
 
std::string const & getResourceDirectoryName () const
 
void setIsExtensionSensitive (bool sensitive)
 
void populateFileMap (std::unordered_map< std::string, File > &fileMap, ResourceLoaderManager *loader)
 
std::string getRelativePath (File const &file)
 

Protected Member Functions

bool isBlacklisted (std::string const &extension)
 
void findRootDirectories (std::list< Directory > &rootDirectories)
 
std::string getRelativePathFromResourceRoot (Directory root, File file)
 

Detailed Description

Searches for resource folders and explores them for valid resource files.

Member Function Documentation

void Ocular::Core::ResourceExplorer::findRootDirectories ( std::list< Directory > &  rootDirectories)
protected

Finds all root directories to explore for resource files.

Parameters
[out]rootDirectories
std::string Ocular::Core::ResourceExplorer::getRelativePath ( File const &  file)

Retrieves the relative path, if it exists, of the file from the Resource directory.

std::string Ocular::Core::ResourceExplorer::getRelativePathFromResourceRoot ( Directory  root,
File  file 
)
protected

Composes the relative path from the root directory to the file.

Example:

Dir:  /path/to/Resources
File: /path/to/Resources/Textures/Grass.png
Rel:  Textures/Grass

The returned path is formatted to be used as a resource map key.

Parameters
[in]rootThe root resource directory that contains the file
[in]fileThe resource file
Returns
The relative path from the root to the file
bool Ocular::Core::ResourceExplorer::isBlacklisted ( std::string const &  extension)
protected
Returns
TRUE if the extension is blacklisted.
void Ocular::Core::ResourceExplorer::populateFileMap ( std::unordered_map< std::string, File > &  fileMap,
ResourceLoaderManager loader 
)
Parameters
[out]resourceMapMap of all resource files.
void Ocular::Core::ResourceExplorer::setBlacklist ( std::list< std::string > const &  blacklist)

Sets the blacklist for the explorer.

Parameters
[in]blacklistContainer with all of the file extensions (including the '.') to add to the blacklist.
Note
populateResourceMap will need to be called to update entries with new blacklist
void Ocular::Core::ResourceExplorer::setIsExtensionSensitive ( bool  sensitive)

If extension-sensitive, then map keys will include the file extension.

Example:

/path/to/Resources/Textures/Grass.png

Sensitive Key:   Textures/Grass.png
Insensitive Key: Textures/Grass

Default behaviour is insensitive keys.

Parameters
[in]sensitive
Note
populateResourceMap will need to be called to update keys for new sensitivity.
void Ocular::Core::ResourceExplorer::setResourceDirectoryName ( std::string const &  name)
Parameters
[in]nameName of root directories that contain resource files.
Note
populateResourceMap will need to be called to update entries with new directories

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