Panda3D
 All Classes Functions Variables Enumerations
namable.h
1 // Filename: namable.h
2 // Created by: drose (15Jan99)
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 #ifndef NAMABLE_H
16 #define NAMABLE_H
17 
18 #include "pandabase.h"
19 
20 #include "typedObject.h"
21 #include <string>
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : Namable
25 // Description : A base class for all things which can have a name.
26 // The name is either empty or nonempty, but it is never
27 // NULL.
28 ////////////////////////////////////////////////////////////////////
29 class EXPCL_PANDAEXPRESS Namable : public MemoryBase {
30 PUBLISHED:
31  INLINE Namable(const string &initial_name = "");
32  INLINE Namable(const Namable &copy);
33  INLINE Namable &operator = (const Namable &other);
34 
35  INLINE void set_name(const string &name);
36  INLINE void clear_name();
37  INLINE bool has_name() const;
38  INLINE const string &get_name() const;
39 
40  // In the absence of any definition to the contrary, outputting a
41  // Namable will write out its name.
42  INLINE void output(ostream &out) const;
43 
44 private:
45  string _name;
46 
47 public:
48  static TypeHandle get_class_type() {
49  return _type_handle;
50  }
51  static void init_type() {
52  register_type(_type_handle, "Namable");
53  }
54 
55 private:
56  static TypeHandle _type_handle;
57 };
58 
59 INLINE ostream &operator << (ostream &out, const Namable &n);
60 
61 ////////////////////////////////////////////////////////////////////
62 // Class : NamableOrderByName
63 // Description : An STL function object for sorting an array of
64 // pointers to Namables into order by name. Returns
65 // true if the objects are in sorted order, false
66 // otherwise.
67 ////////////////////////////////////////////////////////////////////
69 public:
70  INLINE bool operator ()(const Namable *n1, const Namable *n2) const;
71 };
72 
73 #include "namable.I"
74 
75 #endif
76 
77 
A base class for all things which can have a name.
Definition: namable.h:29
This class is intended to be the base class of all objects in Panda that might be allocated and delet...
Definition: memoryBase.h:73
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An STL function object for sorting an array of pointers to Namables into order by name...
Definition: namable.h:68