EntityPointer.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. #ifndef SE_INCL_ENTITYPOINTER_H
  13. #define SE_INCL_ENTITYPOINTER_H
  14. #ifdef PRAGMA_ONCE
  15. #pragma once
  16. #endif
  17. /*
  18. * Smart pointer to entity objects, does the book-keeping for reference counting.
  19. */
  20. class CEntityPointer {
  21. public:
  22. CEntity *ep_pen; // the pointer itself
  23. public:
  24. // all standard smart pointer functions are defined as inlines in Entity.h
  25. // (due to strange order of inclusion needed for events and enums)
  26. inline CEntityPointer(void);
  27. inline ~CEntityPointer(void);
  28. inline CEntityPointer(const CEntityPointer &penOther);
  29. inline CEntityPointer(CEntity *pen);
  30. inline const CEntityPointer &operator=(CEntity *pen);
  31. inline const CEntityPointer &operator=(const CEntityPointer &penOther);
  32. inline CEntity* operator->(void) const;
  33. inline operator CEntity*(void) const;
  34. inline CEntity& operator*(void) const;
  35. };
  36. #endif /* include-once check. */