Panda3D
 All Classes Functions Variables Enumerations
factoryBase.I
1 // Filename: factoryBase.I
2 // Created by: drose (08May00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: FactoryBase::make_instance
18 // Access: Public
19 // Description: Attempts to create a new instance of some class of
20 // the indicated type, or some derivative if necessary.
21 // If an instance of the exact type cannot be created,
22 // the specified priorities will specify which derived
23 // class will be preferred.
24 //
25 // This flavor of make_instance() accepts a string name
26 // that indicates the desired type. It must be the name
27 // of some already-registered type.
28 ////////////////////////////////////////////////////////////////////
30 make_instance(const string &type_name, const FactoryParams &params) {
31  TypeHandle handle = TypeRegistry::ptr()->find_type(type_name);
32  nassertr(handle != TypeHandle::none(), NULL);
33 
34  return make_instance(handle, params);
35 }
36 
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: FactoryBase::make_instance_more_general
40 // Access: Public
41 // Description: Attempts to create an instance of the type requested,
42 // or some base type of the type requested. Returns the
43 // new instance created, or NULL if the instance could
44 // not be created.
45 //
46 // This flavor of make_instance_more_general() accepts a
47 // string name that indicates the desired type. It must
48 // be the name of some already-registered type.
49 ////////////////////////////////////////////////////////////////////
51 make_instance_more_general(const string &type_name,
52  const FactoryParams &params) {
53  TypeHandle handle = TypeRegistry::ptr()->find_type(type_name);
54  nassertr(handle != TypeHandle::none(), NULL);
55 
56  return make_instance_more_general(handle, params);
57 }
58 
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:47
TypeHandle find_type(const string &name) const
Looks for a previously-registered type of the given name.
static TypeHandle none()
Returns a special zero-valued TypeHandle that is used to indicate no type.
Definition: typeHandle.I:274
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:98
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
static TypeRegistry * ptr()
Returns the pointer to the global TypeRegistry object.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
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:78