ResourceCache.pkg 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. $#include "ResourceCache.h"
  2. class ResourceCache
  3. {
  4. void ReleaseAllResources(bool force = false);
  5. bool ReloadResource(Resource* resource);
  6. void SetMemoryBudget(ShortStringHash type, unsigned budget);
  7. void SetMemoryBudget(const String type, unsigned budget);
  8. void SetAutoReloadResources(bool enable);
  9. void SetSearchPackagesFirst(bool value);
  10. Resource* GetResource(const String type, const String name);
  11. bool Exists(const String name) const;
  12. unsigned GetMemoryBudget(ShortStringHash type) const;
  13. unsigned GetMemoryUse(ShortStringHash type) const;
  14. unsigned GetTotalMemoryUse() const;
  15. String GetResourceFileName(const String name) const;
  16. bool GetAutoReloadResources() const;
  17. bool GetSearchPackagesFirst() const;
  18. tolua_readonly tolua_property__get_set unsigned totalMemoryUse;
  19. tolua_readonly tolua_property__get_set bool autoReloadResources;
  20. tolua_readonly tolua_property__get_set bool searchPackagesFirst;
  21. };
  22. ${
  23. // Disable generated GetResource function.
  24. #define TOLUA_DISABLE_tolua_ResourceLuaAPI_ResourceCache_GetResource00
  25. static int tolua_ResourceLuaAPI_ResourceCache_GetResource00(lua_State* tolua_S)
  26. {
  27. #ifndef TOLUA_RELEASE
  28. tolua_Error tolua_err;
  29. if (
  30. !tolua_isusertype(tolua_S,1,"ResourceCache",0,&tolua_err) ||
  31. !tolua_isurho3dstring(tolua_S,2,0,&tolua_err) ||
  32. !tolua_isurho3dstring(tolua_S,3,0,&tolua_err) ||
  33. !tolua_isnoobj(tolua_S,4,&tolua_err)
  34. )
  35. goto tolua_lerror;
  36. else
  37. #endif
  38. {
  39. ResourceCache* self = (ResourceCache*) tolua_tousertype(tolua_S,1,0);
  40. const String type = ((const String) tolua_tourho3dstring(tolua_S,2,0));
  41. const String name = ((const String) tolua_tourho3dstring(tolua_S,3,0));
  42. #ifndef TOLUA_RELEASE
  43. if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetResource'", NULL);
  44. #endif
  45. {
  46. Resource* tolua_ret = (Resource*) self->GetResource(type,name);
  47. tolua_pushusertype(tolua_S,(void*)tolua_ret,type.CString());
  48. }
  49. }
  50. return 1;
  51. #ifndef TOLUA_RELEASE
  52. tolua_lerror:
  53. tolua_error(tolua_S,"#ferror in function 'GetResource'.",&tolua_err);
  54. return 0;
  55. #endif
  56. }
  57. $}