[BDAPLGIN]
[reactos.git] / reactos / dll / directx / bdaplgin / controlnode.cpp
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS BDA Proxy
4 * FILE: dll/directx/bdaplgin/controlnode.cpp
5 * PURPOSE: ControlNode interface
6 *
7 * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org)
8 */
9
10 #include "precomp.h"
11
12 class CControlNode : public IUnknown
13 {
14 public:
15 STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
16
17 STDMETHODIMP_(ULONG) AddRef()
18 {
19 InterlockedIncrement(&m_Ref);
20 return m_Ref;
21 }
22 STDMETHODIMP_(ULONG) Release()
23 {
24 InterlockedDecrement(&m_Ref);
25
26 if (!m_Ref)
27 {
28 delete this;
29 return 0;
30 }
31 return m_Ref;
32 }
33
34 CControlNode(HANDLE hFile, ULONG NodeType, ULONG PinId) : m_Ref(0), m_hFile(hFile), m_NodeType(NodeType), m_PinId(PinId){};
35 virtual ~CControlNode(){};
36
37 protected:
38 LONG m_Ref;
39 HANDLE m_hFile;
40 ULONG m_NodeType;
41 ULONG m_PinId;
42 };
43
44 HRESULT
45 STDMETHODCALLTYPE
46 CControlNode::QueryInterface(
47 IN REFIID refiid,
48 OUT PVOID* Output)
49 {
50 WCHAR Buffer[MAX_PATH];
51 LPOLESTR lpstr;
52
53 *Output = NULL;
54
55 if (IsEqualGUID(refiid, IID_IUnknown))
56 {
57 *Output = PVOID(this);
58 reinterpret_cast<IUnknown*>(*Output)->AddRef();
59 return NOERROR;
60 }
61 else if(IsEqualGUID(refiid, IID_IBDA_FrequencyFilter))
62 {
63 return CBDAFrequencyFilter_fnConstructor(m_hFile, refiid, Output);
64 }
65 else if(IsEqualGUID(refiid, IID_IBDA_SignalStatistics))
66 {
67 return CBDASignalStatistics_fnConstructor(m_hFile, refiid, Output);
68 }
69 else if(IsEqualGUID(refiid, IID_IBDA_LNBInfo))
70 {
71 return CBDALNBInfo_fnConstructor(m_hFile, refiid, Output);
72 }
73 else if(IsEqualGUID(refiid, IID_IBDA_DigitalDemodulator))
74 {
75 return CBDADigitalDemodulator_fnConstructor(m_hFile, refiid, Output);
76 }
77
78 StringFromCLSID(refiid, &lpstr);
79 swprintf(Buffer, L"CControlNode::QueryInterface: NoInterface for %s", lpstr);
80 OutputDebugStringW(Buffer);
81 CoTaskMemFree(lpstr);
82
83 return E_NOINTERFACE;
84 }
85
86
87 HRESULT
88 WINAPI
89 CControlNode_fnConstructor(
90 HANDLE hFile,
91 ULONG NodeType,
92 ULONG PinId,
93 REFIID riid,
94 LPVOID * ppv)
95 {
96 // construct device control
97 CControlNode * handler = new CControlNode(hFile, NodeType, PinId);
98
99 OutputDebugStringW(L"CControlNode_fnConstructor\n");
100
101 if (!handler)
102 return E_OUTOFMEMORY;
103
104 if (FAILED(handler->QueryInterface(riid, ppv)))
105 {
106 /* not supported */
107 delete handler;
108 return E_NOINTERFACE;
109 }
110
111 return NOERROR;
112 }