Crossfire Server, Trunk  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 
AssetCollector::load
virtual void load(BufferReader *reader, const std::string &filename) override
Load assets from the specified reader.
Definition: AssetCollector.cpp:91
AssetCollector::willLoad
virtual bool willLoad(const std::string &) override
Whether this instance will process or not the specified file.
Definition: AssetCollector.h:47
AssetLoader
Abstract buffer handler, processing a BufferReader.
Definition: AssetLoader.h:24
AssetCollector::m_loaders
std::vector< AssetLoader * > m_loaders
Registered loaders.
Definition: AssetCollector.h:54
AssetCollector::collect
void collect(const std::string &directory)
Recurse in the specified directory, finding all files and calling loaders to process them.
Definition: AssetCollector.cpp:54
AssetCollector::m_reader
BufferReader * m_reader
Reader used to load files.
Definition: AssetCollector.h:55
AssetCollector::AssetCollector
AssetCollector()
Constructor.
Definition: AssetCollector.cpp:29
files
the server will also quite happily load unpacked files as long as they have the right file which is convenient if you want to edit your maps and archetypes live It also contains a few files
Definition: server-directories.txt:53
AssetCollector::processFiles
void processFiles(const std::vector< std::string > &files)
Process a list of files.
Definition: AssetCollector.cpp:40
AssetCollector::addLoader
void addLoader(AssetLoader *loader)
Register a loader to be called on found files.
Definition: AssetCollector.h:39
AssetCollector::~AssetCollector
virtual ~AssetCollector()
Destructor.
Definition: AssetCollector.cpp:33
AssetCollector
Assets collector, recursing in directories and calling loaders on found files.
Definition: AssetCollector.h:23
BufferReader
Definition: bufferreader.cpp:21
AssetLoader.h