Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
Cloneable.hGo 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 //!destructor 00009 virtual ~Cloneable() {} 00010 00011 //! returns a copy of @c this 00012 /*! When implementing, your class @e should use its own type as the 00013 * return type, e.g.: 00014 * 00015 * @code 00016 * class Foo : public Cloneable { 00017 * public: 00018 * //note: return Foo* instead of Cloneable* ! 00019 * //Allows users to avoid needing to cast the results 00020 * virtual Foo* clone() { return new Foo(*this); } 00021 * }; 00022 * @endcode 00023 * 00024 * <i>HOWEVER, this is currently unsupported in gcc 3.3</i>, which 00025 * the latest version for which Sony has supplied the patches to 00026 * work on the Aibo. 00027 * 00028 * So instead, you must currently provide the interface exactly as 00029 * shown, and then the caller will probably need to cast the result 00030 * to the known type. Hopefully Sony will eventually update the 00031 * gcc version to at least 3.4 and we can switch over to use the 00032 * "covariant return type". 00033 */ 00034 00035 #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && (__GNUC_MINOR__ > 3))) 00036 virtual Cloneable* clone() const __attribute__ ((warn_unused_result)) =0; 00037 #else 00038 virtual Cloneable* clone() const =0; 00039 #endif 00040 }; 00041 00042 /*! @file 00043 * @brief Defines Cloneable, and interfacing for cloning objects -- needed for making copies with polymorphism (operator= doesn't work as virtual) 00044 * @author ejt (Creator) 00045 */ 00046 00047 #endif |
Tekkotsu v5.1CVS |
Generated Mon May 9 04:58:37 2016 by Doxygen 1.6.3 |