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

Object.h

00001 #ifndef _LCORE_Object_H_  // -*- c++ -*-
00002 
00003 /*
00004  * Copyright (C) 1991-9 Eric M. Hopper <hopper@omnifarious.mn.org>
00005  * 
00006  *     This program is free software; you can redistribute it and/or modify it
00007  *     under the terms of the GNU Lesser General Public License as published
00008  *     by the Free Software Foundation; either version 2 of the License, or
00009  *     (at your option) any later version.
00010  * 
00011  *     This program is distributed in the hope that it will be useful, but
00012  *     WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *     Lesser General Public License for more details.
00015  * 
00016  *     You should have received a copy of the GNU Lesser General Public
00017  *     License along with this program; if not, write to the Free Software
00018  *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 /* $Header: /home/hopper/src/cvs/C++/LCore/LCore/Object.h,v 1.6 2002/08/29 00:58:04 hopper Exp $ */
00022 
00023 // For a log, see ../ChangeLog
00024 //
00025 // Revision 1.1.1.1  1995/07/22 04:09:25  hopper
00026 // Imported sources
00027 //
00028 // Revision 0.2  1994/10/30  04:41:00  hopper
00029 // Moved various things into the new LCore library.
00030 //
00031 // Revision 0.1  1994/07/21  05:38:24  hopper
00032 // Genesis!
00033 //
00034 
00035 #ifdef __GNUG__
00036 #  pragma interface
00037 #endif
00038 
00039 #include <iosfwd>
00040 
00041 #define _LCORE_Object_H_
00042 
00043 namespace strmod {
00044 namespace lcore {
00045 
00046 class ClassIdent;
00047 
00048 class Object {
00049  public:
00050    static const ClassIdent identifier;
00051 
00052    Object()                                       {}
00053    virtual ~Object()                              {}
00054 
00055    const ClassIdent &GetIdent() const             { return(*i_GetIdent()); }
00056    inline virtual int AreYouA(const ClassIdent &cid) const;
00057 
00058  protected:
00059    virtual void PrintOn(std::ostream &os) const;
00060    inline virtual void PrintOn(std::ostream &os);
00061    virtual int IsEqual(const Object &b) const       { return(this == &b); }
00062    int DoEqual(const Object &b) const;
00063    inline virtual const ClassIdent *i_GetIdent() const;
00064 
00065  private:
00066    friend int operator ==(const Object &a, const Object &b);
00067    friend std::ostream &operator <<(std::ostream &os, const Object &ob);
00068    friend std::ostream &operator <<(std::ostream &os, Object &ob);
00069 
00070 };
00071 
00072 #define AreYouA_Template(parent)      return((identifier == cid) || \
00073                                              parent::AreYouA(cid)); \
00074                                    }
00075 
00076 #define AreYouA_FuncT(parent)      return((identifier == cid) || \
00077                                           parent::AreYouA(cid));
00078 
00079 #ifndef _LCORE_ClassTypes_H_
00080 }  // end namespace lcore
00081 }  // end namespace strmod
00082    #include <LCore/ClassTypes.h>
00083 namespace strmod {
00084 namespace lcore {
00085 #endif
00086 
00087 inline void Object::PrintOn(std::ostream &os)
00088 {
00089    ((const Object *)(this))->PrintOn(os);
00090 }
00091 
00092 inline const ClassIdent *Object::i_GetIdent() const
00093 {
00094    return(&identifier);
00095 }
00096 
00097 inline int Object::AreYouA(const ClassIdent &cid) const
00098 {
00099    return(cid == identifier);
00100 }
00101 
00102 inline int operator ==(const Object &a, const Object &b)
00103 {
00104    return((&a == &b) || a.DoEqual(b));
00105 }
00106 
00107 inline int operator !=(const Object &a, const Object &b)
00108 {
00109    return (!(a == b));
00110 }
00111 
00112 inline std::ostream &operator <<(std::ostream &os, const Object &ob)
00113 {
00114    ob.PrintOn(os);
00115    return(os);
00116 }
00117 
00118 inline std::ostream &operator <<(std::ostream &os, Object &ob)
00119 {
00120    ob.PrintOn(os);
00121    return(os);
00122 }
00123 
00124 } // namespace lcore
00125 } // namespace strmod
00126 
00127 #endif

Generated on Wed Jan 29 00:32:44 2003 for libNet by doxygen1.3-rc1