Panda3D
Loading...
Searching...
No Matches
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 */
17INLINE Namable::
18Namable(const std::string &initial_name) :
19 _name(initial_name)
20{
21}
22
23/**
24 *
25 */
26INLINE void Namable::
27set_name(const std::string &name) {
28 _name = name;
29}
30
31/**
32 * Resets the Namable's name to empty.
33 */
34INLINE void Namable::
35clear_name() {
36 _name = "";
37}
38
39/**
40 * Returns true if the Namable has a nonempty name set, false if the name is
41 * empty.
42 */
43INLINE bool Namable::
44has_name() const {
45 return !_name.empty();
46}
47
48/**
49 *
50 */
51INLINE const std::string &Namable::
52get_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 */
60INLINE void Namable::
61output(std::ostream &out) const {
62 out << get_name();
63}
64
65
66INLINE std::ostream &operator << (std::ostream &out, const Namable &n) {
67 n.output(out);
68 return out;
69}
70
71/**
72 *
73 */
74INLINE bool NamableOrderByName::
75operator ()(const Namable *n1, const Namable *n2) const {
76 return (n1->get_name() < n2->get_name());
77}
A base class for all things which can have a name.
Definition namable.h:26
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
bool has_name() const
Returns true if the Namable has a nonempty name set, false if the name is empty.
Definition namable.I:44