Crossfire Server  1.75.0
AssetCollector.h
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2020-2021 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #ifndef ASSETCOLLECTOR_H
14 #define ASSETCOLLECTOR_H
15 
16 #include <vector>
17 #include "AssetLoader.h"
18 
23 class AssetCollector : public AssetLoader {
24 public:
32  virtual ~AssetCollector();
33 
39  void addLoader(AssetLoader *loader) { m_loaders.push_back(loader); }
40 
45  void collect(const std::string& directory);
46 
47  virtual bool willLoad(const std::string &) override {
48  return true;
49  };
50 
51  virtual void load(BufferReader *reader, const std::string &filename) override;
52 
53 protected:
54  std::vector<AssetLoader *> m_loaders;
61  void processFiles(const std::vector<std::string> &files);
62 };
63 
64 #endif /* ASSETCOLLECTOR_H */
65 
void processFiles(const std::vector< std::string > &files)
Process a list of files.
Assets collector, recursing in directories and calling loaders on found files.
void collect(const std::string &directory)
Recurse in the specified directory, finding all files and calling loaders to process them...
BufferReader * m_reader
Reader used to load files.
virtual void load(BufferReader *reader, const std::string &filename) override
Load assets from the specified reader.
virtual ~AssetCollector()
Destructor.
void addLoader(AssetLoader *loader)
Register a loader to be called on found files.
AssetCollector()
Constructor.
virtual bool willLoad(const std::string &) override
Whether this instance will process or not the specified file.
std::vector< AssetLoader * > m_loaders
Registered loaders.
Abstract buffer handler, processing a BufferReader.
Definition: AssetLoader.h:24