Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 /** 27 * \file electromagnetic/TestEm7/include/c2_factory.hh 28 * \brief Provides a factory class to avoid an infinite number of template 29 * \brief declarations. 30 * 31 * \author Created by R. A. Weller and Marcus H. Mendenhall on 7/9/05. 32 * \author 2005 Vanderbilt University. 33 * 34 * \version c2_factory.hh,v 1.13 2008/05/22 12:45:19 marcus Exp 35 */ 36 // 37 38 #ifndef __has_c2_factory_hh 39 #define __has_c2_factory_hh 1 40 41 #include "c2_function.hh" 42 43 /// \brief a factory of pre-templated c2_function generators 44 /// 45 /// do \code 46 /// typedef c2_ptr<double> c2_p; 47 /// static c2_factory<double> c2; 48 /// c2_p f=c2.sin(); 49 /// \endcode 50 /// \note The factory class doesn't contain any data. 51 /// It can be statically instantiated at the top of a file, 52 /// and used everywhere inside, or even instantiated in your project's top-level 53 /// include file. 54 /// \see c2_math_factory 55 /// \ingroup factories 56 template<typename float_type> 57 class c2_factory 58 { 59 public: 60 /// make a *new object 61 static c2_classic_function_p<float_type>& classic_function(float_type (*c_func)(float_type)) 62 { 63 return *new c2_classic_function_p<float_type>(c_func); 64 } 65 /// make a *new object 66 static c2_plugin_function_p<float_type>& plugin_function() 67 { 68 return *new c2_plugin_function_p<float_type>(); 69 } 70 /// make a *new object 71 static c2_plugin_function_p<float_type>& plugin_function(c2_function<float_type>& f) 72 { 73 return *new c2_plugin_function_p<float_type>(f); 74 } 75 /// make a *new object 76 static c2_const_plugin_function_p<float_type>& const_plugin_function() 77 { 78 return *new c2_const_plugin_function_p<float_type>(); 79 } 80 /// make a *new object 81 static c2_const_plugin_function_p<float_type>& 82 const_plugin_function(const c2_function<float_type>& f) 83 { 84 return *new c2_const_plugin_function_p<float_type>(f); 85 } 86 /// make a *new object 87 static c2_scaled_function_p<float_type>& scaled_function(const c2_function<float_type>& outer, 88 float_type scale) 89 { 90 return *new c2_scaled_function_p<float_type>(outer, scale); 91 } 92 /// make a *new object 93 static c2_cached_function_p<float_type>& cached_function(const c2_function<float_type>& func) 94 { 95 return *new c2_cached_function_p<float_type>(func); 96 } 97 /// make a *new object 98 static c2_constant_p<float_type>& constant(float_type x) 99 { 100 return *new c2_constant_p<float_type>(x); 101 } 102 /// make a *new object 103 static interpolating_function_p<float_type>& interpolating_function() 104 { 105 return *new interpolating_function_p<float_type>(); 106 } 107 /// make a *new object 108 static lin_log_interpolating_function_p<float_type>& lin_log_interpolating_function() 109 { 110 return *new lin_log_interpolating_function_p<float_type>(); 111 } 112 /// make a *new object 113 static log_lin_interpolating_function_p<float_type>& log_lin_interpolating_function() 114 { 115 return *new log_lin_interpolating_function_p<float_type>(); 116 } 117 /// make a *new object 118 static log_log_interpolating_function_p<float_type>& log_log_interpolating_function() 119 { 120 return *new log_log_interpolating_function_p<float_type>(); 121 } 122 /// make a *new object 123 static arrhenius_interpolating_function_p<float_type>& arrhenius_interpolating_function() 124 { 125 return *new arrhenius_interpolating_function_p<float_type>(); 126 } 127 /// make a *new object 128 static c2_connector_function_p<float_type>& 129 connector_function(float_type x0, const c2_function<float_type>& f0, float_type x2, 130 const c2_function<float_type>& f2, bool auto_center, float_type y1) 131 { 132 return *new c2_connector_function_p<float_type>(x0, f0, x2, f2, auto_center, y1); 133 } 134 /// make a *new object 135 static c2_connector_function_p<float_type>& connector_function(const c2_fblock<float_type>& fb0, 136 const c2_fblock<float_type>& fb2, 137 bool auto_center, float_type y1) 138 { 139 return *new c2_connector_function_p<float_type>(fb0, fb2, auto_center, y1); 140 } 141 /// make a *new object 142 static c2_connector_function_p<float_type>& connector_function(float_type x0, float_type y0, 143 float_type yp0, float_type ypp0, 144 float_type x2, float_type y2, 145 float_type yp2, float_type ypp2, 146 bool auto_center, float_type y1) 147 { 148 return *new c2_connector_function_p<float_type>(x0, y0, yp0, ypp0, x2, y2, yp2, ypp2, 149 auto_center, y1); 150 } 151 /// make a *new object 152 static c2_piecewise_function_p<float_type>& piecewise_function() 153 { 154 return *new c2_piecewise_function_p<float_type>(); 155 } 156 /// make a *new object 157 static c2_sin_p<float_type>& sin() { return *new c2_sin_p<float_type>(); } 158 /// make a *new object 159 static c2_cos_p<float_type>& cos() { return *new c2_cos_p<float_type>(); } 160 /// make a *new object 161 static c2_tan_p<float_type>& tan() { return *new c2_tan_p<float_type>(); } 162 /// make a *new object 163 static c2_log_p<float_type>& log() { return *new c2_log_p<float_type>(); } 164 /// make a *new object 165 static c2_exp_p<float_type>& exp() { return *new c2_exp_p<float_type>(); } 166 /// make a *new object 167 static c2_sqrt_p<float_type>& sqrt() { return *new c2_sqrt_p<float_type>(); } 168 /// make a *new object 169 static c2_recip_p<float_type>& recip(float_type scale = 1) 170 { 171 return *new c2_recip_p<float_type>(scale); 172 } 173 /// make a *new object 174 static c2_identity_p<float_type>& identity() { return *new c2_identity_p<float_type>(); } 175 /// make a *new object 176 static c2_linear_p<float_type>& linear(float_type x0, float_type y0, float_type slope) 177 { 178 return *new c2_linear_p<float_type>(x0, y0, slope); 179 } 180 /// make a *new object 181 static c2_quadratic_p<float_type>& quadratic(float_type x0, float_type y0, float_type xcoef, 182 float_type x2coef) 183 { 184 return *new c2_quadratic_p<float_type>(x0, y0, xcoef, x2coef); 185 } 186 /// make a *new object 187 static c2_power_law_p<float_type>& power_law(float_type scale, float_type power) 188 { 189 return *new c2_power_law_p<float_type>(scale, power); 190 } 191 /// make a *new object 192 static c2_inverse_function_p<float_type>& 193 inverse_function(const c2_function<float_type>& source) 194 { 195 return *new c2_inverse_function_p<float_type>(source); 196 } 197 198 #if 0 199 /// \brief handle template for inverse_integrated_density_bins 200 /// \brief <float_type, Final<float_type> >(bincenters, binheights) 201 template <template <typename f_t> class Final > 202 static interpolating_function_p<float_type> 203 & inverse_integrated_density_bins(const std::vector<float_type> &bincenters, 204 const std::vector<float_type> &binheights) 205 throw(c2_exception) 206 { 207 return ::inverse_integrated_density_bins<float_type, Final<float_type> > 208 (bincenters, binheights); 209 } 210 /// \brief handle template for inverse_integrated_density_function 211 /// \brief <float_type, Final<float_type> >(bincenters, binheights) 212 template <template <typename f_t> class Final > 213 static interpolating_function_p<float_type> 214 & inverse_integrated_density_function( 215 const std::vector<float_type> &bincenters, 216 const c2_function<float_type> &binheights) 217 throw(c2_exception) 218 { 219 return ::inverse_integrated_density_function<float_type, 220 Final<float_type> > 221 (bincenters, binheights); 222 } 223 #endif 224 }; 225 226 #endif 227