Peoplemon  0.1.0
Peoplemon 3 game source documentation
BundleHandlers.hpp
Go to the documentation of this file.
1 #ifndef CORE_RESOURCES_BUNDLEHANDLERS_HPP
2 #define CORE_RESOURCES_BUNDLEHANDLERS_HPP
3 
4 #include <BLIB/Logging.hpp>
5 #include <BLIB/Resources.hpp>
6 
7 namespace core
8 {
9 namespace res
10 {
18 template<typename T>
19 struct PeoplemonBundleHandler : public bl::resource::bundle::FileHandler {
28  virtual bool processFile(const std::string& path, std::ostream& output,
29  bl::resource::bundle::FileHandlerContext& context) override {
30  T obj;
31  if (!bl::resource::ResourceManager<T>::initializeExisting(path, obj)) {
32  BL_LOG_ERROR << "Failed to process: " << path;
33  return false;
34  }
35  bl::serial::StreamOutputBuffer wrapper(output);
36  bl::serial::binary::OutputStream os(wrapper);
37  if (!obj.saveBundle(os, context)) {
38  BL_LOG_ERROR << "Failed to serialize '" << path << "' into bundle";
39  return false;
40  }
41  return true;
42  }
43 };
44 
45 } // namespace res
46 } // namespace core
47 
48 #endif
Core classes and functionality for both the editor and game.
Generic handler for peoplemon files when being bundled. Performs format conversion and registers depe...
virtual bool processFile(const std::string &path, std::ostream &output, bl::resource::bundle::FileHandlerContext &context) override
Processes the given resource file to bundle.