ork::ResourceTemplate< o, C > Class Template Reference
[resource]

A template Resource class to ease the implementation of concrete Resource subclasses. More...

#include <ResourceTemplate.h>

Inheritance diagram for ork::ResourceTemplate< o, C >:
ork::Resource

List of all members.

Public Member Functions

 ResourceTemplate (ptr< ResourceManager > manager, const string &name, ptr< ResourceDescriptor > desc)
 Creates a new resource of class C.
virtual int getUpdateOrder ()
 Returns the template parameter o.
virtual bool prepareUpdate ()
 If the descriptor of this method has not changed, does nothing and returns true.
virtual void doUpdate (bool commit)
 If commit is true swaps the desc and newDesc fields, and sets the oldValue to NULL.
virtual bool changed ()
 Returns true if this resource has changed.

Protected Member Functions

virtual void doRelease ()
 Calls ResourceManager::releaseResource to release this resource.

Protected Attributes

ptr< C > oldValue
 The old value of this resource.

Detailed Description

template<int o, class C>
class ork::ResourceTemplate< o, C >

A template Resource class to ease the implementation of concrete Resource subclasses.

This template class takes care of the two phase commit for the update of resources, provided that the actual resource class implements a swap(ptr<C>) method that can swap two instances of resources of class C.

Template Parameters:
o the update order of resources of class C (see getUpdateOrder).
C the concrete resource class.

Constructor & Destructor Documentation

template<int o, class C >
ork::ResourceTemplate< o, C >::ResourceTemplate ( ptr< ResourceManager manager,
const string &  name,
ptr< ResourceDescriptor desc 
) [inline]

Creates a new resource of class C.

Parameters:
manager the manager that will keep track of this resource.
name the name of this resource.
desc the descriptor of this resource.

Member Function Documentation

template<int o, class C >
bool ork::ResourceTemplate< o, C >::changed (  )  [inline, virtual]

Returns true if this resource has changed.

Reimplemented from ork::Resource.

template<int o, class C >
void ork::ResourceTemplate< o, C >::doRelease (  )  [inline, protected, virtual]

Calls ResourceManager::releaseResource to release this resource.

template<int o, class C >
void ork::ResourceTemplate< o, C >::doUpdate ( bool  commit  )  [inline, virtual]

If commit is true swaps the desc and newDesc fields, and sets the oldValue to NULL.

If commit is false reverts the changes made in prepareUpdate by swapping again this instance with oldValue.

Implements ork::Resource.

template<int o, class C >
int ork::ResourceTemplate< o, C >::getUpdateOrder (  )  [inline, virtual]

Returns the template parameter o.

Implements ork::Resource.

template<int o, class C >
bool ork::ResourceTemplate< o, C >::prepareUpdate (  )  [inline, virtual]

If the descriptor of this method has not changed, does nothing and returns true.

Otherwise creates a new instance of this resource using the new descriptor newDesc and then swaps it with this instance, saving the current value in oldValue. If the resource creation fails, does nothing and returns false.

Reimplemented from ork::Resource.


Member Data Documentation

template<int o, class C >
ptr<C> ork::ResourceTemplate< o, C >::oldValue [protected]

The old value of this resource.


Generated on Mon Oct 18 09:36:11 2010 for ork by  doxygen 1.6.1