SourcePro C++ 13.0 |
SourcePro® C++ API Reference Guide |
Product Documentation: SourcePro C++ Documentation Home |
Creates an instance of an RWCollectable object, given a class ID. More...
#include <rw/factory.h>
Related Functions | |
(Note that these are not member functions.) | |
RWFactory * | getRWFactory () |
typedef RWCollectable *(* | RWuserCreator )() |
Additional Inherited Members | |
Static Public Member Functions inherited from RWCollectable | |
static RWClassID | classID (const RWStringID &name) |
static RWClassID | classIsA () |
static bool | isAtom (RWClassID id) |
static RWspace | nilStoreSize () |
Static Public Attributes inherited from RWCollection | |
static size_t | DEFAULT_CAPACITY |
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 the prototype:
This function creates 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.
A one-of-a-kind global RWFactory can be accessed using getRWFactory(). It is guaranteed to have creator functions in it for all of the classes referenced by your program. See the section in the Essential Tools Module User's Guide about RWFactory.
None
Program output:
RWFactory::RWFactory | ( | ) |
Constructs an RWFactory.
RWFactory::~RWFactory | ( | ) |
Calls clearAndDestroy(), which is inherited from RWSet.
void RWFactory::addFunction | ( | RWuserCreator | uc, |
RWClassID | id | ||
) |
void RWFactory::addFunction | ( | RWuserCreator | uc, |
RWClassID | id, | ||
RWStringID | sid | ||
) |
Adds to RWFactory the global function pointed to by uc, which creates an instance of an object with RWClassID id and RWStringID sid.
RWCollectable* RWFactory::create | ( | RWClassID | id | ) | const |
RWCollectable* RWFactory::create | ( | RWStringID | sid | ) | const |
Allocates a new instance of the class with RWStringID sid off the heap and returns a pointer to it. Returns rwnil if sid does not exist. Because this instance is allocated off the heap, you are responsible for deleting it when done.
RWClassID RWFactory::getClassID | ( | RWStringID | sid | ) | const |
Looks up the RWClassID associated with sid and returns it. If there is no such association, returns __RWUNKNOWN
.
RWuserCreator RWFactory::getFunction | ( | RWClassID | id | ) | const |
RWuserCreator RWFactory::getFunction | ( | RWStringID | sid | ) | const |
Returns from RWFactory a pointer to the global function associated with RWStringID sid. Returns rwnil if sid does not exist.
RWStringID RWFactory::getStringID | ( | RWClassID | id | ) | const |
Looks up the RWStringID associated with id and returns it. If there is no such association, returns RWStringID("NoID").
|
inline |
Returns true
if self is a subset of h, that is, every element of self has a counterpart in h which isEqual().
This operator is included to fix an inconsistency in the C++ language. It is not explicitly present unless you are compiling with an implementation of the C++ Standard Library. It would normally be inherited from RWSet.
|
inline |
Returns true
if self is a subset of h, that is, every element of self has a counterpart in h which isEqual().
This operator is included to fix an inconsistency in the C++ language. It is not explicitly present unless you are compiling with an implementation of the C++ Standard Library. It would normally be inherited from RWSet.
|
inline |
Returns true
if self is a subset of h, that is, every element of self has a counterpart in h which isEqual().
This operator is included to fix an inconsistency in the C++ language. It is not explicitly present unless you are compiling with an implementation of the C++ Standard Library. It would normally be inherited from RWSet.
void RWFactory::removeFunction | ( | RWClassID | id | ) |
void RWFactory::removeFunction | ( | RWStringID | sid | ) |
Removes from RWFactory the global function associated with RWStringID sid. If sid does not exist in the factory, no action is taken.
|
related |
Returns a pointer to the global RWFactory object instance, creating it if necessary.
|
related |
A global function used to allocate a RWCollectable derived class for RWFactory. A creator function has prototype:
Copyright © 2014 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.