00001 // Filename: factoryParams.I 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 #include <notify.h> 00020 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Function: get_param_into 00024 // Description: A handy convenience template function that extracts a 00025 // parameter of the indicated type from the 00026 // FactoryParams list. If the parameter type is found, 00027 // it fills the pointer and returns true; otherwise, it 00028 // sets the pointer to NULL and returns false. 00029 //////////////////////////////////////////////////////////////////// 00030 template<class ParamType> 00031 bool get_param_into(ParamType *&pointer, const FactoryParams ¶ms) { 00032 FactoryParam *param = 00033 params.get_param_of_type(ParamType::get_class_type()); 00034 if (param == (FactoryParam *)NULL) { 00035 pointer = NULL; 00036 return false; 00037 } 00038 DCAST_INTO_R(pointer, param, false); 00039 return true; 00040 }