Main Page | 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< DescriptionnewDescription (const XmlDescriptionNode &node)=0
 Constructs a new instance of a Description from data contained in an XmlDescriptionNode.
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.
virtual void typeNameType (const String &typeName, Type type)=0
 Associates a type constant with a particular type name.
virtual Type typeNameType (const String &typeName) const =0
 Gets the type constant previously associated with the given type name.
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.

virtual Ptr<Description> Phx::Description::Manager::newDescription const XmlDescriptionNode node  )  [pure virtual]
 

Constructs a new instance of a Description from data contained in an XmlDescriptionNode.

Parameters:
node An XmlDescriptionNode containing data for the Description.
Returns:
A smart pointer to a new Description instance constructed from the data in node.
Note:
This interface is safely accessible by multiple concurrent clients.
Exceptions:
NotFoundException thrown if node.type() is not a known description type name, or if that type name has no listener.

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 T>& 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.

virtual Type Phx::Description::Manager::typeNameType const String &  typeName  )  const [pure virtual]
 

Gets the type constant previously associated with the given type name.

Parameters:
typeName The name of the type whose type constant is sought.
Note:
This interface is safely accessible from multiple clients.
Returns:
Returns the type constant for typeName previously set in typeNameType(const String&, Type), or INVALID_TYPE, if no type constant is known for the given name.

virtual void Phx::Description::Manager::typeNameType const String &  typeName,
Type  type
[pure virtual]
 

Associates a type constant with a particular type name.

Like NamedInterface::Manager, this allows one to specify a correspondence between a particular type name and a type constant. The Manager uses this to parse XML files and other textual content that does not specify a type constant, but only a type name. In these cases, the manager will use the data from this attribute to translate the text type name to a type constant in order to construct a new Description.

Parameters:
typeName The description type name.
type The corresponding type constant for the type name.
Note:
This interface is safely accessible from multiple clients.
Exceptions:
InUseException thrown if typeName already has a type set.


The documentation for this class was generated from the following file:
Generated on Mon Jul 10 19:45:29 2006 for Phoenix OSFS by  doxygen 1.4.2