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