Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/putil/factory.I

Go to the documentation of this file.
00001 // Filename: factory.I
00002 // Created by:  drose (08May00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 ////////////////////////////////////////////////////////////////////
00020 //     Function: Factory::make_instance
00021 //       Access: Public
00022 //  Description: Attempts to create a new instance of some class of
00023 //               the indicated type, or some derivative if necessary.
00024 //               If an instance of the exact type cannot be created,
00025 //               the specified preferred will specify which derived
00026 //               class will be preferred.
00027 ////////////////////////////////////////////////////////////////////
00028 template<class Type>
00029 INLINE Type *Factory<Type>::
00030 make_instance(TypeHandle handle, const FactoryParams &params) {
00031   return (Type *)FactoryBase::make_instance(handle, params);
00032 }
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //     Function: Factory::make_instance
00036 //       Access: Public
00037 //  Description: Attempts to create a new instance of some class of
00038 //               the indicated type, or some derivative if necessary.
00039 //               If an instance of the exact type cannot be created,
00040 //               the specified preferred will specify which derived
00041 //               class will be preferred.
00042 //
00043 //               This flavor of make_instance() accepts a string name
00044 //               that indicates the desired type.  It must be the name
00045 //               of some already-registered type.
00046 ////////////////////////////////////////////////////////////////////
00047 template<class Type>
00048 INLINE Type *Factory<Type>::
00049 make_instance(const string &type_name, const FactoryParams &params) {
00050   return (Type *)FactoryBase::make_instance(type_name, params);
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: Factory::make_instance_more_general
00055 //       Access: Public
00056 //  Description: Attempts to create an instance of the type requested,
00057 //               or some base type of the type requested.  Returns the
00058 //               new instance created, or NULL if the instance could
00059 //               not be created.
00060 ////////////////////////////////////////////////////////////////////
00061 template<class Type>
00062 INLINE Type *Factory<Type>::
00063 make_instance_more_general(TypeHandle handle, const FactoryParams &params) {
00064   return (Type *)FactoryBase::make_instance_more_general(handle, params);
00065 }
00066 
00067 ////////////////////////////////////////////////////////////////////
00068 //     Function: Factory::make_instance_more_general
00069 //       Access: Public
00070 //  Description: Attempts to create an instance of the type requested,
00071 //               or some base type of the type requested.  Returns the
00072 //               new instance created, or NULL if the instance could
00073 //               not be created.
00074 //
00075 //               This flavor of make_instance_more_general() accepts a
00076 //               string name that indicates the desired type.  It must
00077 //               be the name of some already-registered type.
00078 ////////////////////////////////////////////////////////////////////
00079 template<class Type>
00080 INLINE Type *Factory<Type>::
00081 make_instance_more_general(const string &type_name,
00082                            const FactoryParams &params) {
00083   return (Type *)FactoryBase::make_instance_more_general(type_name, params);
00084 }
00085 
00086 ////////////////////////////////////////////////////////////////////
00087 //     Function: Factory::register_factory
00088 //       Access: Public
00089 //  Description: Registers a new kind of thing the Factory will be
00090 //               able to create.
00091 ////////////////////////////////////////////////////////////////////
00092 template<class Type>
00093 INLINE void Factory<Type>::
00094 register_factory(TypeHandle handle, CreateFunc *func) {
00095   FactoryBase::register_factory(handle, (BaseCreateFunc *)func);
00096 }

Generated on Fri May 2 00:43:37 2003 for Panda by doxygen1.3