Panda3D
 All Classes Functions Variables Enumerations
namable.I
00001 // Filename: namable.I
00002 // Created by:  drose (16Feb00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 ////////////////////////////////////////////////////////////////////
00016 //     Function: Namable::Constructor
00017 //       Access: Public
00018 //  Description:
00019 ////////////////////////////////////////////////////////////////////
00020 INLINE Namable::
00021 Namable(const string &initial_name) :
00022   _name(initial_name)
00023 {
00024 }
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: Namable::Copy Constructor
00028 //       Access: Public
00029 //  Description:
00030 ////////////////////////////////////////////////////////////////////
00031 INLINE Namable::
00032 Namable(const Namable &copy) :
00033   _name(copy._name)
00034 {
00035 }
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: Namable::Copy Assignment Operator
00039 //       Access: Public
00040 //  Description:
00041 ////////////////////////////////////////////////////////////////////
00042 INLINE Namable &Namable::
00043 operator = (const Namable &other) {
00044   _name = other._name;
00045   return *this;
00046 }
00047 
00048 ////////////////////////////////////////////////////////////////////
00049 //     Function: Namable::set_name
00050 //       Access: Public
00051 //  Description:
00052 ////////////////////////////////////////////////////////////////////
00053 INLINE void Namable::
00054 set_name(const string &name) {
00055   _name = name;
00056 }
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //     Function: Namable::clear_name
00060 //       Access: Public
00061 //  Description: Resets the Namable's name to empty.
00062 ////////////////////////////////////////////////////////////////////
00063 INLINE void Namable::
00064 clear_name() {
00065   _name = "";
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: Namable::has_name
00070 //       Access: Public
00071 //  Description: Returns true if the Namable has a nonempty name set,
00072 //               false if the name is empty.
00073 ////////////////////////////////////////////////////////////////////
00074 INLINE bool Namable::
00075 has_name() const {
00076   return !_name.empty();
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: Namable::get_name
00081 //       Access: Public
00082 //  Description:
00083 ////////////////////////////////////////////////////////////////////
00084 INLINE const string &Namable::
00085 get_name() const {
00086   return _name;
00087 }
00088 
00089 ////////////////////////////////////////////////////////////////////
00090 //     Function: Namable::output
00091 //       Access: Public
00092 //  Description: Outputs the Namable.  This function simply writes the
00093 //               name to the output stream; most Namable derivatives
00094 //               will probably redefine this.
00095 ////////////////////////////////////////////////////////////////////
00096 INLINE void Namable::
00097 output(ostream &out) const {
00098   out << get_name();
00099 }
00100 
00101 
00102 INLINE ostream &operator << (ostream &out, const Namable &n) {
00103   n.output(out);
00104   return out;
00105 }
00106 
00107 ////////////////////////////////////////////////////////////////////
00108 //     Function: NamableOrderByName::Function operator
00109 //       Access: Public
00110 //  Description:
00111 ////////////////////////////////////////////////////////////////////
00112 INLINE bool NamableOrderByName::
00113 operator ()(const Namable *n1, const Namable *n2) const {
00114   return (n1->get_name() < n2->get_name());
00115 }
 All Classes Functions Variables Enumerations