Panda3D
 All Classes Functions Variables Enumerations
factoryBase.I
00001 // Filename: factoryBase.I
00002 // Created by:  drose (08May00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: FactoryBase::make_instance
00018 //       Access: Public
00019 //  Description: Attempts to create a new instance of some class of
00020 //               the indicated type, or some derivative if necessary.
00021 //               If an instance of the exact type cannot be created,
00022 //               the specified priorities will specify which derived
00023 //               class will be preferred.
00024 //
00025 //               This flavor of make_instance() accepts a string name
00026 //               that indicates the desired type.  It must be the name
00027 //               of some already-registered type.
00028 ////////////////////////////////////////////////////////////////////
00029 INLINE TypedObject *FactoryBase::
00030 make_instance(const string &type_name, const FactoryParams &params) {
00031   TypeHandle handle = TypeRegistry::ptr()->find_type(type_name);
00032   nassertr(handle != TypeHandle::none(), NULL);
00033 
00034   return make_instance(handle, params);
00035 }
00036 
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: FactoryBase::make_instance_more_general
00040 //       Access: Public
00041 //  Description: Attempts to create an instance of the type requested,
00042 //               or some base type of the type requested.  Returns the
00043 //               new instance created, or NULL if the instance could
00044 //               not be created.
00045 //
00046 //               This flavor of make_instance_more_general() accepts a
00047 //               string name that indicates the desired type.  It must
00048 //               be the name of some already-registered type.
00049 ////////////////////////////////////////////////////////////////////
00050 INLINE TypedObject *FactoryBase::
00051 make_instance_more_general(const string &type_name,
00052                            const FactoryParams &params) {
00053   TypeHandle handle = TypeRegistry::ptr()->find_type(type_name);
00054   nassertr(handle != TypeHandle::none(), NULL);
00055 
00056   return make_instance_more_general(handle, params);
00057 }
00058 
 All Classes Functions Variables Enumerations