Potato Engine
Loading...
Searching...
No Matches
Archivable.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include <unordered_map>
5#include <functional>
6
13#define ARCHIVE_STATIC(type) \
14static struct __##type##_Register { \
15 __##type##_Register() { \
16 __Archive::_GetArchive()[#type] = []() -> Archivable* { return new type(); }; \
17 } \
18} __##type##_register;
19
27class Archivable
28{
29public:
30 Archivable() = default;
31 virtual ~Archivable() = default;
32};
33
34using __ArchiveType = std::unordered_map< std::string, std::function<Archivable*()> >;
35
36namespace __Archive {
37 inline __ArchiveType& _GetArchive(){
38 static __ArchiveType archive;
39 return archive;
40 }
41}
Abstract factory class inherited by all classes that should be archived.