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.

116 lines
2.9 KiB

  1. /////////////////////////////////////////////////////////////////////////////////////
  2. // ChannelTuneRequestimpl.h : implementation helper template for component type interface
  3. // Copyright (c) Microsoft Corporation 1999.
  4. #ifndef CHANNELTUNEREQUESTIMPL_H
  5. #define CHANNELTUNEREQUESTIMPL_H
  6. #include <tune.h>
  7. #include "tunerequestimpl.h"
  8. namespace BDATuningModel {
  9. template<class T,
  10. class MostDerived = IChannelTuneRequest,
  11. LPCGUID iid = &__uuidof(MostDerived),
  12. LPCGUID LibID = &LIBID_TunerLib,
  13. WORD wMajor = 1,
  14. WORD wMinor = 0,
  15. class tihclass = CComTypeInfoHolder
  16. > class ATL_NO_VTABLE IChannelTuneRequestImpl :
  17. public ITuneRequestImpl<T, MostDerived, iid, LibID, wMajor, wMinor, tihclass>
  18. {
  19. // IChannelTuneRequest
  20. public:
  21. typedef ITuneRequestImpl<T, MostDerived, iid, LibID, wMajor, wMinor, tihclass> basetype;
  22. IChannelTuneRequestImpl() : m_Channel(-1) {}
  23. virtual ~IChannelTuneRequestImpl() {}
  24. BEGIN_PROP_MAP(IChannelTuneRequestImpl)
  25. CHAIN_PROP_MAP(basetype)
  26. PROP_DATA_ENTRY("Channel", m_Channel, VT_I4)
  27. END_PROP_MAP()
  28. long m_Channel;
  29. STDMETHOD(get_Channel)(long *pVal)
  30. {
  31. try {
  32. if (!pVal) {
  33. return E_POINTER;
  34. }
  35. ATL_LOCKT();
  36. *pVal = m_Channel;
  37. } catch (...) {
  38. return E_POINTER;
  39. }
  40. return NOERROR;
  41. }
  42. STDMETHOD(put_Channel)(long newVal)
  43. {
  44. ATL_LOCKT();
  45. if (!m_TS) {
  46. return E_UNEXPECTED;
  47. }
  48. long maxval;
  49. long minval;
  50. TNAnalogTVTuningSpace ts(m_TS);
  51. if (ts) {
  52. maxval = ts.MaxChannel();
  53. minval = ts.MinChannel();
  54. } else {
  55. TNAnalogRadioTuningSpace ts2(m_TS);
  56. if (ts2) {
  57. maxval = ts2.MaxFrequency();
  58. minval = ts2.MinFrequency();
  59. } else {
  60. TNAuxInTuningSpace ts3(m_TS);
  61. if(ts3){
  62. maxval = 1;
  63. minval = 0;
  64. }
  65. else{
  66. return E_UNEXPECTED;
  67. }
  68. }
  69. }
  70. if (newVal != BDA_UNDEFINED_CHANNEL) {
  71. if (newVal < minval) {
  72. newVal = maxval;
  73. } else if (newVal > maxval) {
  74. newVal = minval;
  75. }
  76. }
  77. m_Channel = newVal;
  78. MARK_DIRTY(T);
  79. return NOERROR;
  80. }
  81. STDMETHOD(Clone) (ITuneRequest **ppTR) {
  82. try {
  83. if (!ppTR) {
  84. return E_POINTER;
  85. }
  86. ATL_LOCKT();
  87. HRESULT hr = basetype::Clone(ppTR);
  88. if (FAILED(hr)) {
  89. return hr;
  90. }
  91. T* pt = static_cast<T*>(*ppTR);
  92. pt->m_Channel = m_Channel;
  93. return NOERROR;
  94. } catch (HRESULT h) {
  95. return h;
  96. } catch (...) {
  97. return E_POINTER;
  98. }
  99. }
  100. };
  101. typedef CComQIPtr<IChannelTuneRequest> PQChannelTuneRequest;
  102. }; // namespace
  103. #endif // CHANNELTUNEREQUESTIMPL_H
  104. // end of file -- channeltunerequestimpl.h