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

Object.h

Go to the documentation of this file.
00001 /*
00002 File: Object.h
00003 
00004 Function: Definition of a polymorphic object. 
00005 
00006 Author(s): Andrew Willmott
00007 
00008 Copyright: (c) 1995-2000, Andrew Willmott
00009 */
00010 
00011 #ifndef __Object__
00012 #define __Object__
00013 
00014 #include <iostream.h>
00015 
00016 
00017  class Object
00018 {
00019 public:
00020  virtual Void Print(ostream &s) const { s << "unknown"; };
00021  virtual Void Parse(istream &s) {};
00022  virtual Object *Clone() const { return new Object; };
00023  virtual Void Free() { delete this; };
00024 };
00025 
00026  typedef Object *ObjectPtr;
00027 
00028 
00029 // --- stream operators -----------------------------------------
00030 
00031 
00032 inline ostream &operator << (ostream &s, ObjectPtr objPtr);
00033 inline istream &operator >> (istream &s, ObjectPtr objPtr);
00034 inline ostream &operator << (ostream &s, Object &obj);
00035 inline istream &operator >> (istream &s, Object &obj);
00036 
00037 
00038 // --- Inlines ----------------------------------------------------------------
00039 
00040 
00041  inline ostream &operator << (ostream &s, ObjectPtr objPtr)
00042 {
00043 objPtr->Print(s);
00044 return(s);
00045 }
00046 
00047  inline istream &operator >> (istream &s, ObjectPtr objPtr)
00048 {
00049 objPtr->Parse(s);
00050 return(s);
00051 }
00052 
00053  inline ostream &operator << (ostream &s, Object &obj)
00054 {
00055 obj.Print(s);
00056 return(s);
00057 }
00058 
00059  inline istream &operator >> (istream &s, Object &obj)
00060 {
00061 obj.Parse(s);
00062 return(s);
00063 }
00064 
00065 
00066 // --- Templates -----------------------------------------------------
00067 
00068 
00069  template <class T> T *Clone(T *t)
00070 {
00071 return((T *) t->Clone());
00072 }
00073 
00074 #endif

Generated at Sat Aug 5 00:16:33 2000 for Class Library by doxygen 1.1.0 written by Dimitri van Heesch, © 1997-2000

AltStyle によって変換されたページ (->オリジナル) /