All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
InteriorsTextureResourceService.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Interiors.h"
6 #include "IInteriorsTextureResourceService.h"
7 #include "Types.h"
8 #include "Rendering.h"
9 #include <map>
10 #include <string>
11 #include <set>
12 
13 namespace Eegeo
14 {
15  namespace Resources
16  {
17  namespace Interiors
18  {
20  {
21  public:
23  IInteriorsCubeTextureResourceBuilder& interiorsCubeTextureResourceBuilder);
24 
26 
27  virtual IInteriorsTextureResource* Create(const std::string& textureName, bool local);
28  virtual IInteriorsTextureResource* CreateFromCubeMapFaces(const Helpers::CubeTextureName& textureName, bool local);
29  virtual void AddWeakTextureReference(const std::string& textureName, bool cube, bool local);
30  virtual void Destroy(const std::string& textureName);
31  virtual void RemoveTextureReferencesForInterior(const std::string& interiorIdentifier);
32  virtual bool Contains(const std::string& textureName) const;
33  virtual IInteriorsTextureResource* Get(const std::string& interiorIdentifier,
34  const std::string& textureName,
35  bool isCube);
36 
37  private:
38  void DestroyAll();
39  bool ContainsWeakTextureReference(const std::string& textureName) const;
40  bool ContainsStrongTextureReference(const std::string& textureName) const;
41  void CreateInstanceOfWeakTexture(const std::string& textureName);
42 
43  IInteriorsTextureResourceBuilder& m_interiorsTextureResourceBuilder;
44  IInteriorsCubeTextureResourceBuilder& m_interiorsCubeTextureResourceBuilder;
45 
46  typedef std::pair<int, IInteriorsTextureResource*> TRefCountedTextureResource;
47  typedef std::map<std::string, TRefCountedTextureResource> TNameToRefCountedTextureResource;
48 
49  TNameToRefCountedTextureResource m_nameToRefCountedTextureResource;
50 
51  struct WeakTextureInfo
52  {
53  bool IsCube;
54  bool IsLocal;
55 
56  WeakTextureInfo(bool isCube, bool isLocal):IsCube(isCube),IsLocal(isLocal) { }
57  };
58 
59  typedef std::map<std::string, WeakTextureInfo> TWeakTexturesByName;
60  TWeakTexturesByName m_weakTexturesByName;
61 
62  typedef std::set<std::string> TInteriorsReferencingTexture;
63  typedef std::map<std::string, TInteriorsReferencingTexture> TTexturesReferencedByInterior;
64  TTexturesReferencedByInterior m_textureToReferencingInteriors;
65  };
66  }
67  }
68 }