Panda3D
namable.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 namable.I
10  * @author drose
11  * @date 2000-02-16
12  */
13 
14 /**
15  *
16  */
17 INLINE Namable::
18 Namable(const std::string &initial_name) :
19  _name(initial_name)
20 {
21 }
22 
23 /**
24  *
25  */
26 INLINE void Namable::
27 set_name(const std::string &name) {
28  _name = name;
29 }
30 
31 /**
32  * Resets the Namable's name to empty.
33  */
34 INLINE void Namable::
36  _name = "";
37 }
38 
39 /**
40  * Returns true if the Namable has a nonempty name set, false if the name is
41  * empty.
42  */
43 INLINE bool Namable::
44 has_name() const {
45  return !_name.empty();
46 }
47 
48 /**
49  *
50  */
51 INLINE const std::string &Namable::
52 get_name() const {
53  return _name;
54 }
55 
56 /**
57  * Outputs the Namable. This function simply writes the name to the output
58  * stream; most Namable derivatives will probably redefine this.
59  */
60 INLINE void Namable::
61 output(std::ostream &out) const {
62  out << get_name();
63 }
64 
65 
66 INLINE std::ostream &operator << (std::ostream &out, const Namable &n) {
67  n.output(out);
68  return out;
69 }
70 
71 /**
72  *
73  */
74 INLINE bool NamableOrderByName::
75 operator ()(const Namable *n1, const Namable *n2) const {
76  return (n1->get_name() < n2->get_name());
77 }
void clear_name()
Resets the Namable's name to empty.
Definition: namable.I:35
void output(std::ostream &out) const
Outputs the Namable.
Definition: namable.I:61
A base class for all things which can have a name.
Definition: namable.h:26
bool has_name() const
Returns true if the Namable has a nonempty name set, false if the name is empty.
Definition: namable.I:44