ResourceCache.pkg 2.1 KB

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