MEM_RefCountedC-Api.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version 2
  5. * of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software Foundation,
  14. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. *
  16. * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  17. * All rights reserved.
  18. */
  19. /** \file
  20. * \ingroup memutil
  21. *
  22. * Interface for C access to functionality relating to shared objects in the foundation library.
  23. */
  24. #ifndef __MEM_REFCOUNTEDC_API_H__
  25. #define __MEM_REFCOUNTEDC_API_H__
  26. /** A pointer to a private object. */
  27. typedef struct MEM_TOpaqueObject *MEM_TObjectPtr;
  28. /** A pointer to a shared object. */
  29. typedef MEM_TObjectPtr MEM_TRefCountedObjectPtr;
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /**
  34. * Returns the reference count of this object.
  35. * @param shared The object to query.
  36. * @return The current reference count.
  37. */
  38. extern int MEM_RefCountedGetRef(MEM_TRefCountedObjectPtr shared);
  39. /**
  40. * Increases the reference count of this object.
  41. * @param shared The object to query.
  42. * @return The new reference count.
  43. */
  44. extern int MEM_RefCountedIncRef(MEM_TRefCountedObjectPtr shared);
  45. /**
  46. * Decreases the reference count of this object.
  47. * If the reference count reaches zero, the object self-destructs.
  48. * @param shared The object to query.
  49. * @return The new reference count.
  50. */
  51. extern int MEM_RefCountedDecRef(MEM_TRefCountedObjectPtr shared);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif // __MEM_REFCOUNTEDC_API_H__