TCMarshalByValue.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef __TCMarshalByValue_h__
  2. #define __TCMarshalByValue_h__
  3. /////////////////////////////////////////////////////////////////////////////
  4. // TCMarshalByValue.h | Declaration of the CTCMarshalByValue, which
  5. // implements the CLSID_TCMarshalByValue component object.
  6. #include "resource.h" // main symbols
  7. #include "SrcInc.h"
  8. #include <TCObj.h>
  9. #include <..\TCLib\ObjectLock.h>
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CTCMarshalByValue
  12. class ATL_NO_VTABLE CTCMarshalByValue :
  13. public IMarshal,
  14. public CComCoClass<CTCMarshalByValue, &CLSID_TCMarshalByValue>,
  15. public CComObjectRoot
  16. {
  17. // Declarations
  18. public:
  19. DECLARE_REGISTRY_RESOURCEID(IDR_TCMarshalByValue)
  20. DECLARE_ONLY_AGGREGATABLE(CTCMarshalByValue)
  21. // Category Map
  22. public:
  23. BEGIN_CATEGORY_MAP(CTCMarshalByValue)
  24. IMPLEMENTED_CATEGORY(CATID_TCObj)
  25. END_CATEGORY_MAP()
  26. // Interface Map
  27. public:
  28. BEGIN_COM_MAP(CTCMarshalByValue)
  29. COM_INTERFACE_ENTRY(IMarshal)
  30. END_COM_MAP()
  31. // Construction / Destruction
  32. public:
  33. CTCMarshalByValue();
  34. #if defined(_DEBUG) && defined(CTCMarshalByValue_DEBUG)
  35. HRESULT CTCMarshalByValue::FinalConstruct();
  36. void CTCMarshalByValue::FinalRelease();
  37. #endif // _DEBUG
  38. // IMarshal Interface Methods
  39. public:
  40. STDMETHODIMP GetUnmarshalClass(REFIID riid, void* pv, DWORD dwDestContext,
  41. void* pvDestContext, DWORD mshlflags, CLSID* pCid);
  42. STDMETHODIMP GetMarshalSizeMax(REFIID riid, void* pv, DWORD dwDestContext,
  43. void* pvDestContext, DWORD mshlflags, DWORD* pSize);
  44. STDMETHODIMP MarshalInterface(IStream* pStm, REFIID riid, void* pv,
  45. DWORD dwDestContext, void* pvDestContext, DWORD mshlflags);
  46. STDMETHODIMP UnmarshalInterface(IStream* pStm, REFIID riid, void** ppv);
  47. STDMETHODIMP ReleaseMarshalData(IStream* pStm);
  48. STDMETHODIMP DisconnectObject(DWORD dwReserved);
  49. // Implementation
  50. protected:
  51. HRESULT GetOuterPersistStream(IPersistStream** pps);
  52. // Types
  53. protected:
  54. typedef TCObjectLock<CTCMarshalByValue> CLock;
  55. // Data Members
  56. protected:
  57. DWORD m_dwEndian;
  58. const DWORD m_dwEndianOriginal, m_dwEndianInverted;
  59. };
  60. /////////////////////////////////////////////////////////////////////////////
  61. // Implementation
  62. inline HRESULT CTCMarshalByValue::GetOuterPersistStream(IPersistStream** pps)
  63. {
  64. HRESULT hr = OuterQueryInterface(IID_IPersistStream, (void**)pps);
  65. if (SUCCEEDED(hr))
  66. return hr;
  67. return OuterQueryInterface(IID_IPersistStreamInit, (void**)pps);
  68. }
  69. /////////////////////////////////////////////////////////////////////////////
  70. #endif // !__TCMarshalByValue_h__