Crossfire Server, Trunk
AssetCollector Class Reference

#include <AssetCollector.h>

+ Inheritance diagram for AssetCollector:
+ Collaboration diagram for AssetCollector:

Public Member Functions

void addLoader (AssetLoader *loader)
 
 AssetCollector ()
 
void collect (const std::string &directory)
 
virtual void load (BufferReader *reader, const std::string &filename) override
 
virtual bool willLoad (const std::string &) override
 
virtual ~AssetCollector ()
 
- Public Member Functions inherited from AssetLoader
virtual ~AssetLoader ()
 

Protected Member Functions

void processFiles (const std::vector< std::string > &files)
 

Protected Attributes

std::vector< AssetLoader * > m_loaders
 
BufferReaderm_reader
 

Detailed Description

Assets collector, recursing in directories and calling loaders on found files. It inherits AssetLoader to be used with TarLoader.

Definition at line 24 of file AssetCollector.h.

Constructor & Destructor Documentation

◆ AssetCollector()

AssetCollector::AssetCollector ( )

Constructor.

Definition at line 29 of file AssetCollector.cpp.

References bufferreader_create(), and m_reader.

+ Here is the call graph for this function:

◆ ~AssetCollector()

AssetCollector::~AssetCollector ( )
virtual

Destructor.

Definition at line 33 of file AssetCollector.cpp.

References bufferreader_destroy(), m_loaders, and m_reader.

+ Here is the call graph for this function:

Member Function Documentation

◆ addLoader()

void AssetCollector::addLoader ( AssetLoader loader)
inline

Register a loader to be called on found files. Ownership of the loader is taken by the AssetCollector.

Parameters
loaderinstance to register.

Definition at line 40 of file AssetCollector.h.

References m_loaders.

Referenced by assets_collect().

+ Here is the caller graph for this function:

◆ collect()

void AssetCollector::collect ( const std::string &  directory)

Recurse in the specified directory, finding all files and calling loaders to process them.

Parameters
directorystarting path, with or without a trailing slash.

Definition at line 54 of file AssetCollector.cpp.

References closedir(), names, opendir(), processFiles(), readdir(), is_valid_types_gen::type, and nlohmann::detail::void().

Referenced by assets_collect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

void AssetCollector::load ( BufferReader reader,
const std::string &  filename 
)
overridevirtual

Load assets from the specified reader.

Parameters
readerreader.
filenamefull filename.

Implements AssetLoader.

Definition at line 91 of file AssetCollector.cpp.

References npc_dialog::filename, and m_loaders.

◆ processFiles()

void AssetCollector::processFiles ( const std::vector< std::string > &  files)
protected

Process a list of files.

Parameters
filesfull path of files to process.

Definition at line 40 of file AssetCollector.cpp.

References bufferreader_init_from_file(), mad_mage_user::file, llevError, m_loaders, and m_reader.

Referenced by collect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ willLoad()

virtual bool AssetCollector::willLoad ( const std::string &  filename)
inlineoverridevirtual

Whether this instance will process or not the specified file.

Parameters
filenamefull file path.
Returns
true if processFile() should be called, false else.

Implements AssetLoader.

Definition at line 48 of file AssetCollector.h.

Field Documentation

◆ m_loaders

std::vector<AssetLoader *> AssetCollector::m_loaders
protected

Registered loaders.

Definition at line 55 of file AssetCollector.h.

Referenced by addLoader(), load(), processFiles(), and ~AssetCollector().

◆ m_reader

BufferReader* AssetCollector::m_reader
protected

Reader used to load files.

Definition at line 56 of file AssetCollector.h.

Referenced by AssetCollector(), processFiles(), and ~AssetCollector().


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