00001 #ifndef _LCORE_Debugable_H_ // -*-c++-*- 00002 00003 #ifdef __GNUG__ 00004 # pragma interface 00005 #endif 00006 00007 /* 00008 * Copyright (C) 1991-9 Eric M. Hopper <hopper@omnifarious.mn.org> 00009 * 00010 * This program is free software; you can redistribute it and/or modify it 00011 * under the terms of the GNU Lesser General Public License as published 00012 * by the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, but 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00023 */ 00024 00025 /* $Header: /home/hopper/src/cvs/C++/LCore/LCore/Debugable.h,v 1.7 2002/11/25 05:40:05 hopper Exp $ */ 00026 00027 // For a log, see ../ChangeLog 00028 00029 #include <LCore/HopClTypes.h> 00030 #include <LCore/Protocol.h> 00031 00032 #define _LCORE_Debugable_H_ 00033 00034 namespace strmod { 00035 namespace lcore { 00036 00037 /** \class Debugable Debugable.h LCore/Debugable.h 00038 * Interface class for things that have certain common debugging functions. 00039 * You'll probable need to use a dynamic_cast to use this interface in a 00040 * generic way in most cases. 00041 */ 00042 class Debugable : virtual public Protocol { 00043 public: 00044 static const LCore_ClassIdent identifier; 00045 00046 inline virtual int AreYouA(const lcore::ClassIdent &cid) const; 00047 00048 /** \brief This should ALWAYS return true. It says whether the class 00049 * invariant holds or not. 00050 * 00051 * Your class invariant should be as strict as possible. The class 00052 * invariant is used to detect when the class goes into a bad state, so all 00053 * possible bad states should be caught by the invariant. */ 00054 virtual bool invariant() const = 0; 00055 00056 /** This should print out as much of the internal state of a class as would 00057 * be needed to debug it properly. 00058 */ 00059 virtual void printState(::std::ostream &os) const = 0; 00060 00061 protected: 00062 virtual const ClassIdent *i_GetIdent() const { return(&identifier); } 00063 }; 00064 00065 //-----------------------------inline functions-------------------------------- 00066 00067 inline int Debugable::AreYouA(const ClassIdent &cid) const 00068 { 00069 return((identifier == cid) || Protocol::AreYouA(cid)); 00070 } 00071 00072 } // namespace lcore 00073 } // namespace strmod 00074 00075 #endif
1.3-rc1