CCAllocatorDiagnostics.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /****************************************************************************
  2. Copyright (c) 2014-2017 Chukong Technologies Inc.
  3. Author: Justin Graham (https://github.com/mannewalis)
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef CC_ALLOCATOR_DIAGNOSTICS_H
  22. #define CC_ALLOCATOR_DIAGNOSTICS_H
  23. /// @cond DO_NOT_SHOW
  24. #include <unordered_set>
  25. #include "base/allocator/CCAllocatorMacros.h"
  26. #include "base/allocator/CCAllocatorMutex.h"
  27. #include "base/allocator/CCAllocatorBase.h"
  28. NS_CC_BEGIN
  29. NS_CC_ALLOCATOR_BEGIN
  30. #if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
  31. class AllocatorBase;
  32. class AllocatorDiagnostics
  33. {
  34. public:
  35. AllocatorDiagnostics();
  36. static AllocatorDiagnostics* instance();
  37. void trackAllocator(AllocatorBase* allocator);
  38. void untrackAllocator(AllocatorBase* allocator);
  39. std::string diagnostics();
  40. protected:
  41. AllocatorMutex _mutex;
  42. AllocatorBase* _allocators;
  43. };
  44. #endif//CC_ENABLE_ALLOCATOR_DIAGNOSTICS
  45. NS_CC_ALLOCATOR_END
  46. NS_CC_END
  47. /// @endcond
  48. #endif//CC_ALLOCATOR_DIAGNOSTICS_H