10 #ifndef SAVELOAD_FILTER_H
11 #define SAVELOAD_FILTER_H
16 std::shared_ptr<LoadFilter>
chain;
37 virtual size_t Read(uint8_t *buf,
size_t len) = 0;
53 template <
typename T> std::shared_ptr<LoadFilter>
CreateLoadFilter(std::shared_ptr<LoadFilter> chain)
55 return std::make_shared<T>(chain);
61 std::shared_ptr<SaveFilter>
chain;
81 virtual void Write(uint8_t *buf,
size_t len) = 0;
88 if (this->chain !=
nullptr) this->chain->Finish();
98 template <
typename T> std::shared_ptr<SaveFilter>
CreateSaveFilter(std::shared_ptr<SaveFilter> chain, uint8_t compression_level)
100 return std::make_shared<T>(chain, compression_level);
std::shared_ptr< SaveFilter > CreateSaveFilter(std::shared_ptr< SaveFilter > chain, uint8_t compression_level)
Instantiator for a save filter.
std::shared_ptr< LoadFilter > CreateLoadFilter(std::shared_ptr< LoadFilter > chain)
Instantiator for a load filter.
Interface for filtering a savegame till it is loaded.
virtual size_t Read(uint8_t *buf, size_t len)=0
Read a given number of bytes from the savegame.
virtual ~LoadFilter()
Make sure the writers are properly closed.
virtual void Reset()
Reset this filter to read from the beginning of the file.
std::shared_ptr< LoadFilter > chain
Chained to the (savegame) filters.
LoadFilter(std::shared_ptr< LoadFilter > chain)
Initialise this filter.
Interface for filtering a savegame till it is written.
virtual void Write(uint8_t *buf, size_t len)=0
Write a given number of bytes into the savegame.
virtual ~SaveFilter()
Make sure the writers are properly closed.
virtual void Finish()
Prepare everything to finish writing the savegame.
SaveFilter(std::shared_ptr< SaveFilter > chain)
Initialise this filter.
std::shared_ptr< SaveFilter > chain
Chained to the (savegame) filters.