Panda3D

Loading...
Searching...
No Matches
factoryBase.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file factoryBase.I
10 * @author drose
11 * @date 2000-05-08
12 */
13
14/**
15 * Attempts to create a new instance of some class of the indicated type, or
16 * some derivative if necessary. If an instance of the exact type cannot be
17 * created, the specified priorities will specify which derived class will be
18 * preferred.
19 *
20 * This flavor of make_instance() accepts a string name that indicates the
21 * desired type. It must be the name of some already-registered type.
22 */
23INLINE TypedObject *FactoryBase::
24 make_instance(const std::string &type_name, const FactoryParams &params) {
25 TypeHandle handle = TypeRegistry::ptr()->find_type(type_name);
26 nassertr(handle != TypeHandle::none(), nullptr);
27
28 return make_instance(handle, params);
29}
30
31
32/**
33 * Attempts to create an instance of the type requested, or some base type of
34 * the type requested. Returns the new instance created, or NULL if the
35 * instance could not be created.
36 *
37 * This flavor of make_instance_more_general() accepts a string name that
38 * indicates the desired type. It must be the name of some already-registered
39 * type.
40 */
41INLINE TypedObject *FactoryBase::
42 make_instance_more_general(const std::string &type_name,
43 const FactoryParams &params) {
44 TypeHandle handle = TypeRegistry::ptr()->find_type(type_name);
45 nassertr(handle != TypeHandle::none(), nullptr);
46
47 return make_instance_more_general(handle, params);
48}
FactoryBase::make_instance
TypedObject * make_instance(TypeHandle handle, const FactoryParams &params)
Attempts to create a new instance of some class of the indicated type, or some derivative if necessar...
Definition factoryBase.cxx:25
FactoryBase::make_instance_more_general
TypedObject * make_instance_more_general(TypeHandle handle, const FactoryParams &params)
Attempts to create an instance of the type requested, or some base type of the type requested.
Definition factoryBase.cxx:53
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypeRegistry::ptr
static TypeRegistry * ptr()
Returns the pointer to the global TypeRegistry object.
Definition typeRegistry.I:30
TypeRegistry::find_type
TypeHandle find_type(const std::string &name) const
Looks for a previously-registered type of the given name.
Definition typeRegistry.cxx:233
TypedObject
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition typedObject.h:88