Commit f377e88a authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

activex: Simplify use of VLCEnumIterator

parent b3c07ee5
...@@ -51,22 +51,11 @@ struct VLCEnumConnectionsDereference ...@@ -51,22 +51,11 @@ struct VLCEnumConnectionsDereference
} }
}; };
class VLCEnumConnections : public VLCEnumIterator<IID_IEnumConnections, using VLCEnumConnections = VLCEnumIterator<IID_IEnumConnections,
IEnumConnections, IEnumConnections,
CONNECTDATA, CONNECTDATA,
std::map<DWORD,LPUNKNOWN>::iterator, std::map<DWORD,LPUNKNOWN>,
VLCEnumConnectionsDereference> VLCEnumConnectionsDereference>;
{
public:
VLCEnumConnections(std::map<DWORD,LPUNKNOWN> &m) :
VLCEnumIterator<IID_IEnumConnections,
IEnumConnections,
CONNECTDATA,
std::map<DWORD,LPUNKNOWN>::iterator,
VLCEnumConnectionsDereference> (m.begin(), m.end())
{
}
};
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -81,23 +70,11 @@ struct VLCEnumConnectionPointsDereference ...@@ -81,23 +70,11 @@ struct VLCEnumConnectionPointsDereference
} }
}; };
class VLCEnumConnectionPoints: public VLCEnumIterator<IID_IEnumConnectionPoints, using VLCEnumConnectionPoints = VLCEnumIterator<IID_IEnumConnectionPoints,
IEnumConnectionPoints, IEnumConnectionPoints,
LPCONNECTIONPOINT, LPCONNECTIONPOINT,
std::vector<LPCONNECTIONPOINT>::iterator, std::vector<LPCONNECTIONPOINT>,
VLCEnumConnectionPointsDereference> VLCEnumConnectionPointsDereference>;
{
public:
VLCEnumConnectionPoints(std::vector<LPCONNECTIONPOINT>& v) :
VLCEnumIterator<IID_IEnumConnectionPoints,
IEnumConnectionPoints,
LPCONNECTIONPOINT,
std::vector<LPCONNECTIONPOINT>::iterator,
VLCEnumConnectionPointsDereference> (v.begin(), v.end())
{
}
};
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
// EventSystemProxyWnd // EventSystemProxyWnd
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
......
...@@ -46,19 +46,10 @@ static const FORMATETC _enhMetaFileFormatEtc = ...@@ -46,19 +46,10 @@ static const FORMATETC _enhMetaFileFormatEtc =
TYMED_ENHMF, TYMED_ENHMF,
}; };
class VLCEnumFORMATETC : public VLCEnumIterator<IID_IEnumFORMATETC, using VLCEnumFORMATETC = VLCEnumIterator<IID_IEnumFORMATETC,
IEnumFORMATETC, IEnumFORMATETC,
FORMATETC, FORMATETC,
vector<FORMATETC>::iterator> std::vector<FORMATETC>>;
{
public:
VLCEnumFORMATETC(vector<FORMATETC> v) :
VLCEnumIterator<IID_IEnumFORMATETC,
IEnumFORMATETC,
FORMATETC,
vector<FORMATETC>::iterator>(v.begin(), v.end())
{};
};
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
...@@ -246,7 +237,7 @@ STDMETHODIMP VLCDataObject::QueryGetData(LPFORMATETC pFormatEtc) ...@@ -246,7 +237,7 @@ STDMETHODIMP VLCDataObject::QueryGetData(LPFORMATETC pFormatEtc)
default: default:
return DV_E_FORMATETC; return DV_E_FORMATETC;
} }
if( pFormatEtc->dwAspect != formatEtc->dwAspect ) if( pFormatEtc->dwAspect != formatEtc->dwAspect )
return DV_E_DVASPECT; return DV_E_DVASPECT;
......
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
#include <servprov.h> #include <servprov.h>
#include <shlwapi.h> #include <shlwapi.h>
#include <wininet.h> #include <wininet.h>
#include <assert.h>
using namespace std; using namespace std;
......
...@@ -52,32 +52,26 @@ struct VLCDereference ...@@ -52,32 +52,26 @@ struct VLCDereference
T operator()(const Iterator& i) const T operator()(const Iterator& i) const
{ {
return *i; return *i;
}; }
}; };
template<REFIID EnumeratorIID, class Enumerator, typename T, class Iterator, typename Dereference = VLCDereference<T, Iterator> > template<REFIID EnumeratorIID, class Enumerator, typename T, class Container, typename Dereference = VLCDereference<T, typename Container::iterator> >
class VLCEnumIterator : public Enumerator class VLCEnumIterator : public Enumerator
{ {
public: public:
VLCEnumIterator(const Iterator& from, const Iterator& to) : VLCEnumIterator(Container& container) :
_refcount(1), _refcount(1),
_begin(from), _begin(begin(container)),
_curr(from), _curr(_begin),
_end(to) _end(end(container))
{}; {
}
VLCEnumIterator(const VLCEnumIterator& e) :
Enumerator(), VLCEnumIterator(const VLCEnumIterator& e) = default;
_refcount(e._refcount),
_begin(e._begin), virtual ~VLCEnumIterator() = default;
_curr(e._curr),
_end(e._end)
{};
virtual ~VLCEnumIterator()
{};
// IUnknown methods // IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv) STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
...@@ -93,12 +87,12 @@ public: ...@@ -93,12 +87,12 @@ public:
} }
// standalone object // standalone object
return E_NOINTERFACE; return E_NOINTERFACE;
}; }
STDMETHODIMP_(ULONG) AddRef(void) STDMETHODIMP_(ULONG) AddRef()
{ {
return InterlockedIncrement(&_refcount); return InterlockedIncrement(&_refcount);
}; }
STDMETHODIMP_(ULONG) Release(void) STDMETHODIMP_(ULONG) Release(void)
{ {
...@@ -109,7 +103,7 @@ public: ...@@ -109,7 +103,7 @@ public:
return 0; return 0;
} }
return refcount; return refcount;
}; }
// IEnumXXXX methods // IEnumXXXX methods
...@@ -134,7 +128,7 @@ public: ...@@ -134,7 +128,7 @@ public:
*pceltFetched = c; *pceltFetched = c;
return (c == celt) ? S_OK : S_FALSE; return (c == celt) ? S_OK : S_FALSE;
}; }
STDMETHODIMP Skip(ULONG celt) STDMETHODIMP Skip(ULONG celt)
{ {
...@@ -146,29 +140,28 @@ public: ...@@ -146,29 +140,28 @@ public:
++c; ++c;
} }
return (c == celt) ? S_OK : S_FALSE; return (c == celt) ? S_OK : S_FALSE;
}; }
STDMETHODIMP Reset(void) STDMETHODIMP Reset()
{ {
_curr = _begin; _curr = _begin;
return S_OK; return S_OK;
}; }
STDMETHODIMP Clone(Enumerator **ppEnum) STDMETHODIMP Clone(Enumerator **ppEnum)
{ {
if( NULL == ppEnum ) if( NULL == ppEnum )
return E_POINTER; return E_POINTER;
*ppEnum = dynamic_cast<Enumerator *>(new VLCEnumIterator(*this)); *ppEnum = new VLCEnumIterator(*this);
return (NULL != *ppEnum ) ? S_OK : E_OUTOFMEMORY; return (NULL != *ppEnum ) ? S_OK : E_OUTOFMEMORY;
}; }
private: private:
LONG _refcount; LONG _refcount;
Iterator _begin, _curr, _end; typename Container::iterator _begin, _curr, _end;
Dereference dereference; Dereference dereference;
}; };
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment