CoreLinux++  0.4.32
Bridge.hpp
1 #if !defined (__BRIDGE_HPP)
2 #define __BRIDGE_HPP
3 
4 /*
5  CoreLinux++
6  Copyright (C) 1999,2000 CoreLinux Consortium
7 
8  The CoreLinux++ Library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12 
13  The CoreLinux++ Library Library is distributed in the hope that it will
14  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public
19  License along with the GNU C Library; see the file COPYING.LIB. If not,
20  write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA 02111-1307, USA.
22 */
23 
24 #if !defined(__COMMON_HPP)
25 #include <Common.hpp>
26 #endif
27 
28 
29 namespace corelinux
30 {
31 
43  template <class Implementation>
44  class Bridge : public CoreLinuxObject
45  {
46  public:
47 
53  Bridge( Implementation aImplementation )
54  :
56  theImplementation(aImplementation)
57  {
58  ; // do nothing
59  }
60 
61 
63 
64  virtual ~Bridge( void )
65  {
66  ; // do nothing
67  }
68 
69  //
70  // Operator overloads
71  //
80  Bridge & operator=( const Bridge & aRef ) throw(Exception)
81  {
82  this->setImplementation( aRef.getImplementation() );
83  return (*this);
84  }
85 
92  bool operator==( const Bridge & ) const
93  {
94  return (this == &aRef);
95  }
96 
103  bool operator!=( const Bridge & ) const
104  {
105  return !(*this == aRef);
106  }
107 
108  protected:
109 
117  Bridge( void ) throw (Assertion)
118  {
119  NEVER_GET_HERE;
120  }
121 
131  Bridge( const Bridge & ) throw (Assertion)
132  {
133  NEVER_GET_HERE;
134  }
135  //
136  // Accessors
137  //
143  Implementation getImplementation( void ) const
144  {
145  return theImplementation;
146  }
147 
148  //
149  // Mutators
150  //
151 
160  void setImplementation( Implementation aImpl ) throw(Exception)
161  {
162  theImplementation = cloneImplementation(aImpl);
163  }
164 
165 
174  virtual Implementation cloneImplementation
175  (
176  Implementation
177  ) throw(Exception) = 0;
178 
179  private:
180 
182 
183  Implementation theImplementation;
184 
185 
186  };
187 
188 }
189 
190 #endif // if !defined(__BRIDGE_HPP)
191 
192 /*
193  Common rcs information do not modify
194  $Author: prudhomm $
195  $Revision: 1.1 $
196  $Date: 2000/04/23 20:43:13 $
197  $Locker: $
198 */
199 
200 
201 
Bridge(Implementation aImplementation)
Default Constructor requires a Implementation.
Definition: Bridge.hpp:53
void setImplementation(Implementation aImpl)
Set theImplementation.
Definition: Bridge.hpp:160
Bridge & operator=(const Bridge &aRef)
Assignment operator overload.
Definition: Bridge.hpp:80
virtual Implementation cloneImplementation(Implementation)=0
Pure virtual method to have the derivation contain theImplementation.by ownership.
virtual ~Bridge(void)
Virtual Destructor.
Definition: Bridge.hpp:64
When an abstraction can have one of several possible implementations, the usual way to accommodate th...
Definition: Bridge.hpp:44
Implementation getImplementation(void) const
Gets current theImplementation.
Definition: Bridge.hpp:143
Forward reference the various common classes.
Definition: AbstractAllocator.hpp:32
bool operator!=(const Bridge &) const
Non-equality operator overload.
Definition: Bridge.hpp:103
Bridge(const Bridge &)
Copy Constructor Because theImplementation is owned by the Bridge, only the assignment operator insur...
Definition: Bridge.hpp:131
Exception is the base exception class used in the CoreLinux++ libraries.
Definition: Exception.hpp:51
Bridge(void)
Default Constructor Because a Bridge requires a implementation to work, you can not construct one wit...
Definition: Bridge.hpp:117
Assertion is-a Exception created when an assertion fails.
Definition: Assertion.hpp:423
An CoreLinuxObject is a base class for the library.
Definition: CoreLinuxObject.hpp:39
bool operator==(const Bridge &) const
Equality operator overload.
Definition: Bridge.hpp:92

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