00001 // Filename: eggMorphList.I 00002 // Created by: drose (29Jan99) 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 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: EggMorphList::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 template<class MorphType> 00026 INLINE EggMorphList<MorphType>:: 00027 EggMorphList() { 00028 } 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Function: EggMorphList::Copy Constructor 00032 // Access: Public 00033 // Description: 00034 //////////////////////////////////////////////////////////////////// 00035 template<class MorphType> 00036 INLINE EggMorphList<MorphType>:: 00037 EggMorphList(const EggMorphList<MorphType> ©) : 00038 _morphs(copy._morphs) 00039 { 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: EggMorphList::Copy Assignment Operator 00044 // Access: Public 00045 // Description: 00046 //////////////////////////////////////////////////////////////////// 00047 template<class MorphType> 00048 INLINE void EggMorphList<MorphType>:: 00049 operator = (const EggMorphList ©) { 00050 _morphs = copy._morphs; 00051 } 00052 00053 //////////////////////////////////////////////////////////////////// 00054 // Function: EggMorphList::Destructor 00055 // Access: Public 00056 // Description: 00057 //////////////////////////////////////////////////////////////////// 00058 template<class MorphType> 00059 INLINE EggMorphList<MorphType>:: 00060 ~EggMorphList() { 00061 } 00062 00063 //////////////////////////////////////////////////////////////////// 00064 // Function: EggMorphList::operator == 00065 // Access: Public 00066 // Description: 00067 //////////////////////////////////////////////////////////////////// 00068 template<class MorphType> 00069 INLINE bool EggMorphList<MorphType>:: 00070 operator == (const EggMorphList<MorphType> &other) const { 00071 return (_morphs == other._morphs); 00072 } 00073 00074 //////////////////////////////////////////////////////////////////// 00075 // Function: EggMorphList::operator != 00076 // Access: Public 00077 // Description: 00078 //////////////////////////////////////////////////////////////////// 00079 template<class MorphType> 00080 INLINE bool EggMorphList<MorphType>:: 00081 operator != (const EggMorphList<MorphType> &other) const { 00082 return (_morphs != other._morphs); 00083 } 00084 00085 //////////////////////////////////////////////////////////////////// 00086 // Function: EggMorphList::operator < 00087 // Access: Public 00088 // Description: 00089 //////////////////////////////////////////////////////////////////// 00090 template<class MorphType> 00091 INLINE bool EggMorphList<MorphType>:: 00092 operator < (const EggMorphList<MorphType> &other) const { 00093 return (_morphs < other._morphs); 00094 } 00095 00096 //////////////////////////////////////////////////////////////////// 00097 // Function: EggMorphList::begin 00098 // Access: Public 00099 // Description: 00100 //////////////////////////////////////////////////////////////////// 00101 template<class MorphType> 00102 INLINE TYPENAME EggMorphList<MorphType>::iterator EggMorphList<MorphType>:: 00103 begin() { 00104 return _morphs.begin(); 00105 } 00106 00107 //////////////////////////////////////////////////////////////////// 00108 // Function: EggMorphList::begin 00109 // Access: Public 00110 // Description: 00111 //////////////////////////////////////////////////////////////////// 00112 template<class MorphType> 00113 INLINE TYPENAME EggMorphList<MorphType>::const_iterator EggMorphList<MorphType>:: 00114 begin() const { 00115 return _morphs.begin(); 00116 } 00117 00118 //////////////////////////////////////////////////////////////////// 00119 // Function: EggMorphList::end 00120 // Access: Public 00121 // Description: 00122 //////////////////////////////////////////////////////////////////// 00123 template<class MorphType> 00124 INLINE TYPENAME EggMorphList<MorphType>::iterator EggMorphList<MorphType>:: 00125 end() { 00126 return _morphs.end(); 00127 } 00128 00129 //////////////////////////////////////////////////////////////////// 00130 // Function: EggMorphList::end 00131 // Access: Public 00132 // Description: 00133 //////////////////////////////////////////////////////////////////// 00134 template<class MorphType> 00135 INLINE TYPENAME EggMorphList<MorphType>::const_iterator EggMorphList<MorphType>:: 00136 end() const { 00137 return _morphs.end(); 00138 } 00139 00140 //////////////////////////////////////////////////////////////////// 00141 // Function: EggMorphList::size 00142 // Access: Public 00143 // Description: 00144 //////////////////////////////////////////////////////////////////// 00145 template<class MorphType> 00146 INLINE TYPENAME EggMorphList<MorphType>::size_type EggMorphList<MorphType>:: 00147 size() const { 00148 return _morphs.size(); 00149 } 00150 00151 //////////////////////////////////////////////////////////////////// 00152 // Function: EggMorphList::empty 00153 // Access: Public 00154 // Description: 00155 //////////////////////////////////////////////////////////////////// 00156 template<class MorphType> 00157 INLINE bool EggMorphList<MorphType>:: 00158 empty() const { 00159 return _morphs.empty(); 00160 } 00161 00162 //////////////////////////////////////////////////////////////////// 00163 // Function: EggMorphList::insert 00164 // Access: Public 00165 // Description: This is similar to the insert() interface for sets, 00166 // except it does not guarantee that the resulting list 00167 // is sorted. 00168 // 00169 // We have this member function so the EggMorphList 00170 // resembles a set. It used to *be* a set, but we 00171 // cannot export STL sets from a Windows DLL. 00172 //////////////////////////////////////////////////////////////////// 00173 template<class MorphType> 00174 pair<TYPENAME EggMorphList<MorphType>::iterator, bool> EggMorphList<MorphType>:: 00175 insert(const MorphType &value) { 00176 pair<iterator, bool> result; 00177 TYPENAME Morphs::iterator mi; 00178 for (mi = _morphs.begin(); mi != _morphs.end(); ++mi) { 00179 if ((*mi) == value) { 00180 // This value is already present. 00181 result.first = mi; 00182 result.second = false; 00183 return result; 00184 } 00185 } 00186 00187 // This value is not already present; add it to the list. 00188 _morphs.push_back(value); 00189 result.first = _morphs.begin() + _morphs.size() - 1; 00190 result.second = true; 00191 return result; 00192 } 00193 00194 //////////////////////////////////////////////////////////////////// 00195 // Function: EggMorphList::clear 00196 // Access: Public 00197 // Description: Empties the list of morphs. 00198 //////////////////////////////////////////////////////////////////// 00199 template<class MorphType> 00200 INLINE void EggMorphList<MorphType>:: 00201 clear() { 00202 _morphs.clear(); 00203 } 00204 00205 //////////////////////////////////////////////////////////////////// 00206 // Function: EggMorphList::write 00207 // Access: Public 00208 // Description: 00209 //////////////////////////////////////////////////////////////////// 00210 template<class MorphType> 00211 void EggMorphList<MorphType>:: 00212 write(ostream &out, int indent_level) const { 00213 const_iterator i; 00214 00215 for (i = begin(); i != end(); ++i) { 00216 indent(out, indent_level) << *i << "\n"; 00217 } 00218 } 00219