pantheios::com Namespace Reference


Detailed Description

Utility components for using Pantheios with COM.

When implementing COM components, one must carefully observe the prohibition on allowing exceptions to escape out to the context of the caller. But implementing COM components to follow this can be verbose and tiresome. This function suite may be used to handle all that boring guff automatically, and log the details of caught exceptions to boot!

The invoke_nothrow() functions can be used to wrap non-member entry point functions, as illustrated in the following example (an extract from the adjunct library Pantheios.COM):

STDAPI DllRegisterServer_()
{
  pantheios::log_NOTICE("DllRegisterServer()");

  HRESULT hr  =   S_OK;

#ifdef _MERGE_PROXYSTUB
  if(SUCCEEDED(hr))
  {
    hr = PrxDllRegisterServer();
  }
#endif \/\* _MERGE_PROXYSTUB \*\/

  if(SUCCEEDED(hr))
  {
    hr = _Module.RegisterServer(true);
  }

  if(FAILED(hr))
  {
    pantheios::log_ERROR( "Registration failed: ", pantheios::integer(hr, pantheios::fmt::fullHex)
                        , ": ", winstl::error_desc_a(hr));
  }
  else
  {
    // Translate all the other Pantheios loggers
    hr = ReregisterPantheiosEventSources();
  }

  return hr;
}

STDAPI DllRegisterServer()
{
  return pantheios::com::invoke_nothrow(DllRegisterServer_, "DllRegisterServer");
}

Any exceptions thrown in the implementation function, DllRegisterServer_() will be caught by invoke_nothrow() and translated into the appropriate HRESULT, and a corresponding log statement called.

The invoke_nothrow_method() functions can be used to wrap COM methods, as illustrated in the following example (an extract from Open-RJ.COM):

STDMETHODIMP Record::get_Count_(long *pVal)
{
  pantheios::log_DEBUG("Record::Count");

  return get_long_(pVal, &orj_record_t::numFields);
}

STDMETHODIMP Record::get_Count(long *pVal)
{
  return pantheios::invoke_nothrow_method(this, &Record::get_Count_, pVal, "Record::Count");
}


Functions

template<typename R>
invoke_nothrow (R(stdcall *pfn)(), char const *functionName)
 Wraps a 0-parameter function in an exception-handler and logs any exceptions using Pantheios.
template<typename R, typename A0>
invoke_nothrow (R(stdcall *pfn)(A0), A0 a0, char const *functionName)
 Wraps a 1-parameter function in an exception-handler and logs any exceptions using Pantheios.
template<typename R, typename A0, typename A1>
invoke_nothrow (R(stdcall *pfn)(A0, A1), A0 a0, A1 a1, char const *functionName)
 Wraps a 2-parameter function in an exception-handler and logs any exceptions using Pantheios.
template<typename R, typename A0, typename A1, typename A2>
invoke_nothrow (R(stdcall *pfn)(A0, A1, A2), A0 a0, A1 a1, A2 a2, char const *functionName)
 Wraps a 3-parameter function in an exception-handler and logs any exceptions using Pantheios.
template<typename R, typename C, typename A0>
invoke_nothrow_method (C *pThis, R(stdcallC::*pfn)(A0), A0 a0, char const *functionName)
 Wraps a 1-parameter class member function in an exception-handler and logs any exceptions using Pantheios.
template<typename R, typename C, typename A0, typename A1>
invoke_nothrow_method (C *pThis, R(stdcallC::*pfn)(A0, A1), A0 a0, A1 a1, char const *functionName)
 Wraps a 2-parameter class member function in an exception-handler and logs any exceptions using Pantheios.
template<typename R, typename C, typename A0, typename A1, typename A2>
invoke_nothrow_method (C *pThis, R(stdcallC::*pfn)(A0, A1, A2), A0 a0, A1 a1, A2 a2, char const *functionName)
 Wraps a 3-parameter class member function in an exception-handler and logs any exceptions using Pantheios.
template<typename R, typename C, typename A0, typename A1, typename A2, typename A3>
invoke_nothrow_method (C *pThis, R(stdcallC::*pfn)(A0, A1, A2, A3), A0 a0, A1 a1, A2 a2, A3 a3, char const *functionName)
 Wraps a 4-parameter class member function in an exception-handler and logs any exceptions using Pantheios.
template<typename R, typename C, typename A0, typename A1, typename A2, typename A3, typename A4>
invoke_nothrow_method (C *pThis, R(stdcallC::*pfn)(A0, A1, A2, A3, A4), A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, char const *functionName)
 Wraps a 5-parameter class member function in an exception-handler and logs any exceptions using Pantheios.


Function Documentation

template<typename R, typename A0, typename A1, typename A2>
R pantheios::com::invoke_nothrow R(stdcall *pfn)(A0, A1, A2)  ,
A0  a0,
A1  a1,
A2  a2,
char const *  functionName
[inline]
 

Wraps a 3-parameter function in an exception-handler and logs any exceptions using Pantheios.

Parameters:
pfn The function that will be invoked
a0 The first argument to the function
a1 The second argument to the function
a2 The third argument to the function
functionName The name of the function, used in any logging messages

template<typename R, typename A0, typename A1>
R pantheios::com::invoke_nothrow R(stdcall *pfn)(A0, A1)  ,
A0  a0,
A1  a1,
char const *  functionName
[inline]
 

Wraps a 2-parameter function in an exception-handler and logs any exceptions using Pantheios.

Parameters:
pfn The function that will be invoked
a0 The first argument to the function
a1 The second argument to the function
functionName The name of the function, used in any logging messages

template<typename R, typename A0>
R pantheios::com::invoke_nothrow R(stdcall *pfn)(A0)  ,
A0  a0,
char const *  functionName
[inline]
 

Wraps a 1-parameter function in an exception-handler and logs any exceptions using Pantheios.

Parameters:
pfn The function that will be invoked
a0 The argument to the function
functionName The name of the function, used in any logging messages

template<typename R>
R pantheios::com::invoke_nothrow R(stdcall *pfn)()  ,
char const *  functionName
[inline]
 

Wraps a 0-parameter function in an exception-handler and logs any exceptions using Pantheios.

Parameters:
pfn The function that will be invoked
functionName The name of the function, used in any logging messages

template<typename R, typename C, typename A0, typename A1, typename A2, typename A3, typename A4>
R pantheios::com::invoke_nothrow_method C *  pThis,
R(stdcallC::*)(A0, A1, A2, A3, A4)  pfn,
A0  a0,
A1  a1,
A2  a2,
A3  a3,
A4  a4,
char const *  functionName
[inline]
 

Wraps a 5-parameter class member function in an exception-handler and logs any exceptions using Pantheios.

Parameters:
pThis The instance on which the member function will be invoked
pfn The member function that will be invoked
a0 The first argument to the function
a1 The second argument to the function
a2 The third argument to the function
a3 The fourth argument to the function
a4 The fifth argument to the function
functionName The name of the function, used in any logging messages

template<typename R, typename C, typename A0, typename A1, typename A2, typename A3>
R pantheios::com::invoke_nothrow_method C *  pThis,
R(stdcallC::*)(A0, A1, A2, A3)  pfn,
A0  a0,
A1  a1,
A2  a2,
A3  a3,
char const *  functionName
[inline]
 

Wraps a 4-parameter class member function in an exception-handler and logs any exceptions using Pantheios.

Parameters:
pThis The instance on which the member function will be invoked
pfn The member function that will be invoked
a0 The first argument to the function
a1 The second argument to the function
a2 The third argument to the function
a3 The fourth argument to the function
functionName The name of the function, used in any logging messages

template<typename R, typename C, typename A0, typename A1, typename A2>
R pantheios::com::invoke_nothrow_method C *  pThis,
R(stdcallC::*)(A0, A1, A2)  pfn,
A0  a0,
A1  a1,
A2  a2,
char const *  functionName
[inline]
 

Wraps a 3-parameter class member function in an exception-handler and logs any exceptions using Pantheios.

Parameters:
pThis The instance on which the member function will be invoked
pfn The member function that will be invoked
a0 The first argument to the function
a1 The second argument to the function
a2 The third argument to the function
functionName The name of the function, used in any logging messages

template<typename R, typename C, typename A0, typename A1>
R pantheios::com::invoke_nothrow_method C *  pThis,
R(stdcallC::*)(A0, A1)  pfn,
A0  a0,
A1  a1,
char const *  functionName
[inline]
 

Wraps a 2-parameter class member function in an exception-handler and logs any exceptions using Pantheios.

Parameters:
pThis The instance on which the member function will be invoked
pfn The member function that will be invoked
a0 The first argument to the function
a1 The second argument to the function
functionName The name of the function, used in any logging messages

template<typename R, typename C, typename A0>
R pantheios::com::invoke_nothrow_method C *  pThis,
R(stdcallC::*)(A0)  pfn,
A0  a0,
char const *  functionName
[inline]
 

Wraps a 1-parameter class member function in an exception-handler and logs any exceptions using Pantheios.

Parameters:
pThis The instance on which the member function will be invoked
pfn The member function that will be invoked
a0 The argument to the function
functionName The name of the function, used in any logging messages

pantheios Library documentation © Matthew Wilson, 2006 SourceForge.net Logo