LAMA
lama::ContextFactory Class Reference

Singleton class that provides (shared) pointers to a context. More...

#include <ContextFactory.hpp>

Inheritance diagram for lama::ContextFactory:

Public Member Functions

ContextManagergetContextManager (const Context::ContextType type)
 This method can be used to get access to a context so that data can be allocated on it.
void addContextManager (const Context::ContextType type, ContextManager &contextManager)
 Each context type that should be supported must add its context manager so that the the factory can forward a query for a context type to the corresponding manager.

Static Public Member Functions

static ContextPtr getContext (const Context::ContextType type, int deviceNr=LAMA_DEFAULT_DEVICE_NUMBER)
 This method can be used to get access to a context so that data can be allocated on it.
static bool hasContext (const Context::ContextType type)
 checks if a context of the passed type is available.
static ContextFactorygetFactory ()
 Method that returns a reference to the context factory.
static void release ()
 Release all context managers.

Private Member Functions

 ContextFactory ()
virtual ~ContextFactory ()
 LAMA_LOG_DECL_STATIC_LOGGER (logger)

Private Attributes

ContextManagermContextManager [Context::MaxContext]
 Each possible context will have its own context manager.

Static Private Attributes

static const char * theContextIds [Context::MaxContext]
 Set NULL manager as defaults for all devices.
static ContextFactorytheContextFactory = NULL

Detailed Description

Singleton class that provides (shared) pointers to a context.

of a given type.

Each context is returned via a shared pointer so the context is freed automatically if no more reference is kept.

For each supported context type a context manager must register to the factory otherwise the type remains unsupported.


Constructor & Destructor Documentation

lama::ContextFactory::~ContextFactory ( ) [private, virtual]

Member Function Documentation

Each context type that should be supported must add its context manager so that the the factory can forward a query for a context type to the corresponding manager.

Parameters:
[in]typeis the type of context for which the manager is responsibile
[in]contextManagerreference to the manager for all contexts of a given type.

References LAMA_ASSERT_DEBUG.

Referenced by lama::ContextManager::registerFactory().

This method can be used to get access to a context so that data can be allocated on it.

The shared pointer guarantees that a context will live at least as long as arrays are allocated on it.

Parameters:
[in]typeis the type of context that is wanted
[in]deviceNris used for multiple devices of the same type (default is LAMA_DEFAULT_DEVICE_NUMBER)
Returns:
a context of the requested type, if available.
Exceptions:
Exceptionif the context of the requested type is not available

References LAMA_ASSERT_DEBUG.

Referenced by lama::MatrixConfigGrammar::MatrixConfigGrammar().

Method that returns a reference to the context factory.

Referenced by lama::MatrixConfigGrammar::MatrixConfigGrammar(), and lama::ContextManager::registerFactory().

checks if a context of the passed type is available.

Parameters:
[in]typeis the type of context that is wanted
Returns:
if a context of the passed type is available

References mContextManager.

void lama::ContextFactory::release ( ) [static]

Release all context managers.

References mContextManager.


Field Documentation

Each possible context will have its own context manager.

Referenced by getContext(), hasContext(), and release().

const char * lama::ContextFactory::theContextIds [static, private]
Initial value:
 { "HostContext",
                                                "CudaContext",
                                                "OpenCLContext"

                                               }

Set NULL manager as defaults for all devices.


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