ReactOS  0.4.15-dev-1397-g19779b3
enumpins.cpp
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Network Provider for MPEG2 based networks
4  * FILE: dll/directx/msdvbnp/enumpins.cpp
5  * PURPOSE: IEnumPins interface
6  *
7  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8  */
9 #include "precomp.h"
10 
11 class CEnumPins : public IEnumPins
12 {
13 public:
15 
17  {
19  return m_Ref;
20  }
22  {
24  if (!m_Ref)
25  {
26  delete this;
27  return 0;
28  }
29  return m_Ref;
30  }
31 
32 
33  HRESULT STDMETHODCALLTYPE Next(ULONG cPins, IPin **ppPins, ULONG *pcFetched);
37 
38  CEnumPins(ULONG NumPins, IPin ** pins) : m_Ref(0), m_NumPins(NumPins), m_Pins(pins), m_Index(0){};
39  virtual ~CEnumPins(){};
40 
41 protected:
42  LONG m_Ref;
45  ULONG m_Index;
46 };
47 
48 HRESULT
51  IN REFIID refiid,
52  OUT PVOID* Output)
53 {
54  if (IsEqualGUID(refiid, IID_IUnknown))
55  {
56  *Output = PVOID(this);
57  reinterpret_cast<IUnknown*>(*Output)->AddRef();
58  return NOERROR;
59  }
60  if (IsEqualGUID(refiid, IID_IEnumPins))
61  {
62  *Output = (IEnumPins*)(this);
63  reinterpret_cast<IEnumPins*>(*Output)->AddRef();
64  return NOERROR;
65  }
66 
69  StringFromCLSID(refiid, &lpstr);
70  swprintf(Buffer, L"CEnumPins::QueryInterface: NoInterface for %s\n", lpstr);
73 
74  return E_NOINTERFACE;
75 }
76 
77 HRESULT
80  ULONG cPins,
81  IPin **ppPins,
82  ULONG *pcFetched)
83 {
84  ULONG i = 0;
85 
86  if (!ppPins)
87  return E_POINTER;
88 
89  if (cPins > 1 && !pcFetched)
90  return E_INVALIDARG;
91 
92  while(i < cPins)
93  {
94  if (m_Index + i >= m_NumPins)
95  break;
96 
97  ppPins[i] = m_Pins[m_Index + i];
98  m_Pins[m_Index + i]->AddRef();
99 
100  i++;
101  }
102 
103  if (pcFetched)
104  {
105  *pcFetched = i;
106  }
107 
108  m_Index += i;
109 
110  if (i < cPins)
111  return S_FALSE;
112  else
113  return S_OK;
114 }
115 
116 HRESULT
119  ULONG cPins)
120 {
121  if (cPins + m_Index >= m_NumPins)
122  {
123  return S_FALSE;
124  }
125 
126  m_Index += cPins;
127  return S_OK;
128 }
129 
130 HRESULT
133 {
134  m_Index = 0;
135  return S_OK;
136 }
137 
138 HRESULT
141  IEnumPins **ppEnum)
142 {
143  OutputDebugStringW(L"CEnumPins::Clone : NotImplemented\n");
144  return E_NOTIMPL;
145 }
146 
147 HRESULT
148 WINAPI
151  ULONG NumPins,
152  IPin ** pins,
153  REFIID riid,
154  LPVOID * ppv)
155 {
156  CEnumPins * handler = new CEnumPins(NumPins, pins);
157 
158  if (!handler)
159  return E_OUTOFMEMORY;
160 
161  if (FAILED(handler->QueryInterface(riid, ppv)))
162  {
163  /* not supported */
164  delete handler;
165  return E_NOINTERFACE;
166  }
167 
168  return NOERROR;
169 }
HRESULT STDMETHODCALLTYPE Next(ULONG cPins, IPin **ppPins, ULONG *pcFetched)
Definition: enumpins.cpp:79
#define IN
Definition: typedefs.h:39
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
ULONG m_NumPins
Definition: enumpins.cpp:43
#define NOERROR
Definition: winerror.h:2354
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
STDMETHODIMP_(ULONG) Release()
Definition: enumpins.cpp:21
static LPOLESTR
Definition: stg_prop.c:27
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
HRESULT STDMETHODCALLTYPE Reset()
Definition: enumpins.cpp:131
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
#define STDMETHODIMP
Definition: basetyps.h:43
ULONG Release()
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
HRESULT STDMETHODCALLTYPE Skip(ULONG cPins)
Definition: enumpins.cpp:117
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
virtual ~CEnumPins()
Definition: enumpins.cpp:39
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
const GUID IID_IUnknown
#define MAX_PATH
Definition: compat.h:34
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define WINAPI
Definition: msvc.h:6
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
ULONG AddRef()
STDMETHODIMP_(ULONG) AddRef()
Definition: enumpins.cpp:16
static const WCHAR L[]
Definition: oid.c:1250
#define InterlockedDecrement
Definition: armddk.h:52
Definition: arc.h:85
#define S_OK
Definition: intsafe.h:51
#define InterlockedIncrement
Definition: armddk.h:53
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
Definition: axcore.idl:91
#define E_NOTIMPL
Definition: ddrawi.h:99
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
HRESULT STDMETHODCALLTYPE Clone(IEnumPins **ppEnum)
Definition: enumpins.cpp:139
ULONG m_Index
Definition: enumpins.cpp:44
#define OUT
Definition: typedefs.h:40
HRESULT WINAPI CEnumPins_fnConstructor(std::vector< IPin * > Pins, REFIID riid, LPVOID *ppv)
Definition: enumpins.cpp:151
CEnumPins(ULONG NumPins, IPin **pins)
Definition: enumpins.cpp:38
unsigned int ULONG
Definition: retypes.h:1
IPin ** m_Pins
Definition: enumpins.cpp:44
static LPCSTR lpstr
Definition: font.c:51
std::vector< IPin * > m_Pins
Definition: enumpins.cpp:43
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
#define E_POINTER
Definition: winerror.h:2365
LONG m_Ref
Definition: enumpins.cpp:39
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412