Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Phx::Description::Manager Class Reference

A manager accessory type to Description that keeps track of Description types and creates new instances. More...

#include <PhxDescription.h>

Inheritance diagram for Phx::Description::Manager:

Phx::LockedPtrInterface< Description::Manager > List of all members.

Public Member Functions

virtual Ptr< DescriptionnewDescription (Description::Type type)=0
 Constructs a new instance of a Description with the specified type and returns a pointer to it.
virtual Ptr< DescriptionnewDescription (const Ptr< const Description > &description)=0
 Constructs a new instance of a Description that matches the given Description.
virtual Ptr< const DescriptionfileDescription (const String &filename)=0
 Gets a description specified by a file name.
virtual void typeListener (Description::Type type, TypeListener *listener)=0
 Creates a new type by setting a listener that constructs instances of a description type.
template<class T>
Ptr< TypeListenernewDescriptionType ()
 A convenience method that automatically creates a Description type by installing a standard TypeListener.

Classes

class  DefaultTypeListener
class  TypeListener
 A listener type that is invoked to construct new instances of Description subclasses. More...

Detailed Description

A manager accessory type to Description that keeps track of Description types and creates new instances.

You can install new Description types, as with the NamedInterface::Manager, by setting a Manager::TypeListener for your type constant via typeListener(). You may also use the newDescriptionType() convenience template method.


Member Function Documentation

virtual Ptr<const Description> Phx::Description::Manager::fileDescription const String &  filename  )  [pure virtual]
 

Gets a description specified by a file name.

Note that this call will immediately load the description if it is not in memory. If the description is already loaded, it will return a pointer to the cached copy.

Todo:
In the future, we may provide an asynchronous loading facility to allow large resources to be loaded in the background. A listener would be called back to notify the client when the description was available and could be acquired through this method.
Parameters:
filename The name of the file containing the description. If filename ends in '.xml' the file will be read as an XML file. Otherwise, the file is read as a serialized binary file.
Note:
This interface is safely accessible by multiple concurrent clients.
Exceptions:
NotFoundException thrown if no file with the given name is found.
PermissionException thrown for a file system permission error.
IOException thrown for an IO error while reading the file.

virtual Ptr<Description> Phx::Description::Manager::newDescription const Ptr< const Description > &  description  )  [pure virtual]
 

Constructs a new instance of a Description that matches the given Description.

Parameters:
description The Description that will be cloned.
Returns:
A smart pointer to a new Description instance whose type and attributes match description.
Note:
This interface is safely accessible by multiple concurrent clients.
Exceptions:
NotFoundException thrown if description->type() has no type listener installed (so a clone cannot be constructed).
RangeException thrown if description is 0.

virtual Ptr<Description> Phx::Description::Manager::newDescription Description::Type  type  )  [pure virtual]
 

Constructs a new instance of a Description with the specified type and returns a pointer to it.

Unlike the NamedInterface::Manager, the Description is not stored within this manager after it is created. If it should be made publicly available

Parameters:
type The type constant of the Description subclass that should be constructed.
Returns:
A smart pointer to a new Description instance whose type constant is type.
Note:
This interface is safely accessible by multiple concurrent clients.
Exceptions:
InUseException thrown if name is in use.

template<class T>
Ptr<TypeListener> Phx::Description::Manager::newDescriptionType  )  [inline]
 

A convenience method that automatically creates a Description type by installing a standard TypeListener.

Normally, to create a new description type you would create a TypeListener subclass which implements TypeListener::onNewDescription() to return a new instance of your Description subclass. This is tedious for some systems that want to create many different Description types and simply leave them in the system. To simplify, this (templatized) method automatically constructs a description of the template parameter type to create new instance using the constructor.

You must explicitly supply the template parameter, which must be a type with an accessible constructor with signature: T::T(const Ptr<const Description>& description); and derives, ultimately, from Description.

The class T must also define T::DESCRIPTION_TYPE, a static, const Description::Type value that is the type constant for the description class. This is passed to typeListener() as the type parameter.

Returns:
A smart pointer to the constructed TypeListener.
Note:
This interface is safely accessible from multiple clients.

virtual void Phx::Description::Manager::typeListener Description::Type  type,
TypeListener listener
[pure virtual]
 

Creates a new type by setting a listener that constructs instances of a description type.

The listener is entered into the collection of description types and will be called whenever a new Description of type corresponding to the constant type must be created. When a new description is needed listener->onNewDescription() method will be invoked.

Parameters:
type The type constant for the Description subclass that this listener creates.
listener The TypeListener whose TypeListener::onNewDescription() method will be invoked whenver Description instances with type type are needed.
Note:
This interface is safely accessible from multiple clients.


The documentation for this class was generated from the following file:
Generated on Wed Dec 21 22:05:38 2005 for Phoenix OSFS by  doxygen 1.4.2