PageRenderTime 39ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/lscript/llscriptresource.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 69 lines | 19 code | 12 blank | 38 comment | 0 complexity | 4f18d7be87fa9ae191b98047e57846d6 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llscriptresource.h
  3. * @brief LLScriptResource class definition
  4. *
  5. * $LicenseInfo:firstyear=2008&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLSCRIPTRESOURCE_H
  27. #define LL_LLSCRIPTRESOURCE_H
  28. #include "stdtypes.h"
  29. // An LLScriptResource is a limited resource per ID.
  30. class LLScriptResource
  31. {
  32. public:
  33. LLScriptResource();
  34. // If amount resources are available will mark amount resouces
  35. // used and returns true
  36. // Otherwise returns false and doesn't mark any resources used.
  37. bool request(S32 amount = 1);
  38. // Release amount resources from use if at least amount resources are used and return true
  39. // If amount is more than currently used no resources are released and return false
  40. bool release(S32 amount = 1);
  41. // Returns how many resources are available
  42. S32 getAvailable() const;
  43. // Sets the total amount of available resources
  44. // It is possible to set the amount to less than currently used
  45. // Most likely to happen on parcel ownership change
  46. void setTotal(S32 amount);
  47. // Get the total amount of available resources
  48. S32 getTotal() const;
  49. // Get the number of resources used
  50. S32 getUsed() const;
  51. // true if more resources used than total available
  52. bool isOverLimit() const;
  53. private:
  54. S32 mTotal; // How many resources have been set aside
  55. S32 mUsed; // How many resources are currently in use
  56. };
  57. #endif // LL_LLSCRIPTRESOURCE_H