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

Phx::NamedInterface::Manager Class Reference

Manages interface types and constructs and manages instances of the NamedInterface class. More...

#include <PhxNamedInterface.h>

Inheritance diagram for Phx::NamedInterface::Manager:

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

Public Member Functions

virtual Ptr< NamedInterfacenewNamedInterface (NamedInterface::Type interfaceType, const Ptr< Description > &description, const String &instanceName, NamedInterface::Identifier identifier)=0
 Constructs a new interface instance of the given type and assigns it the specified name and identifier if possible.
virtual Ptr< NamedInterfacenewNamedInterface (NamedInterface::Type interfaceType, const Ptr< Description > &description, const String &instanceName)=0
virtual Ptr< NamedInterfacenamedInterface (NamedInterface::Identifier identifier) const =0
 Locates and returns a pointer to an interface which is referred to by a given identifier.
virtual Ptr< NamedInterfacenamedInterface (const String &name) const =0
 Locates and returns a pointer to an interface instance which is referred to by a given text name.
virtual void deleteNamedInterface (const Ptr< NamedInterface > &interface)=0
 Deletes an interface from this manager.
virtual void typeListener (NamedInterface::Type type, TypeListener *listener)=0
 Creates a new NamedInterface type by setting a listener that constructs instances of the NamedInterface class.
template<class T>
Ptr< TypeListenernewNamedInterfaceType (void)
 A convenience method that automatically creates an NamedInterface type by installing a standard TypeListener.
virtual void typeNameType (const String &typeName, NamedInterface::Type type)=0
 For a given name, sets the type constant for objects with that type name.
virtual NamedInterface::Type typeNameType (const String &typeName) const =0
 Retrives the type associated with a particular type name.

Static Public Attributes

static const NamedInterface::Type INTERFACE_TYPE
static const String INTERFACE_TYPE_NAME

Protected Member Functions

void setNamedInterfaceType (const Ptr< NamedInterface > &interface, NamedInterface::Type type)
void setNamedInterfaceName (const Ptr< NamedInterface > &interface, const String &name)
void setNamedInterfaceIdentifier (const Ptr< NamedInterface > &interface, NamedInterface::Identifier identifier)

Classes

class  DefaultTypeListener
class  TypeListener
 A listener class which is used to call back the client to create and delete instances of a NamedInterface. More...

Detailed Description

Manages interface types and constructs and manages instances of the NamedInterface class.

The manager provides for simple creation of objects by type via newNamedInterface().

You can register a new interface type by installing a TypeListener for that type.


Member Function Documentation

virtual void Phx::NamedInterface::Manager::deleteNamedInterface const Ptr< NamedInterface > &  interface  )  [pure virtual]
 

Deletes an interface from this manager.

This will remove any references to the given interface from this manager. When the object that is referred to by the given interface pointer needs to be removed from the system, this method should be called. This will unregister the instance name of the interface if it had one.

Note that the object itself may not actually be freed. If other objects in the system are still holding Ptr references to it, then it may remain in existence until they release their references. This call simply releases the manager from the responsibility of keeping track of the object.

Managers must be careful since releasing the final reference to an object may have unforseen consequences within the simulation. While not required, it is highly recommended that managers defer deletion of objects until it is known to be safe. The standard Manager provided by Core does exactly this.

Todo:
Should we require that deferred deletion always be implemented?
Parameters:
interface The interface to be removed from the manager.
Note:
This interface is safely accessible by multiple concurrent clients.
Exceptions:
NotFoundException Thrown if interface's identifier is not found in this manager.
InternalException Thrown if interface's identifier is found, but it has a non-null name that was not found.

virtual Ptr<NamedInterface> Phx::NamedInterface::Manager::namedInterface const String &  name  )  const [pure virtual]
 

Locates and returns a pointer to an interface instance which is referred to by a given text name.

Parameters:
name The text name for the interface to be returned. This is the name that was set for the instance when it was created via newNamedInterface().
Returns:
The requested interface whose name is name, or NULL if there is no interface instance with the given name in this manager.
Note:
This interface is safely accessible by multiple concurrent clients.

virtual Ptr<NamedInterface> Phx::NamedInterface::Manager::namedInterface NamedInterface::Identifier  identifier  )  const [pure virtual]
 

Locates and returns a pointer to an interface which is referred to by a given identifier.

Parameters:
identifier The identifier associated with the interface that should be returned.
Returns:
The requested interface associated with identifier or NULL if there is no interface with the given identifier in this manager.
Note:
This interface is safely accessible by multiple concurrent clients.

virtual Ptr<NamedInterface> Phx::NamedInterface::Manager::newNamedInterface NamedInterface::Type  interfaceType,
const Ptr< Description > &  description,
const String &  instanceName,
NamedInterface::Identifier  identifier
[pure virtual]
 

Constructs a new interface instance of the given type and assigns it the specified name and identifier if possible.

Parameters:
interfaceType The type constant of the interface class of which an instance should be returned.
description A pointer to an appropriately typed Description that contains data for the NamedInterface to use during construction.
instanceName The instance name of this object. This is an optional name that can be used to look up the object by name later. You can avoid using such a name by simply passing "", in which case the argument is ignored. If the name is in use by another object and exception is thrown.
identifier The requested identifier for the new object. If the identifier is illegal or in use an exception is thrown.
Returns:
A pointer to the new object instance. This is guaranteed to be non-null. An exception is thrown otherwise.
Exceptions:
RangeException thrown if identifier is out of the legal range.
InUseException thrown if identifier or instanceName requested cannot be assigned to this instance because it is in use.
NotFoundException thrown if a type listener for interfaceType could not be found.
Note:
This interface is safely accessible by multiple concurrent clients.

template<class T>
Ptr<TypeListener> Phx::NamedInterface::Manager::newNamedInterfaceType void   )  [inline]
 

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

Normally, to create a new NamedInterface type you would create a TypeListener subclass which implements TypeListener::onNewNamedInterface() and onDeleteNamedInterface().

This is tedious for many situations. To simplify things, this (templatized) method automatically constructs a listener that will create an instance of the template parameter, and does nothing on interface deletion.

You must explicitly supply the template parameter, which must be a type with a constructor of the form T::T(const Ptr<Description>&, const String&, NamedInterface::Identifier, const NamedInterface::Manager*) and also must derive, ultimately, from NamedInterface.

The first three parameters passed to the constructor are the values that are passed to TypeListener::onNewNamedInterface(). The last parameter is a pointer to the interface manager in which the constructed object will reside.

T must also supply two public, const static data members. T::INTERFACE_TYPE is of type NamedInterface::Type and its value is the assigned type constant for the class (this is the type parameter passed to typeListener()). T::INTERFACE_TYPE_NAME is of type String and its value is the assigned type name for the class (this is the typeName parameter of typeNameType()).

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

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

Creates a new NamedInterface type by setting a listener that constructs instances of the NamedInterface class.

The listener's onNewNamedInterface() and onDeleteNamedInterface() methods will be called whenever NamedInterface's of type type are created or deleted.

Parameters:
type The type constant for the Description subclass that this listener creates.
listener The TypeListener whose methods will be invoked whenver NamedInterface instances with type type are needed.
Note:
This interface is safely accessible from multiple clients.
Exceptions:
InUseException thrown if the type is used used by another type.

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

Retrives the type associated with a particular type name.

Parameters:
typeName The type name whose corresponding type constant should be returned.
Returns:
The type constant that was set by a call to typeNameType(String, NamedInterface::Type). Returns NamedInterface::INVALID_TYPE if no type constant is set for that name.
Note:
This interface is safely accessible from multiple concurrent clients.

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

For a given name, sets the type constant for objects with that type name.

Note that it is possible to associate multiple type names to the same type. However, this is presently not recommended.

Parameters:
typeName The type name whose corresponding type is type.
type The type which will be associated with the given name.
InUseException thrown if typeName has a different type that type already set for it.

Note:
This interface is safely accessible from multiple concurrent 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