Ocular Engine
ResourceLoaderRegistrar.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_RESOURCES_RESOURCE_LOADER_REGISTRAR__H__
19 #define __H__OCULAR_RESOURCES_RESOURCE_LOADER_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  AResourceLoader* loader = dynamic_cast<AResourceLoader*>(t);
53 
54  if(loader != nullptr)
55  {
56  std::shared_ptr<AResourceLoader> shared(loader);
57  OcularEngine.ResourceManager()->registerResourceLoader(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_LOADER(T) Ocular::Core::ResourceLoaderRegistrar<T> OCULAR_INTERNAL_RegisterResourceLoader;
81 
82 //------------------------------------------------------------------------------------------
83 
84 #endif
Definition: ResourceLoader.hpp:55
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
Definition: ResourceLoaderRegistrar.hpp:45