Panda3D
|
00001 // Filename: configVariableDouble.I 00002 // Created by: drose (20Oct04) 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 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: ConfigVariableDouble::Constructor 00018 // Access: Published 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE ConfigVariableDouble:: 00022 ConfigVariableDouble(const string &name) : 00023 ConfigVariable(name, VT_double), 00024 _local_modified(initial_invalid_cache()) 00025 { 00026 _core->set_used(); 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: ConfigVariableDouble::Constructor 00031 // Access: Published 00032 // Description: 00033 //////////////////////////////////////////////////////////////////// 00034 INLINE ConfigVariableDouble:: 00035 ConfigVariableDouble(const string &name, double default_value, 00036 const string &description, int flags) : 00037 #ifdef PRC_SAVE_DESCRIPTIONS 00038 ConfigVariable(name, ConfigVariableCore::VT_double, description, flags), 00039 #else 00040 ConfigVariable(name, ConfigVariableCore::VT_double, string(), flags), 00041 #endif 00042 _local_modified(initial_invalid_cache()) 00043 { 00044 set_default_value(default_value); 00045 _core->set_used(); 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: ConfigVariableDouble::Constructor 00050 // Access: Published 00051 // Description: 00052 //////////////////////////////////////////////////////////////////// 00053 INLINE ConfigVariableDouble:: 00054 ConfigVariableDouble(const string &name, const string &default_value, 00055 const string &description, int flags) : 00056 #ifdef PRC_SAVE_DESCRIPTIONS 00057 ConfigVariable(name, ConfigVariableCore::VT_double, description, flags), 00058 #else 00059 ConfigVariable(name, ConfigVariableCore::VT_double, string(), flags), 00060 #endif 00061 _local_modified(initial_invalid_cache()) 00062 { 00063 _core->set_default_value(default_value); 00064 _core->set_used(); 00065 } 00066 00067 //////////////////////////////////////////////////////////////////// 00068 // Function: ConfigVariableDouble::operator = 00069 // Access: Published 00070 // Description: Reassigns the variable's local value. 00071 //////////////////////////////////////////////////////////////////// 00072 INLINE void ConfigVariableDouble:: 00073 operator = (double value) { 00074 set_value(value); 00075 } 00076 00077 //////////////////////////////////////////////////////////////////// 00078 // Function: ConfigVariableDouble::typecast operator 00079 // Access: Published 00080 // Description: Returns the variable's value. 00081 //////////////////////////////////////////////////////////////////// 00082 INLINE ConfigVariableDouble:: 00083 operator double () const { 00084 return get_value(); 00085 } 00086 00087 //////////////////////////////////////////////////////////////////// 00088 // Function: ConfigVariableDouble::size() 00089 // Access: Published 00090 // Description: Returns the number of unique words in the variable. 00091 //////////////////////////////////////////////////////////////////// 00092 INLINE int ConfigVariableDouble:: 00093 size() const { 00094 return get_num_words(); 00095 } 00096 00097 //////////////////////////////////////////////////////////////////// 00098 // Function: ConfigVariableDouble::operator [] 00099 // Access: Published 00100 // Description: Returns the value of the variable's nth word. 00101 //////////////////////////////////////////////////////////////////// 00102 INLINE double ConfigVariableDouble:: 00103 operator [] (int n) const { 00104 return get_word(n); 00105 } 00106 00107 //////////////////////////////////////////////////////////////////// 00108 // Function: ConfigVariableDouble::set_value 00109 // Access: Published 00110 // Description: Reassigns the variable's local value. 00111 //////////////////////////////////////////////////////////////////// 00112 INLINE void ConfigVariableDouble:: 00113 set_value(double value) { 00114 set_string_value(""); 00115 set_double_word(0, value); 00116 } 00117 00118 //////////////////////////////////////////////////////////////////// 00119 // Function: ConfigVariableDouble::get_value 00120 // Access: Published 00121 // Description: Returns the variable's value. 00122 //////////////////////////////////////////////////////////////////// 00123 INLINE double ConfigVariableDouble:: 00124 get_value() const { 00125 TAU_PROFILE("double ConfigVariableDouble::get_value() const", " ", TAU_USER); 00126 if (!is_cache_valid(_local_modified)) { 00127 mark_cache_valid(((ConfigVariableDouble *)this)->_local_modified); 00128 ((ConfigVariableDouble *)this)->_cache = get_double_word(0); 00129 } 00130 return _cache; 00131 } 00132 00133 //////////////////////////////////////////////////////////////////// 00134 // Function: ConfigVariableDouble::get_default_value 00135 // Access: Published 00136 // Description: Returns the variable's default value. 00137 //////////////////////////////////////////////////////////////////// 00138 INLINE double ConfigVariableDouble:: 00139 get_default_value() const { 00140 const ConfigDeclaration *decl = ConfigVariable::get_default_value(); 00141 if (decl != (ConfigDeclaration *)NULL) { 00142 return decl->get_double_word(0); 00143 } 00144 return 0.0; 00145 } 00146 00147 //////////////////////////////////////////////////////////////////// 00148 // Function: ConfigVariableDouble::get_word 00149 // Access: Published 00150 // Description: Returns the variable's nth value. 00151 //////////////////////////////////////////////////////////////////// 00152 INLINE double ConfigVariableDouble:: 00153 get_word(int n) const { 00154 return get_double_word(n); 00155 } 00156 00157 //////////////////////////////////////////////////////////////////// 00158 // Function: ConfigVariableDouble::set_word 00159 // Access: Published 00160 // Description: Reassigns the variable's nth value. This makes a 00161 // local copy of the variable's overall value. 00162 //////////////////////////////////////////////////////////////////// 00163 INLINE void ConfigVariableDouble:: 00164 set_word(int n, double value) { 00165 set_double_word(n, value); 00166 }