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

panda/src/putil/factory.h

Go to the documentation of this file.
00001 // Filename: factory.h
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 #ifndef FACTORY_H
00020 #define FACTORY_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "factoryBase.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : Factory
00028 // Description : A Factory can be used to create an instance of a
00029 //               particular subclass of some general base class.  Each
00030 //               subclass registers itself with the Factory, supplying
00031 //               a function that will construct an instance of that
00032 //               subclass; the Factory can later choose a suitable
00033 //               subclass and return a newly-constructed pointer to an
00034 //               object of that type on the user's demand.  This is
00035 //               used, for instance, to manage the set of
00036 //               GraphicsPipes available to the user.
00037 //
00038 //               This is a thin template wrapper around FactoryBase.
00039 //               All it does is ensure the types are correctly cast.
00040 //               All of its methods are inline, and it has no data
00041 //               members, so it is not necessary to export the class
00042 //               from the DLL.
00043 ////////////////////////////////////////////////////////////////////
00044 template<class Type>
00045 class Factory : public FactoryBase {
00046 public:
00047   typedef Type *CreateFunc(const FactoryParams &params);
00048 
00049   INLINE Type *make_instance(TypeHandle handle,
00050                              const FactoryParams &params = FactoryParams());
00051 
00052   INLINE Type *make_instance(const string &type_name,
00053                              const FactoryParams &params = FactoryParams());
00054 
00055   INLINE Type *
00056   make_instance_more_general(TypeHandle handle,
00057                              const FactoryParams &params = FactoryParams());
00058 
00059   INLINE Type *
00060   make_instance_more_general(const string &type_name,
00061                              const FactoryParams &params = FactoryParams());
00062 
00063   INLINE void register_factory(TypeHandle handle, CreateFunc *func);
00064 };
00065 
00066 #include "factory.I"
00067 
00068 #endif
00069 

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