Panda3D
eggMorph.I
1 // Filename: eggMorph.I
2 // Created by: drose (29Jan99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: EggMorph::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 template<class Parameter>
23 EggMorph(const string &name, const Parameter &offset)
24  : Namable(name), _offset(offset) {
25 }
26 
27 
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: EggMorph::set_offset
31 // Access: Public
32 // Description:
33 ////////////////////////////////////////////////////////////////////
34 template<class Parameter>
35 INLINE void EggMorph<Parameter>::
36 set_offset(const Parameter &offset) {
37  _offset = offset;
38 }
39 
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function: EggMorph::get_offset
43 // Access: Public
44 // Description:
45 ////////////////////////////////////////////////////////////////////
46 template<class Parameter>
47 INLINE const Parameter &EggMorph<Parameter>::
48 get_offset() const {
49  return _offset;
50 }
51 
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: EggMorph::Ordering operator
55 // Access: Public
56 // Description:
57 ////////////////////////////////////////////////////////////////////
58 template<class Parameter>
59 INLINE bool EggMorph<Parameter>::
60 operator < (const EggMorph<Parameter> &other) const {
61  return get_name() < other.get_name();
62 }
63 
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: EggMorph::Equality operator
67 // Access: Public
68 // Description:
69 ////////////////////////////////////////////////////////////////////
70 template<class Parameter>
71 INLINE bool EggMorph<Parameter>::
72 operator == (const EggMorph<Parameter> &other) const {
73  return get_name() == other.get_name();
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: EggMorph::Inequality operator
78 // Access: Public
79 // Description:
80 ////////////////////////////////////////////////////////////////////
81 template<class Parameter>
82 INLINE bool EggMorph<Parameter>::
83 operator != (const EggMorph<Parameter> &other) const {
84  return !operator == (other);
85 }
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: EggMorph::compare_to
89 // Access: Public
90 // Description: compare_to() compares a different space than the
91 // operator methods, which only check the name.
92 // compare_to() compares the name and the value as well.
93 ////////////////////////////////////////////////////////////////////
94 template<class Parameter>
95 INLINE int EggMorph<Parameter>::
96 compare_to(const EggMorph<Parameter> &other, double threshold) const {
97  int compare = strcmp(get_name().c_str(), other.get_name().c_str());
98  if (compare != 0) {
99  return compare;
100  }
101  return _offset.compare_to(other._offset, threshold);
102 }
103 
104 ////////////////////////////////////////////////////////////////////
105 // Function: EggMorph::output
106 // Access: Public
107 // Description:
108 ////////////////////////////////////////////////////////////////////
109 template<class Parameter>
110 INLINE void EggMorph<Parameter>::
111 output(ostream &out, const string &tag, int num_dimensions) const {
112  out << tag << " " << get_name() << " {";
113  for (int i = 0; i < num_dimensions; ++i) {
114  out << " " << MAYBE_ZERO(_offset[i]);
115  }
116  out << " }";
117 }
int compare_to(const EggMorph< Parameter > &other, double threshold) const
compare_to() compares a different space than the operator methods, which only check the name...
Definition: eggMorph.I:96
A single <Dxyz> or <Duv> or some such entry.
Definition: eggMorph.h:33
A base class for all things which can have a name.
Definition: namable.h:29