Skip to content

GetRepCap

Gets a pointer to a child repeated capability instance.

template <typename RepCapClass>
RepCapClass* GetRepCap(const CString& strInstanceName) const;
template <typename RepCapClass>
RepCapClass* GetRepCap(int nIndex) const;

strInstanceName

[in] Physical name or virtual name of the desired repeated capability instance.

nIndex

[in] Zero-based index of the desired repeated capability instance.

Returns a pointer to the repeated capability instance or NULL if the instance is not found.

This function returns a pointer to a child repeated capability instance. The strInstanceName parameter may be either a physical name or a virtual name.

Since this function returns a direct pointer to the child repeated capability C++ class instance, not an interface pointer, you can call C++ functions defined on the class that are not in the public COM interface.

The following example demonstrates use of the GetRepCap function.

CoAcme4321.cpp
HRESULT Acme4321::PresetAll()
{
HRESULT hr = S_OK;
int nRepCapCount = GetRepCapCount<Acme4321Channel>();
for (int i = 0; i < nRepCapCount; i++)
{
Acme4321Channel* pChannel = GetRepCap<Acme4321Channel>(i);
// Call C++ functions on the Acme4321Channel class...
pChannel->PresetHelper(); // Not a COM interface method
}
return hr;
}