ResourceCache.pkg 2.0 KB

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