User Manual, Developers Guide and API Documentation

wns::HasBirthmark Class Reference

Provide unique birthmark (identifier) for all clones of one origin. More...

#include <Birthmark.hpp>

Inheritance diagram for wns::HasBirthmark:

Inheritance graph
[legend]
Collaboration diagram for wns::HasBirthmark:

Collaboration graph
[legend]

List of all members.

Public Member Functions

const BirthmarkgetBirthmark () const
 Retrieve the birthmark.
 HasBirthmark ()
 Default constructor.
virtual ~HasBirthmark ()
 Destructor.

Protected Member Functions

void setBirthmark (const Birthmark &other)
 Set the birthmark of an object.

Private Attributes

Birthmark birthmark
 Unique identifier.


Detailed Description

Note:
Always derive virtual from HasBirthmark!!
If you happen to have the need to recognize the copy of an object, the HasBirthmark base class may be of interest for you.

Here's how it works:

If you derive as follows:

 #include <WNS/Birthmark.hpp>

 class Foo :
 public wns::HasBirthmark
 {};

each new instance of your class Foo comes equipped with a new and unique 'Birthmark' object. You don't have to worry about its creation. Birthmark objects can be stored locally and have operators to identify them as being equal or unequal.

Example:

 Foo a, b; // construct two distinct objects

 Foo copyOfa(a); // explicit copy of a

 Foo copyOfb = b; // assignment of b

 CPPUNIT_ASSERT(a.getBirthmark() != b.getBirthmark());
 CPPUNIT_ASSERT(a.getBirthmark() == copyOfa.getBirthmark());
... and so on (assignment is left as an exercise to the reader)

If you clone/copy an object of your class Foo, each cloned/copied object will have the same birthmark, enabling you to detect whether an object is equal to or a clone of some other object.

Birthmarks are NOT:

Definition at line 146 of file Birthmark.hpp.


Constructor & Destructor Documentation

HasBirthmark::HasBirthmark (  ) 

Definition at line 81 of file Birthmark.cpp.

HasBirthmark::~HasBirthmark (  )  [virtual]

Definition at line 87 of file Birthmark.cpp.


Member Function Documentation

const Birthmark & HasBirthmark::getBirthmark (  )  const

Definition at line 93 of file Birthmark.cpp.

void HasBirthmark::setBirthmark ( const Birthmark other  )  [protected]

Warning:
Use this with great care! Never make it public available! This method is normally only needed if you have special clone methods for an object that don't use the copy constructor.

Definition at line 100 of file Birthmark.cpp.


Member Data Documentation

Definition at line 183 of file Birthmark.hpp.


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

Generated on Sat May 26 03:32:50 2012 for openWNS by  doxygen 1.5.5