Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
00001 //-*-c++-*- 00002 #ifndef INCLUDED_Factory_h_ 00003 #define INCLUDED_Factory_h_ 00004 00005 //! A lightweight class to override for constructing new objects (if you need to pass constructors parameters, etc.) 00006 /*! Say you don't want to construct your behavior at boot-up (if it's big and might not even be 00007 * used) but your behavior needs special setup during creation (might be invoked 00008 * several difference ways for instance) then you'll want to subclass this to do the setup when 00009 * your behavior is activated.\n 00010 * The default is to simply call the default constructor */ 00011 template<class B> 00012 class Factory { 00013 public: 00014 static B* construct() { return new B(); } //!< Just returns a new B 00015 }; 00016 00017 //! Uses template to specify a constant parameter to the constructor 00018 template<class B, class A1, A1 a1> 00019 class Factory1Arg : public Factory<B> { 00020 public: 00021 static B* construct() { return new B(a1); } //!< Just returns a new B constructed with arguments @a a1 00022 }; 00023 00024 //! Uses template to specify constant parameters to the constructor 00025 template<class B, class A1, A1 a1, class A2, A2 a2> 00026 class Factory2Arg : public Factory<B> { 00027 public: 00028 static B* construct() { return new B(a1,a2); } //!< Just returns a new B constructed with arguments @a a1, @a a2 00029 }; 00030 00031 //! Uses template to specify constant parameters to the constructor 00032 template<class B, class A1, A1 a1, class A2, A2 a2, class A3, A3 a3> 00033 class Factory3Arg : public Factory<B> { 00034 public: 00035 static B* construct() { return new B(a1,a2,a3); } //!< Just returns a new B constructed with arguments @a a1 - @a a3 00036 }; 00037 00038 //! Uses template to specify constant parameters to the constructor 00039 template<class B, class A1, A1 a1, class A2, A2 a2, class A3, A3 a3, class A4, A4 a4> 00040 class Factory4Arg : public Factory<B> { 00041 public: 00042 static B* construct() { return new B(a1,a2,a3,a4); } //!< Just returns a new B constructed with arguments @a a1 - @a a4 00043 }; 00044 00045 /*! @file 00046 * @brief Defines Factory, a lightweight class to override for constructing new objects 00047 * @author ejt (Creator) 00048 * 00049 * $Author: ejt $ 00050 * $Name: tekkotsu-2_0 $ 00051 * $Revision: 1.5 $ 00052 * $State: Exp $ 00053 * $Date: 2003/10/30 23:24:20 $ 00054 */ 00055 00056 #endif 00057
Tekkotsu v2.0 |
Generated Wed Jan 21 03:20:28 2004 by Doxygen 1.3.4 |