corelinux::Bridge< Implementation > Class Template Referenceabstract

When an abstraction can have one of several possible implementations, the usual way to accommodate them is to use inheritance. More...

`#include <Bridge.hpp>`

## Public Member Functions

| Bridge (Implementation aImplementation)
| Default Constructor requires a Implementation. More...
virtual | ~Bridge (void)
| Virtual Destructor.
Bridge & | operator= (const Bridge &aRef) throw (Exception)
| Assignment operator overload. More...
bool | operator== (const Bridge &) const
| Equality operator overload. More...
bool | operator!= (const Bridge &) const
| Non-equality operator overload. More...
Public Member Functions inherited from corelinux::CoreLinuxObject
| CoreLinuxObject (void)
| Default Constructor.
| CoreLinuxObject (CoreLinuxObjectCref)
| Copy Constructor. More...
virtual | ~CoreLinuxObject (void)
| Virtual Destructor.
CoreLinuxObjectRef | operator= (CoreLinuxObjectCref)
| Assignment operator overload. More...
bool | operator== (CoreLinuxObjectCref) const
| Equality operator overload. More...
bool | operator!= (CoreLinuxObjectCref) const
| Non-equality operator overload. More...

## Protected Member Functions

| Bridge (void) throw (Assertion)
| Default Constructor Because a Bridge requires a implementation to work, you can not construct one without it. More...
| Bridge (const Bridge &) throw (Assertion)
| Copy Constructor Because theImplementation is owned by the Bridge, only the assignment operator insures that the derivation is constructed and can be invoked for object management. More...
Implementation | getImplementation (void) const
| Gets current theImplementation. More...
void | setImplementation (Implementation aImpl) throw (Exception)
| Set theImplementation. More...
virtual Implementation | cloneImplementation (Implementation)=0 throw (Exception)
| Pure virtual method to have the derivation contain theImplementation.by ownership. More...

## Detailed Description

### template<class Implementation>
class corelinux::Bridge< Implementation >

When an abstraction can have one of several possible implementations, the usual way to accommodate them is to use inheritance.

An abstract class defines the interface to the abstraction, and concrete subclasses implement it in different ways. But this approach isn't always flexible enough. Inheritance binds an implementation to the abstraction permanently, which makes it difficult to modify, extend, and reuse abstractions and implementations independently. A Bridge decouples an abstraction from its implementation so that the two can vary independently.

## Constructor & Destructor Documentation

template<class Implementation >

corelinux::Bridge< Implementation >::Bridge | ( | Implementation | aImplementation | ) |

inline

Default Constructor requires a Implementation.

Parameters

  Implementation | instance

template<class Implementation >

corelinux::Bridge< Implementation >::Bridge | ( | void |  | ) |
throw | ( | Assertion
| ) |  |

inline protected

Default Constructor Because a Bridge requires a implementation to work, you can not construct one without it.

Parameters

  void |

Exceptions

  NEVER_GET_HERE |

template<class Implementation >

corelinux::Bridge< Implementation >::Bridge | ( | const Bridge< Implementation > & |  | ) |
throw | ( | Assertion
| ) |  |

inline protected

Copy Constructor Because theImplementation is owned by the Bridge, only the assignment operator insures that the derivation is constructed and can be invoked for object management.

Parameters

  Bridge | const reference

Exceptions

  NEVER_GET_HERE |

## Member Function Documentation

template<class Implementation >

virtual Implementation corelinux::Bridge< Implementation >::cloneImplementation | ( | Implementation |  | ) |
throw | ( | Exception
| ) |  |

protected pure virtual

Pure virtual method to have the derivation contain theImplementation.by ownership.

Parameters

  Implementation | instance

Returns
  Implementation instance

Exceptions

  Exception | - implementation defined

Referenced by corelinux::Bridge< Implementation >::setImplementation().

template<class Implementation >

Implementation corelinux::Bridge< Implementation >::getImplementation | ( | void |  | ) | const

inline protected

Gets current theImplementation.

Returns
  Implementation instance

template<class Implementation >

bool corelinux::Bridge< Implementation >::operator!= | ( | const Bridge< Implementation > & |  | ) | const

inline

Non-equality operator overload.

Parameters

  Bridge | const reference

Returns
  false if equal, true otherwise

template<class Implementation >

Bridge& corelinux::Bridge< Implementation >::operator= | ( | const Bridge< Implementation > & | aRef | ) |
throw | ( | Exception
| ) |  |

inline

Assignment operator overload.

This may throw Exception if there is a problem cloning theImplementation.

Parameters

  Bridge | const reference

Returns
  Bridge reference to self

Exceptions

  Exception | - implementation defined

References corelinux::Bridge< Implementation >::setImplementation().

template<class Implementation >

bool corelinux::Bridge< Implementation >::operator== | ( | const Bridge< Implementation > & |  | ) | const

inline

Equality operator overload.

Parameters

  Bridge | const reference

Returns
  true if equal, false otherwise

template<class Implementation >

void corelinux::Bridge< Implementation >::setImplementation | ( | Implementation | aImpl | ) |
throw | ( | Exception
| ) |  |

inline protected

Set theImplementation.

This in turn calls the pure-virtual method cloneImplementation so that a pointer unique to this object, or one which is referencable can be managed

Parameters

  Implementation | instance

Exceptions

  Exception | - implementation defined

References corelinux::Bridge< Implementation >::cloneImplementation().

Referenced by corelinux::Bridge< Implementation >::operator=().

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

- Bridge.hpp

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium