I have a COM object, CProvider, implemented using ATL. This class encloses another class, CProviderInfo, and maintains a static vector of objects of this inner class type.
Here's how it looks like:
//-------------
// CProvider.h
//-------------
//
// COM object class
//
class ATL_NO_VTABLE CProvider :
public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<CProvider, &CLSID_Provider>,
public Interface1,
public Interface2
{
public:
BEGIN_COM_MAP(CProvider)
COM_INTERFACE_ENTRY(Interface1)
COM_INTERFACE_ENTRY(Interface2)
END_COM_MAP()
//
// The inner class
//
class CProviderInfo
{
public:
CProviderInfo();
CComBSTR m_strName;
GUID m_guidRegistration;
};
private:
//
// static vector of inner class type
//
static vector<CProviderInfo> m_vProviderInfo;
};
What I would like to do is introduce a method on CProvider that returns a copy of the static vector m_vProviderInfo. Trying to play by COM rules, I introduced a new IDL interface IProviderInfoRetriever for this purpose:
//---------
// IDL file
//---------
//
// IProviderInfoRetriever interface
//
[
// uuid, version ... etc.
]
interface IProviderInfoRetriever : IUnknown
{
HRESULT GetProviderInfo(
[out, retval] SAFEARRAY(IProviderInfo*) *ppProviderInfo);
}
//
// The interface of the class holding the info
//
[
// uuid, version ... etc.
]
interface IProviderInfo : IUnknown
{
[propget]
HRESULT Name(
[out, retval] BSTR *pbstrName);
[propget]
HRESULT Registration(
[out, retval] GUID *pguidRegistration);
}
My plan is to have CProvider implement IProviderInfoRetriever effectively copying the contents of the static vector m_vProviderInfo into the output SAFEARRAY of IProviderInfoRetriever::GetProviderInfo().
My question is: is it possible to have the inner class CProviderInfo implement IProviderInfo? Would that break existing code that creates local variables of type CProviderInfo?