Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/express/namable.h

Go to the documentation of this file.
00001 // Filename: namable.h
00002 // Created by:  drose (15Jan99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef NAMABLE_H
00020 #define NAMABLE_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "typedObject.h"
00025 #include <string>
00026 
00027 ///////////////////////////////////////////////////////////////////
00028 //       Class : Namable
00029 // Description : A base class for all things which can have a name.
00030 //               The name is either empty or nonempty, but it is never
00031 //               NULL.
00032 ////////////////////////////////////////////////////////////////////
00033 class EXPCL_PANDAEXPRESS Namable {
00034 PUBLISHED:
00035   INLINE Namable(const string &initial_name = "");
00036   INLINE Namable(const Namable &copy);
00037   INLINE Namable &operator = (const Namable &other);
00038 
00039   INLINE void set_name(const string &name);
00040   INLINE void clear_name();
00041   INLINE bool has_name() const;
00042   INLINE const string &get_name() const;
00043 
00044   // In the absence of any definition to the contrary, outputting a
00045   // Namable will write out its name.
00046   INLINE void output(ostream &out) const;
00047 
00048 private:
00049   string _name;
00050 
00051 public:
00052   static TypeHandle get_class_type() {
00053     return _type_handle;
00054   }
00055   static void init_type() {
00056     register_type(_type_handle, "Namable");
00057   }
00058 
00059 private:
00060   static TypeHandle _type_handle;
00061 };
00062 
00063 INLINE ostream &operator << (ostream &out, const Namable &n);
00064 
00065 ///////////////////////////////////////////////////////////////////
00066 //       Class : NamableOrderByName
00067 // Description : An STL function object for sorting an array of
00068 //               pointers to Namables into order by name.  Returns
00069 //               true if the objects are in sorted order, false
00070 //               otherwise.
00071 ////////////////////////////////////////////////////////////////////
00072 class NamableOrderByName {
00073 public:
00074   INLINE bool operator ()(const Namable *n1, const Namable *n2) const;
00075 };
00076 
00077 #include "namable.I"
00078 
00079 #endif
00080 
00081 

Generated on Fri May 2 00:38:27 2003 for Panda by doxygen1.3