HatchitResource
ht_resource.h
1 
15 #pragma once
16 
17 #include <ht_platform.h>
18 #include <ht_noncopy.h>
19 #include <ht_refcounted.h>
20 #include <ht_singleton.h>
21 #include <ht_file.h>
22 #include <map>
23 #include <unordered_map>
24 #include <type_traits>
25 #include <ht_path_singleton.h>
26 #include <ht_jsonhelper.h>
27 #include <fstream>
28 #include <utility>
29 
30 namespace Hatchit
31 {
32  namespace Resource
33  {
34  template<typename ResourceType>
35  class HT_API FileResource : public Core::RefCounted<ResourceType>
36  {
37  public:
38  virtual ~FileResource() { };
39 
40  template<typename... Args>
41  static Core::Handle<const ResourceType> GetHandle(const std::string& ID, Args&&... args)
42  {
43  Core::Handle<ResourceType> handle = Core::RefCounted<ResourceType>::GetHandle(ID, std::forward<Args>(args)...);
44  if (handle.IsValid() /*&& handle->VInitFromFile(ID)*/)
45  return handle.template StaticCastHandle<const ResourceType>();
46  else
47  return Core::Handle<const ResourceType>();
48  }
49 
50  static Core::Handle<const ResourceType> GetHandleFromFileName(const std::string& fileName);
51 
52  protected:
53  FileResource(Core::Guid ID);
54  };
55  }
56 }
57 
58 /*
59  Here's how the classes are going to be structured for resources:
60  Resource<T> is the base class for all resources that have to be loaded / generated
61  T is going to be the actual implementation of the data.
62  Then we create a TPtr alias that is equivalent to Resource<T>::Handle
63 */
64 
65 #include <ht_resource.inl>
Definition: ht_resource.h:35
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Definition: ht_assimp.h:31