IAGCBaseImpl.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #ifndef __IAGCBaseImpl_h__
  2. #define __IAGCBaseImpl_h__
  3. /////////////////////////////////////////////////////////////////////////////
  4. // IAGCBaseImpl.h : Declaration of the IAGCBaseImpl class template.
  5. //
  6. #include "IAGCCommonImpl.h"
  7. /////////////////////////////////////////////////////////////////////////////
  8. // Interface Map Macro
  9. //
  10. // Classes derived from IAGCBaseImpl should include this macro in their
  11. // interface maps.
  12. //
  13. #define COM_INTERFACE_ENTRIES_IAGCBaseImpl() \
  14. COM_INTERFACE_ENTRY(IAGCBase) \
  15. COM_INTERFACE_ENTRY(IDispatch) \
  16. COM_INTERFACE_ENTRIES_IAGCCommonImpl()
  17. /////////////////////////////////////////////////////////////////////////////
  18. //
  19. // Note: This is not a base class for all AGC objects, just AGC objects that
  20. // represent IGC objects that inherit IbaseIGC
  21. //
  22. // All AGC object inherit IAGCCommon
  23. //
  24. template <class T, class IGC, class ITF, const GUID* plibid, class AGCIGC = IGC, class AGCITF = ITF>
  25. class ATL_NO_VTABLE IAGCBaseImpl :
  26. public IAGCCommonImpl<T, IGC, ITF, plibid, AGCIGC, AGCITF>
  27. {
  28. // Types
  29. public:
  30. typedef IAGCBaseImpl<T, IGC, ITF, plibid, AGCIGC, AGCITF> IAGCBaseImplBase;
  31. // IAGCBase Interface Methods
  32. public:
  33. /*-------------------------------------------------------------------------
  34. * get_ObjectType()
  35. *-------------------------------------------------------------------------
  36. * Purpose:
  37. * return this object's type
  38. *
  39. */
  40. STDMETHODIMP get_ObjectType(AGCObjectType* pObjectType)
  41. {
  42. assert(GetIGC());
  43. // CLEAROUT(pObjectType, );
  44. *pObjectType = (AGCObjectType) GetIGC()->GetObjectType();
  45. return S_OK;
  46. }
  47. /*-------------------------------------------------------------------------
  48. * get_ObjectID()
  49. *-------------------------------------------------------------------------
  50. * Purpose:
  51. * return this object's ID
  52. *
  53. */
  54. STDMETHODIMP get_ObjectID(AGCObjectID* pObjectID)
  55. {
  56. assert(GetIGC());
  57. // CLEAROUT(pObjectID, (AGCObjectID)m_pIGC->GetObjectID());
  58. *pObjectID = (AGCObjectID)GetIGC()->GetObjectID();
  59. return S_OK;
  60. }
  61. /*-------------------------------------------------------------------------
  62. * get_AGCID()
  63. *-------------------------------------------------------------------------
  64. * Purpose:
  65. * return this object's unique AGC id number ID, which is a combo of its
  66. * type id, and object id.
  67. *
  68. */
  69. STDMETHODIMP get_UniqueID(AGCUniqueID* pObjectID)
  70. {
  71. assert(GetIGC());
  72. #ifdef _DEBUG
  73. //
  74. // These should be compile time asserts, but I forgot how to do that
  75. //
  76. if (sizeof(ObjectID) > sizeof(short) ||
  77. sizeof(ObjectType) > sizeof(short))
  78. {
  79. // this and the event system are probably broken if this triggers
  80. return T::Error("Recent changes in IGC broke this property, please notify the Allegiance team.");
  81. }
  82. #endif
  83. // merge to form unique id
  84. *pObjectID = (GetIGC()->GetObjectType() << 16) | GetIGC()->GetObjectID();
  85. return S_OK;
  86. }
  87. /*-------------------------------------------------------------------------
  88. * get_Game()
  89. *-------------------------------------------------------------------------
  90. * Purpose:
  91. * return a AGCGame pointer of the game in which this object lives.
  92. *
  93. */
  94. STDMETHODIMP get_Game(IAGCGame** ppGame)
  95. {
  96. assert(GetIGC());
  97. assert(GetIGC()->GetMission());
  98. return GetAGCGlobal()->GetAGCObject(GetIGC()->GetMission(), IID_IAGCGame,
  99. (void**)ppGame);
  100. }
  101. };
  102. /////////////////////////////////////////////////////////////////////////////
  103. #endif //__IAGCBaseImpl_h__