initialiser Class Template Reference
[COM Utility Library]

#include <comstl/util/initialisers.hpp>

List of all members.


Detailed Description

template<typename IP, typename XP>
class comstl::initialiser< IP, XP >

Initialises the COM libraries.

This class is used to initialise the COM libraries. It can respond to CoInitializeEx argument flags when translated in a DCOM build.

It is specialised for COM or OLE library initialisation, and with or without throwing an exception on failure, in the following typedefs:

It is commonly used within main() (for a CLI program), or WinMain() (for a GUI program). A typical program structure is shown as follows:

#include <comstl/util/initialisers.hpp>

#include <stdlib.h>

static int main_(int argc, char **argv)
{
  . . . // main application functionality
}

int main(int argc, char **argv)
{
  try
  {
    comstl::com_init  init; // Initialise the COM libraries

    return main_(argc, argv);
  }
  catch(comstl::com_initialisation_exception &x) // COM library initialisation failed
  {
    return EXIT_FAILURE;
  }
  catch(std::exception &x) // other failures from main_()
  {
    return EXIT_FAILURE;
  }
}

In practice, initialisation failure of the COM libraries is unheard of, so you can probably dispense with the specific catch clause shown above, and rely on comstl::com_initialisation_exception being caught by the std::exception clause.

See also:
comstl::
Examples:

by_library/com_utility/creation_functions/creation_functions.cpp, by_library/com_utility/rot_functions/rot_functions.cpp, by_library/memory/com_memory_functions/com_memory_functions.cpp, and by_project/comstl/comstl.cpp.


Member Types

typedef IP initialisation_policy_type
 The initialiation policy type.
typedef XP exception_policy_type
 The exception type.
typedef
exception_policy_type::thrown_type 
thrown_type
 The thrown type.

Public Member Functions

Construction
 initialiser ()
 Initialises via CoInitialize().
 ~initialiser () throw ()
 Uninitialises via CoUninitialize().
Attributes
bool is_initialised () const
 Reflects whether the COM libraries were initialised.
bool operator! () const
 Reflects whether the COM libraries were not initialised.
HRESULT get_HRESULT () const
 The result of the call to CoInitialize()/CoInitializeEx().

Member Typedef Documentation

The initialiation policy type.

The exception type.

typedef exception_policy_type::thrown_type thrown_type

The thrown type.


Constructor & Destructor Documentation

initialiser (  )  [inline]

Initialises via CoInitialize().

~initialiser (  )  throw () [inline]

Uninitialises via CoUninitialize().

References initialiser::is_initialised().


Member Function Documentation

bool is_initialised (  )  const [inline]

Reflects whether the COM libraries were initialised.

Referenced by initialiser::operator!(), and initialiser::~initialiser().

bool operator! (  )  const [inline]

Reflects whether the COM libraries were not initialised.

References initialiser::is_initialised().

HRESULT get_HRESULT (  )  const [inline]

The result of the call to CoInitialize()/CoInitializeEx().


The documentation for this class was generated from the following file:

Generated on Thu Jun 10 08:58:27 2010 for STLSoft by  doxygen 1.5.6