I have a COM object.
In the main class I made two public members.
public:
HANDLE m_hVoiceData;
void* m_pVoiceData;
They are for mapping a file.
I map the file at the instantiation of the COM object.
The main class of the COM object has a private class.
From this private class I want to access these public members:
This is how I want to access the mapped file:
memcpy(nEncodedBytes,& CTTSEngObj::m_pVoiceData[iFirstByteToRead], iLenCompressedBytes);
But the compiler does not like this.
It says that "A non-static member reference has to be relative to a certain object".
Can anybody please tell me how to do this correctly?
I know that making a member public in a main class, but I need to do it because the private class (as mentioned above) also has private classes, and they all need this member to access a certain mapped file.
This is where I map the file:
STDMETHODIMP CTTSEngObj::SetObjectToken(ISpObjectToken * pToken)
{
HRESULT hr = SpGenericSetObjectToken(pToken, m_cpToken);
//--- Map the voice data so it will be shared among all instances
// Note: This is a good example of how to memory map and share
// your voice data across instances.
TCHAR szFileName[MAX_PATH+1];
GetModuleFileName(_Module.m_hInst, szFileName, MAX_PATH+1);
StrCpy(PathFindFileName(szFileName), _T("data.dat"));
if( SUCCEEDED( hr ) )
{
USES_CONVERSION;//needed to make T2W work
hr = MapFile( T2W(szFileName), &m_hVoiceData, &m_pVoiceData );
}
And then
STDMETHODIMP CTTSEngObj::Speak( DWORD dwSpeakFlags,
REFGUID rguidFormatId,
const WAVEFORMATEX * pWaveFormatEx,
const SPVTEXTFRAG* pTextFragList,
ISpTTSEngineSite* pOutputSite )
{
HRESULT hr = S_OK;
//--- Check args
if( SP_IS_BAD_INTERFACE_PTR( pOutputSite ) ||
SP_IS_BAD_READ_PTR( pTextFragList ) )
{
hr = E_INVALIDARG;
return hr;
}
m_App.DoSomething();
m_App is a class.
It is a private member of the COM object main class.
This class has subclasses, for example:
CTTSEngObj.m_App.SomeSmallClass
And SomeSmallClass needs to access the mapped file.