Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
3.4 KiB

  1. // MultiTrackTerminal.h: interface for the CMultiTrackTerminal class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(_MULTITRACKTERMINAL_DOT_H_INCLUDED_)
  5. #define _MULTITRACKTERMINAL_DOT_H_INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. template <class T>
  10. class ITMultiTrackTerminalVtbl : public ITMultiTrackTerminal
  11. {
  12. };
  13. class CMultiTrackTerminal;
  14. typedef IDispatchImpl<ITMultiTrackTerminalVtbl<CMultiTrackTerminal>, &IID_ITMultiTrackTerminal, &LIBID_TAPI3Lib> CTMultiTrack;
  15. class CMultiTrackTerminal :
  16. public CComObjectRootEx<CComMultiThreadModel>,
  17. public CTMultiTrack
  18. {
  19. public:
  20. BEGIN_COM_MAP(CMultiTrackTerminal)
  21. COM_INTERFACE_ENTRY(IDispatch)
  22. COM_INTERFACE_ENTRY(ITMultiTrackTerminal)
  23. END_COM_MAP()
  24. //
  25. // the logic for creating a track terminal needs to be implemented by the
  26. // specific terminals, so this is a pure virtual method
  27. //
  28. virtual HRESULT STDMETHODCALLTYPE CreateTrackTerminal(
  29. IN long MediaType,
  30. IN TERMINAL_DIRECTION TerminalDirection,
  31. OUT ITTerminal **ppTerminal
  32. ) = 0;
  33. public:
  34. virtual HRESULT STDMETHODCALLTYPE get_TrackTerminals(
  35. OUT VARIANT *pVariant
  36. );
  37. virtual HRESULT STDMETHODCALLTYPE EnumerateTrackTerminals(
  38. IEnumTerminal **ppEnumTerminal
  39. );
  40. virtual HRESULT STDMETHODCALLTYPE get_MediaTypesInUse(
  41. OUT long *plMediaTypesInUse
  42. );
  43. virtual HRESULT STDMETHODCALLTYPE get_DirectionsInUse(
  44. OUT TERMINAL_DIRECTION *plDirectionsInUsed
  45. );
  46. virtual HRESULT STDMETHODCALLTYPE RemoveTrackTerminal(
  47. IN ITTerminal *pTrackTerminalToRemove
  48. );
  49. public:
  50. CMultiTrackTerminal();
  51. virtual ~CMultiTrackTerminal();
  52. protected:
  53. HRESULT AddTrackTerminal(ITTerminal *pTrackTerminalToAdd);
  54. HRESULT ReleaseAllTracks();
  55. //
  56. // a helper method that returns true if the terminal is in the list of managed tracks
  57. //
  58. BOOL DoIManageThisTrack(ITTerminal *pTrackInQuestion)
  59. {
  60. CLock lock(m_lock);
  61. int nIndex = m_TrackTerminals.Find(pTrackInQuestion);
  62. return (nIndex >= 0);
  63. }
  64. //
  65. // returns the number of tracks managed by this terminal
  66. //
  67. int CountTracks();
  68. public:
  69. //
  70. // the derived class, CComObject, implements these. Here declare as pure
  71. // virtual so we can refer to these methods from ChildRelease and
  72. // ChildAddRef()
  73. //
  74. virtual ULONG STDMETHODCALLTYPE AddRef() = 0;
  75. virtual ULONG STDMETHODCALLTYPE Release() = 0;
  76. //
  77. // called by a track terminals when they are addref'ed or released
  78. //
  79. virtual void ChildAddRef();
  80. virtual void ChildRelease();
  81. protected:
  82. //
  83. // we have to adjust refcount with the information on the number of tracks that we are managing
  84. //
  85. ULONG InternalAddRef();
  86. ULONG InternalRelease();
  87. protected:
  88. //
  89. // collection of track terminals
  90. //
  91. CMSPArray<ITTerminal*> m_TrackTerminals;
  92. protected:
  93. //
  94. // critical section.
  95. //
  96. CMSPCritSection m_lock;
  97. private:
  98. //
  99. // this data member is used to keep the count of the tracks managed by this
  100. // terminal
  101. //
  102. int m_nNumberOfTracks;
  103. };
  104. #endif // !defined(_MULTITRACKTERMINAL_DOT_H_INCLUDED_)