Ocular Engine
ResourceSaverRegistrar.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_RESOURCES_RESOURCE_SAVER_REGISTRAR__H__
19 #define __H__OCULAR_RESOURCES_RESOURCE_SAVER_REGISTRAR__H__
20 
21 #include "Resource.hpp"
22 #include "OcularEngine.hpp"
23 
24 #include <memory>
25 #include <iostream>
26 
27 //------------------------------------------------------------------------------------------
28 
33 namespace Ocular
34 {
39  namespace Core
40  {
44  template<class T>
46  {
47  public:
48 
50  {
51  T* t = new T();
52  AResourceSaver* saver = dynamic_cast<AResourceSaver*>(t);
53 
54  if(saver != nullptr)
55  {
56  std::shared_ptr<AResourceSaver> shared(saver);
57  OcularEngine.ResourceManager()->registerResourceSaver(shared);
58  }
59  else
60  {
61  delete t;
62  t = nullptr;
63  }
64  }
65 
66  protected:
67 
68  private:
69  };
70  }
74 }
79 #define OCULAR_REGISTER_RESOURCE_SAVER(T) Ocular::Core::ResourceSaverRegistrar<T> OCULAR_INTERNAL_RegisterResourceSaver;
81 
82 //------------------------------------------------------------------------------------------
83 
84 #endif
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
Definition: ResourceSaverRegistrar.hpp:45
Definition: ResourceSaver.hpp:49