Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide

RWFactory

Module:  Essential Tools Module   Group:  RWCollectable


RWFactoryRWSet

Local Index

Members

Synopsis

typedef unsigned short  RWClassID;
typedef RWCollectable*  (*RWuserCreator)();
#include <rw/factory.h>
RWFactory* theFactory;

Description

Class RWFactory can create an instance of an RWCollectable object, given a class ID. It does this by maintaining a table of class IDs and associated "creator functions." A creator function has prototype:

This function should create an instance of a particular class. For a given RWClassID tag, the appropriate function is selected, invoked and the resultant pointer returned. Because any object created this way is created off the heap, you are responsible for deleting it when done.

There is a one-of-a-kind global RWFactory which can be accessed using getRWFactory(). It is guaranteed to have creator functions in it for all of the classes referenced by your program. See also the section in the User's Guide about RWFactory.

Persistence

None

Example

Public Constructors

RWFactory();

Public Destructor

~RWFactory();

Public Operator

RWBoolean
operator<=(const RWFactory& h);

Public Member Functions

void
addFunction(RWuserCreator uc, RWClassID id);
void
addFunction(RWuserCreator uc, RWClassID id,RWStringID sid);
RWClassID
classID(RWStringID) const;
RWCollectable*
create(RWClassID id) const;
RWCollectable*
create(RWString sid) const;
RWuserCreator
getFunction(RWClassID id) const;
RWuserCreator
getFunction(RWStringID sid) const;
void
removeFunction(RWClassID id);
void
removeFunction(RWStringID sid);
RWStringID
stringID(RWClassID id) const;


Previous fileTop of DocumentContentsIndex pageNext file

©2004 Copyright Quovadx, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.