Panda3D
Loading...
Searching...
No Matches
namable.h
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.h
10 * @author drose
11 * @date 1999-01-15
12 */
13
14#ifndef NAMABLE_H
15#define NAMABLE_H
16
17#include "pandabase.h"
18
19#include "typedObject.h"
20#include <string>
21
22/**
23 * A base class for all things which can have a name. The name is either
24 * empty or nonempty, but it is never NULL.
25 */
26class EXPCL_PANDA_EXPRESS Namable : public MemoryBase {
27PUBLISHED:
28 INLINE explicit Namable(const std::string &initial_name = "");
29
30 INLINE void set_name(const std::string &name);
31 INLINE void clear_name();
32 INLINE bool has_name() const;
33 INLINE const std::string &get_name() const;
34 MAKE_PROPERTY(name, get_name, set_name);
35
36 // In the absence of any definition to the contrary, outputting a Namable
37 // will write out its name.
38 INLINE void output(std::ostream &out) const;
39
40private:
41 std::string _name;
42
43public:
44 static TypeHandle get_class_type() {
45 return _type_handle;
46 }
47 static void init_type() {
48 register_type(_type_handle, "Namable");
49 }
50
51private:
52 static TypeHandle _type_handle;
53};
54
55INLINE std::ostream &operator << (std::ostream &out, const Namable &n);
56
57/**
58 * An STL function object for sorting an array of pointers to Namables into
59 * order by name. Returns true if the objects are in sorted order, false
60 * otherwise.
61 */
63public:
64 INLINE bool operator ()(const Namable *n1, const Namable *n2) const;
65};
66
67#include "namable.I"
68
69#endif
This class is intended to be the base class of all objects in Panda that might be allocated and delet...
Definition memoryBase.h:65
An STL function object for sorting an array of pointers to Namables into order by name.
Definition namable.h:62
A base class for all things which can have a name.
Definition namable.h:26
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.