Tekkotsu Homepage
Dev. Resources

Cloneable Class Reference

An interface for cloning objects -- needed for making copies with polymorphism (operator= doesn't work as virtual). More...

#include <Cloneable.h>

Inheritance diagram for Cloneable:

Detailed Description

An interface for cloning objects -- needed for making copies with polymorphism (operator= doesn't work as virtual).

Definition at line 6 of file Cloneable.h.

List of all members.

Public Member Functions

virtual ~Cloneable ()
virtual Cloneableclone () const =0
 returns a copy of this

Constructor & Destructor Documentation

virtual Cloneable::~Cloneable (  )  [virtual]


Definition at line 9 of file Cloneable.h.

Member Function Documentation

virtual Cloneable* Cloneable::clone (  )  const [pure virtual]

returns a copy of this

When implementing, your class should use its own type as the return type, e.g.:

  class Foo : public Cloneable {
    //note: return Foo* instead of Cloneable* !
    //Allows users to avoid needing to cast the results
    virtual Foo* clone() { return new Foo(*this); }

HOWEVER, this is currently unsupported in gcc 3.3, which the latest version for which Sony has supplied the patches to work on the Aibo.

So instead, you must currently provide the interface exactly as shown, and then the caller will probably need to cast the result to the known type. Hopefully Sony will eventually update the gcc version to at least 3.4 and we can switch over to use the "covariant return type".

Implemented in LinkComponent, KinematicJoint, SensorInfo, SensorRangeFinder, SensorContact, SensorFeedback, GPSSensor, OdometrySensor, RectangularObstacle, CircularObstacle, EllipticalObstacle, ConvexPolyObstacle, HierarchicalObstacle, BoxObstacle, CylindricalObstacle, SphericalObstacle, EllipsoidObstacle, plist::ObjectBase, plist::DictionaryOf< PO, Alloc >, plist::ArrayOf< PO, Alloc >, plist::Primitive< T >, plist::NamedEnumeration< T >, plist::OutputSelector, plist::Angle, plist::RGBColor< T >, plist::DictionaryOf< SinusoidalParameters >, plist::DictionaryOf< plist::Primitive< float > >, plist::DictionaryOf< plist::Primitive< T > >, plist::DictionaryOf< plist::Point >, plist::ArrayOf< ContactPoint >, plist::ArrayOf< plist::ArrayOf< plist::Primitive< float > > >, plist::ArrayOf< LinkComponent >, plist::ArrayOf< SensorInfo >, plist::ArrayOf< plist::Primitive< std::string > >, plist::ArrayOf< KinematicJoint >, plist::ArrayOf< plist::Primitive< float > >, plist::ArrayOf< plist::Primitive< T > >, plist::ArrayOf< plist::Angle >, plist::ArrayOf< LegParameters >, plist::ArrayOf< plist::Primitive< PLISTREAL > >, plist::Primitive< fmat::fmatReal >, plist::Primitive< PLISTREAL >, plist::Primitive< std::string >, plist::Primitive< float >, plist::Primitive< int >, plist::Primitive< unsigned int >, plist::Primitive< unsigned short >, plist::Primitive< string >, plist::Primitive< storage_t >, plist::Primitive< bool >, plist::NamedEnumeration< Config::vision_config::encoding_t >, plist::NamedEnumeration< J_DCT_METHOD >, plist::NamedEnumeration< Config::transports >, plist::NamedEnumeration< gain_levels >, plist::NamedEnumeration< volume_levels >, plist::NamedEnumeration< compression_t >, plist::NamedEnumeration< white_balance_levels >, plist::NamedEnumeration< consoleMode_t >, plist::NamedEnumeration< JointType_t >, and plist::NamedEnumeration< shutter_speeds >.

The documentation for this class was generated from the following file:

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:05 2016 by Doxygen 1.6.3