Panda3D

Loading...
Searching...
No Matches
eggMorphList.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file eggMorphList.I
10 * @author drose
11 * @date 1999-01-29
12 */
13
14/**
15 *
16 */
17 template<class MorphType>
18INLINE EggMorphList<MorphType>::
19 EggMorphList() {
20}
21
22/**
23 *
24 */
25 template<class MorphType>
26INLINE EggMorphList<MorphType>::
27 EggMorphList(const EggMorphList<MorphType> &copy) :
28 _morphs(copy._morphs)
29{
30}
31
32/**
33 *
34 */
35 template<class MorphType>
36INLINE void EggMorphList<MorphType>::
37 operator = (const EggMorphList &copy) {
38 _morphs = copy._morphs;
39}
40
41/**
42 *
43 */
44 template<class MorphType>
45INLINE EggMorphList<MorphType>::
46~EggMorphList() {
47}
48
49/**
50 *
51 */
52 template<class MorphType>
53INLINE bool EggMorphList<MorphType>::
54 operator == (const EggMorphList<MorphType> &other) const {
55 return (_morphs == other._morphs);
56}
57
58/**
59 *
60 */
61 template<class MorphType>
62INLINE bool EggMorphList<MorphType>::
63operator != (const EggMorphList<MorphType> &other) const {
64 return (_morphs != other._morphs);
65}
66
67/**
68 *
69 */
70 template<class MorphType>
71INLINE bool EggMorphList<MorphType>::
72 operator < (const EggMorphList<MorphType> &other) const {
73 return (_morphs < other._morphs);
74}
75
76/**
77 * compare_to() compares a different space than the operator methods, which
78 * only check the morph's name. compare_to() compares the name and the value
79 * as well.
80 */
81 template<class MorphType>
82 int EggMorphList<MorphType>::
83 compare_to(const EggMorphList<MorphType> &other, double threshold) const {
84 if (_morphs.size() != other._morphs.size()) {
85 return (int)_morphs.size() - (int)other._morphs.size();
86 }
87 for (size_t i = 0; i < _morphs.size(); i++) {
88 int compare = _morphs[i].compare_to(other._morphs[i], threshold);
89 if (compare < 0) {
90 return compare;
91 }
92 }
93 return 0;
94}
95
96/**
97 *
98 */
99 template<class MorphType>
100INLINE typename EggMorphList<MorphType>::iterator EggMorphList<MorphType>::
101 begin() {
102 return _morphs.begin();
103}
104
105/**
106 *
107 */
108 template<class MorphType>
109INLINE typename EggMorphList<MorphType>::const_iterator EggMorphList<MorphType>::
110 begin() const {
111 return _morphs.begin();
112}
113
114/**
115 *
116 */
117 template<class MorphType>
118INLINE typename EggMorphList<MorphType>::iterator EggMorphList<MorphType>::
119 end() {
120 return _morphs.end();
121}
122
123/**
124 *
125 */
126 template<class MorphType>
127INLINE typename EggMorphList<MorphType>::const_iterator EggMorphList<MorphType>::
128 end() const {
129 return _morphs.end();
130}
131
132/**
133 *
134 */
135 template<class MorphType>
136INLINE typename EggMorphList<MorphType>::size_type EggMorphList<MorphType>::
137 size() const {
138 return _morphs.size();
139}
140
141/**
142 *
143 */
144 template<class MorphType>
145INLINE bool EggMorphList<MorphType>::
146 empty() const {
147 return _morphs.empty();
148}
149
150/**
151 * This is similar to the insert() interface for sets, except it does not
152 * guarantee that the resulting list is sorted.
153 *
154 * We have this member function so the EggMorphList resembles a set. It used
155 * to *be* a set, but we cannot export STL sets from a Windows DLL.
156 */
157 template<class MorphType>
158std::pair<typename EggMorphList<MorphType>::iterator, bool> EggMorphList<MorphType>::
159 insert(const MorphType &value) {
160 std::pair<iterator, bool> result;
161 typename Morphs::iterator mi;
162 for (mi = _morphs.begin(); mi != _morphs.end(); ++mi) {
163 if ((*mi) == value) {
164 // This value is already present.
165 result.first = mi;
166 result.second = false;
167 return result;
168 }
169 }
170
171 // This value is not already present; add it to the list.
172 _morphs.push_back(value);
173 result.first = _morphs.begin() + _morphs.size() - 1;
174 result.second = true;
175 return result;
176}
177
178/**
179 * Empties the list of morphs.
180 */
181 template<class MorphType>
182INLINE void EggMorphList<MorphType>::
183 clear() {
184 _morphs.clear();
185}
186
187/**
188 *
189 */
190 template<class MorphType>
191 void EggMorphList<MorphType>::
192 write(std::ostream &out, int indent_level, const std::string &tag,
193 int num_dimensions) const {
194 const_iterator i;
195
196 for (i = begin(); i != end(); ++i) {
197 indent(out, indent_level);
198 i->output(out, tag, num_dimensions);
199 out << "\n";
200 }
201}
EggMorphList
A collection of <Dxyz>'s or <Duv>'s or some such.
Definition eggMorphList.h:29
EggMorphList::clear
void clear()
Empties the list of morphs.
Definition eggMorphList.I:183
EggMorphList::compare_to
int compare_to(const EggMorphList< MorphType > &other, double threshold) const
compare_to() compares a different space than the operator methods, which only check the morph's name.
Definition eggMorphList.I:83
EggMorphList::insert
std::pair< iterator, bool > insert(const MorphType &value)
This is similar to the insert() interface for sets, except it does not guarantee that the resulting l...
Definition eggMorphList.I:159
const_iterator
indent
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition indent.cxx:20