Panda3D
|
00001 // Filename: factoryParams.I 00002 // Created by: drose (08May00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "pnotify.h" 00016 00017 00018 //////////////////////////////////////////////////////////////////// 00019 // Function: get_param_into 00020 // Description: A handy convenience template function that extracts a 00021 // parameter of the indicated type from the 00022 // FactoryParams list. If the parameter type is found, 00023 // it fills the pointer and returns true; otherwise, it 00024 // sets the pointer to NULL and returns false. 00025 //////////////////////////////////////////////////////////////////// 00026 template<class ParamType> 00027 bool get_param_into(ParamType *&pointer, const FactoryParams ¶ms) { 00028 FactoryParam *param = 00029 params.get_param_of_type(ParamType::get_class_type()); 00030 if (param == (FactoryParam *)NULL) { 00031 pointer = NULL; 00032 return false; 00033 } 00034 DCAST_INTO_R(pointer, param, false); 00035 return true; 00036 }