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

ClassTypes.h

00001 #ifndef _LCORE_ClassTypes_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/ClassTypes.h,v 1.7 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:24  hopper
00026 // Imported sources
00027 //
00028 // Revision 0.2  1994/10/30 04:40:13  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 #ifndef _LCORE_Object_H_
00040 #  include <LCore/Object.h>
00041 #else  // Already included LCore/Object.h
00042 
00043 #define _LCORE_ClassTypes_H_
00044 
00045 #ifndef _LCORE_GenTypes_H_
00046 #  include <LCore/GenTypes.h>
00047 #endif
00048 
00049 #include <iosfwd>
00050 
00051 namespace strmod {
00052 namespace lcore {
00053 
00054 class ClassIdent;
00055 
00056 class ProgrammerNum : public Object
00057 {
00058  public:
00059    static const ClassIdent identifier;
00060 
00061    inline virtual int AreYouA(const ClassIdent &cid) const;
00062 
00063    U4Byte GetPrNum() const                        { return(num); }
00064    friend inline bool operator ==(const ProgrammerNum &a,
00065                                   const ProgrammerNum &b);
00066 
00067    ProgrammerNum(U4Byte n) : num(n)               {}
00068 
00069  protected:
00070    inline virtual int IsEqual(const Object &b) const;
00071    inline virtual const ClassIdent *i_GetIdent() const;
00072 
00073  private:
00074    U4Byte num;
00075 };
00076 
00077 class ClassNum : public Object {
00078    U4Byte num;
00079 
00080  protected:
00081    inline virtual int IsEqual(const Object &b) const;
00082    inline virtual const ClassIdent *i_GetIdent() const;
00083 
00084  public:
00085    static const ClassIdent identifier;
00086 
00087    inline virtual int AreYouA(const ClassIdent &cid) const;
00088 
00089    U4Byte GetClNum() const                     { return(num); }
00090    friend inline bool operator ==(const ClassNum &a, const ClassNum &b);
00091 
00092    ClassNum(U4Byte n) : num(n)                 {}
00093 };
00094 
00095 
00096 class ClassIdent : public Object {
00097    ProgrammerNum prnum;
00098    ClassNum clnum;
00099 
00100  protected:
00101    virtual void PrintOn(std::ostream &os) const;
00102    virtual void PrintOn(std::ostream &os)               { Object::PrintOn(os); }
00103    inline virtual int IsEqual(const Object &b) const;
00104    inline virtual const ClassIdent *i_GetIdent() const;
00105 
00106  public:
00107    static const ClassIdent identifier;
00108 
00109    inline virtual int AreYouA(const ClassIdent &cid) const;
00110 
00111    const ProgrammerNum &GetProgrammer() const         { return(prnum); }
00112    const ClassNum &GetClass() const                   { return(clnum); }
00113    friend inline bool operator ==(const ClassIdent &a, const ClassIdent &b);
00114 
00115    inline ClassIdent(const ProgrammerNum &pn, const ClassNum &cn);
00116 };
00117 
00118 //------------------inline functions for class ProgrammerNum----------------
00119 
00120 inline bool operator ==(const ProgrammerNum &a, const ProgrammerNum &b)
00121 {
00122    return(a.num == b.num);
00123 }
00124 
00125 inline int ProgrammerNum::IsEqual(const Object &b) const
00126 {
00127    const ProgrammerNum *pnp = (const ProgrammerNum *)(&b);
00128 
00129    return(*this == *pnp);
00130 }
00131 
00132 inline const ClassIdent *ProgrammerNum::i_GetIdent() const
00133 {
00134    return(&identifier);
00135 }
00136 
00137 inline int ProgrammerNum::AreYouA(const ClassIdent &cid) const
00138 {
00139    return ((identifier == cid) || Object::AreYouA(cid));
00140 }
00141 
00142 //------------------inline functions for class ClassNum----------------------
00143 
00144 inline bool operator ==(const ClassNum &a, const ClassNum &b)
00145 {
00146    return(a.num == b.num);
00147 }
00148 
00149 inline int ClassNum::IsEqual(const Object &b) const
00150 {
00151    const ClassNum *pnp = (const ClassNum *)(&b);
00152 
00153    return(*this == *pnp);
00154 }
00155 
00156 inline const ClassIdent *ClassNum::i_GetIdent() const
00157 {
00158    return(&identifier);
00159 }
00160 
00161 inline int ClassNum::AreYouA(const ClassIdent &cid) const
00162 {
00163    return ((identifier == cid) || Object::AreYouA(cid));
00164 }
00165 
00166 //-----------------inline functions for class ClassIdent---------------------
00167 
00168 inline bool operator ==(const ClassIdent &a, const ClassIdent &b)
00169 {
00170    return((&a == &b) || ((a.clnum == b.clnum) && (a.prnum == b.prnum)));
00171 }
00172 
00173 inline int ClassIdent::IsEqual(const Object &b) const
00174 {
00175    const ClassIdent *pnp = (const ClassIdent *)(&b);
00176 
00177    return(*this == *pnp);
00178 }
00179 
00180 inline const ClassIdent *ClassIdent::i_GetIdent() const
00181 {
00182    return(&identifier);
00183 }
00184 
00185 inline ClassIdent::ClassIdent(const ProgrammerNum &pn, const ClassNum &cn) :
00186      prnum(pn), clnum(cn)
00187 {
00188 }
00189 
00190 inline int ClassIdent::AreYouA(const ClassIdent &cid) const
00191 {
00192    return ((identifier == cid) || Object::AreYouA(cid));
00193 }
00194 
00195 } // namespace lcore
00196 } // namespace strmod
00197 
00198 #endif  // End of include check for LCore/Object.h
00199 #endif  // End double inclusion guard ifdef

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