Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Cloneable.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_Cloneable_h_
00003 #define INCLUDED_Cloneable_h_
00004 
00005 //! An interface for cloning objects -- needed for making copies with polymorphism (operator= doesn't work as virtual)
00006 class Cloneable {
00007 public:
00008   virtual ~Cloneable() {}
00009 
00010   //! returns a copy of @c this
00011   /*! When implementing, your class @e should use its own type as the
00012    *  return type, e.g.:
00013    *
00014    *  @code
00015    *  class Foo : public Cloneable {
00016    *  public:
00017    *    //note: return Foo* instead of Cloneable* !
00018    *    //Allows users to avoid needing to cast the results
00019    *    virtual Foo* clone() { return new Foo(*this); }
00020    *  };
00021    *  @endcode
00022    *
00023    *  <i>HOWEVER, this is currently unsupported in gcc 3.3</i>, which
00024    *  the latest version for which Sony has supplied the patches to
00025    *  work on the Aibo.
00026    *
00027    *  So instead, you must currently provide the interface exactly as
00028    *  shown, and then the caller will probably need to cast the result
00029    *  to the known type.  Hopefully Sony will eventually update the
00030    *  gcc version to at least 3.4 and we can switch over to use the
00031    *  "covariant return type".
00032    */
00033   virtual Cloneable* clone() const=0;
00034 };
00035 
00036 /*! @file
00037  * @brief Defines Cloneable, and interfacing for cloning objects -- needed for making copies with polymorphism (operator= doesn't work as virtual)
00038  * @author ejt (Creator)
00039  *
00040  * $Author: ejt $
00041  * $Name: tekkotsu-2_4_1 $
00042  * $Revision: 1.1 $
00043  * $State: Exp $
00044  * $Date: 2005/06/29 22:05:45 $
00045  */
00046 
00047 #endif

Tekkotsu v2.4.1
Generated Tue Aug 16 16:32:46 2005 by Doxygen 1.4.4