Panda3D
Public Types | Public Member Functions

Factory< Type > Class Template Reference

A Factory can be used to create an instance of a particular subclass of some general base class. More...

#include "factory.h"

Inheritance diagram for Factory< Type >:
FactoryBase

List of all members.

Public Types

typedef Type * CreateFunc (const FactoryParams &params)

Public Member Functions

Type * make_instance (TypeHandle handle, const FactoryParams &params=FactoryParams())
 Attempts to create a new instance of some class of the indicated type, or some derivative if necessary.
Type * make_instance (const string &type_name, const FactoryParams &params=FactoryParams())
 Attempts to create a new instance of some class of the indicated type, or some derivative if necessary.
Type * make_instance_more_general (const string &type_name, const FactoryParams &params=FactoryParams())
 Attempts to create an instance of the type requested, or some base type of the type requested.
Type * make_instance_more_general (TypeHandle handle, const FactoryParams &params=FactoryParams())
 Attempts to create an instance of the type requested, or some base type of the type requested.
void register_factory (TypeHandle handle, CreateFunc *func)
 Registers a new kind of thing the Factory will be able to create.

Detailed Description

template<class Type>
class Factory< Type >

A Factory can be used to create an instance of a particular subclass of some general base class.

Each subclass registers itself with the Factory, supplying a function that will construct an instance of that subclass; the Factory can later choose a suitable subclass and return a newly-constructed pointer to an object of that type on the user's demand. This is used, for instance, to manage the set of GraphicsPipes available to the user.

This is a thin template wrapper around FactoryBase. All it does is ensure the types are correctly cast. All of its methods are inline, and it has no data members, so it is not necessary to export the class from the DLL.

Definition at line 41 of file factory.h.


Member Function Documentation

template<class Type >
Type * Factory< Type >::make_instance ( TypeHandle  handle,
const FactoryParams params = FactoryParams() 
) [inline]

Attempts to create a new instance of some class of the indicated type, or some derivative if necessary.

If an instance of the exact type cannot be created, the specified preferred will specify which derived class will be preferred.

Reimplemented from FactoryBase.

Definition at line 26 of file factory.I.

References FactoryBase::make_instance().

template<class Type >
Type * Factory< Type >::make_instance ( const string &  type_name,
const FactoryParams params = FactoryParams() 
) [inline]

Attempts to create a new instance of some class of the indicated type, or some derivative if necessary.

If an instance of the exact type cannot be created, the specified preferred will specify which derived class will be preferred.

This flavor of make_instance() accepts a string name that indicates the desired type. It must be the name of some already-registered type.

Reimplemented from FactoryBase.

Definition at line 45 of file factory.I.

References FactoryBase::make_instance().

template<class Type >
Type * Factory< Type >::make_instance_more_general ( const string &  type_name,
const FactoryParams params = FactoryParams() 
) [inline]

Attempts to create an instance of the type requested, or some base type of the type requested.

Returns the new instance created, or NULL if the instance could not be created.

This flavor of make_instance_more_general() accepts a string name that indicates the desired type. It must be the name of some already-registered type.

Reimplemented from FactoryBase.

Definition at line 77 of file factory.I.

References FactoryBase::make_instance_more_general().

template<class Type >
Type * Factory< Type >::make_instance_more_general ( TypeHandle  handle,
const FactoryParams params = FactoryParams() 
) [inline]

Attempts to create an instance of the type requested, or some base type of the type requested.

Returns the new instance created, or NULL if the instance could not be created.

Reimplemented from FactoryBase.

Definition at line 59 of file factory.I.

References FactoryBase::make_instance_more_general().

template<class Type >
void Factory< Type >::register_factory ( TypeHandle  handle,
CreateFunc *  func 
) [inline]

Registers a new kind of thing the Factory will be able to create.

Definition at line 90 of file factory.I.

References FactoryBase::register_factory().

Referenced by SpeedTreeNode::register_with_read_factory(), RecorderTable::register_with_read_factory(), RecorderHeader::register_with_read_factory(), RecorderFrame::register_with_read_factory(), MouseRecorder::register_with_read_factory(), BamCacheRecord::register_with_read_factory(), BamCacheIndex::register_with_read_factory(), UvScrollNode::register_with_read_factory(), SwitchNode::register_with_read_factory(), Spotlight::register_with_read_factory(), SequenceNode::register_with_read_factory(), PointLight::register_with_read_factory(), LODNode::register_with_read_factory(), FadeLODNode::register_with_read_factory(), DirectionalLight::register_with_read_factory(), CallbackNode::register_with_read_factory(), AmbientLight::register_with_read_factory(), TransparencyAttrib::register_with_read_factory(), TransformState::register_with_read_factory(), TextureAttrib::register_with_read_factory(), TexProjectorEffect::register_with_read_factory(), TexMatrixAttrib::register_with_read_factory(), TexGenAttrib::register_with_read_factory(), StencilAttrib::register_with_read_factory(), ShowBoundsEffect::register_with_read_factory(), ShadeModelAttrib::register_with_read_factory(), ScissorEffect::register_with_read_factory(), ScissorAttrib::register_with_read_factory(), RescaleNormalAttrib::register_with_read_factory(), RenderState::register_with_read_factory(), RenderModeAttrib::register_with_read_factory(), RenderEffects::register_with_read_factory(), PortalNode::register_with_read_factory(), PolylightNode::register_with_read_factory(), PlaneNode::register_with_read_factory(), PandaNode::register_with_read_factory(), OccluderNode::register_with_read_factory(), OccluderEffect::register_with_read_factory(), ModelRoot::register_with_read_factory(), ModelNode::register_with_read_factory(), MaterialAttrib::register_with_read_factory(), LightRampAttrib::register_with_read_factory(), LightAttrib::register_with_read_factory(), LensNode::register_with_read_factory(), GeomNode::register_with_read_factory(), FogAttrib::register_with_read_factory(), Fog::register_with_read_factory(), DepthWriteAttrib::register_with_read_factory(), DepthTestAttrib::register_with_read_factory(), DepthOffsetAttrib::register_with_read_factory(), DecalEffect::register_with_read_factory(), CullFaceAttrib::register_with_read_factory(), CullBinAttrib::register_with_read_factory(), CompassEffect::register_with_read_factory(), ColorWriteAttrib::register_with_read_factory(), ColorScaleAttrib::register_with_read_factory(), ColorBlendAttrib::register_with_read_factory(), ColorAttrib::register_with_read_factory(), ClipPlaneAttrib::register_with_read_factory(), Camera::register_with_read_factory(), BillboardEffect::register_with_read_factory(), AuxBitplaneAttrib::register_with_read_factory(), AudioVolumeAttrib::register_with_read_factory(), AntialiasAttrib::register_with_read_factory(), AlphaTestAttrib::register_with_read_factory(), SheetNode::register_with_read_factory(), RopeNode::register_with_read_factory(), NurbsCurve::register_with_read_factory(), HermiteCurve::register_with_read_factory(), CubicCurveseg::register_with_read_factory(), UserVertexTransform::register_with_read_factory(), UserVertexSlider::register_with_read_factory(), TransformTable::register_with_read_factory(), TransformBlendTable::register_with_read_factory(), TextureStage::register_with_read_factory(), Texture::register_with_read_factory(), SliderTable::register_with_read_factory(), PerspectiveLens::register_with_read_factory(), OrthographicLens::register_with_read_factory(), MatrixLens::register_with_read_factory(), Material::register_with_read_factory(), InternalName::register_with_read_factory(), GeomVertexFormat::register_with_read_factory(), GeomVertexData::register_with_read_factory(), GeomVertexArrayFormat::register_with_read_factory(), GeomVertexArrayData::register_with_read_factory(), GeomTristrips::register_with_read_factory(), GeomTrifans::register_with_read_factory(), GeomTriangles::register_with_read_factory(), GeomPoints::register_with_read_factory(), GeomLinestrips::register_with_read_factory(), GeomLines::register_with_read_factory(), Geom::register_with_read_factory(), EventStoreValue< Type >::register_with_read_factory(), ButtonEventList::register_with_read_factory(), DataNodeTransmit::register_with_read_factory(), CollisionTube::register_with_read_factory(), CollisionSphere::register_with_read_factory(), CollisionSegment::register_with_read_factory(), CollisionRay::register_with_read_factory(), CollisionPolygon::register_with_read_factory(), CollisionPlane::register_with_read_factory(), CollisionParabola::register_with_read_factory(), CollisionNode::register_with_read_factory(), CollisionLine::register_with_read_factory(), CollisionInvSphere::register_with_read_factory(), CollisionFloorMesh::register_with_read_factory(), CollisionBox::register_with_read_factory(), JointVertexTransform::register_with_read_factory(), CharacterVertexSlider::register_with_read_factory(), CharacterSlider::register_with_read_factory(), CharacterJointEffect::register_with_read_factory(), CharacterJointBundle::register_with_read_factory(), CharacterJoint::register_with_read_factory(), Character::register_with_read_factory(), PartGroup::register_with_read_factory(), PartBundle::register_with_read_factory(), MovingPartScalar::register_with_read_factory(), MovingPartMatrix::register_with_read_factory(), AnimPreloadTable::register_with_read_factory(), AnimGroup::register_with_read_factory(), AnimChannelScalarTable::register_with_read_factory(), AnimChannelScalarDynamic::register_with_read_factory(), AnimChannelMatrixXfmTable::register_with_read_factory(), AnimChannelMatrixFixed::register_with_read_factory(), AnimChannelMatrixDynamic::register_with_read_factory(), AnimBundleNode::register_with_read_factory(), AnimBundle::register_with_read_factory(), and CFDoCullCommand::register_with_read_factory().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations