Service< T > Class Template Reference

This class simplifies use of Services classes. More...

#include <Service.h>

Inheritance diagram for Service< T >:

Inheritance graph

List of all members.

Public Member Functions

T * get () const
T * operator-> () const


Detailed Description

template<class T>
class Service< T >

This class simplifies use of Services classes.

For example, the following code:

   ModelServices* pModelServices = NULL;
   ModuleManager::instance()->getService()->queryInterface("ModelServices2", reinterpret_cast<void**>(&pModelServices));
   bool bHasElement = pModelServices->hasElementType("AoiElement");

Would instead be:

   Service<ModelServices> pModelServices;
   bool bHasElement = pModelServices->hasElementType("AoiElement");

The following can also be done:

   bool bHasElement = Service<ModelServices>()->hasElementType("AoiElement");

This templated class can ONLY be used with the defined template specializations or a link-time error will occur. The specializations are:

Examples:

Tutorial/Tutorial1.cpp, Tutorial/Tutorial2.cpp, Tutorial/Tutorial3.cpp, Tutorial/Tutorial4.cpp, and Tutorial/Tutorial5.cpp.

Definition at line 50 of file Service.h.


Member Function Documentation

template<class T>
T* Service< T >::get (  )  const

Provides direct access to the Service pointer.

Returns:
A pointer of type T. No implementation is provided in order to force specialization. Specialized methods need to ensure that NULL will never be returned.

template<class T>
T* Service< T >::operator-> (  )  const

Allows the held Service pointer to be used with pointer indirection.

Returns:
A pointer of type T; for all template specializations, this is guaranteed to be non-null.

Definition at line 68 of file Service.h.


Software Development Kit - Opticks 4.9.0 Build 16218