CoreLinux++  0.4.32
Decorator.hpp
1 #if !defined (__DECORATOR_HPP)
2 #define __DECORATOR_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 
38  template <class Implementation>
39  class Decorator : public CoreLinuxObject
40  {
41  public:
42 
43  //
44  // Constructors
45  //
46 
52  Decorator( Implementation aImplementation )
53  :
55  theImplementation(aImplementation)
56  {
57  ; // do nothing
58  }
59 
65  Decorator( const Decorator &aDecorator )
66  :
69  (
70  aDecorator.getImplementation()
71  )
72  {
73  ; // do nothing
74  }
75 
77 
78  virtual ~Decorator( void )
79  {
80  ; // do nothing
81  }
82 
83  //
84  // Operator overloads
85  //
94  Decorator & operator=( const Decorator & aDecorator )
95  throw(Exception)
96  {
97  this->setImplementation
98  ( aDecorator.getImplementation() );
99 
100  return (*this);
101  }
102 
109  bool operator==( const Decorator & aDecorator ) const
110  {
111  return
112  (
113  this == &aDecorator &&
114  (
115  this->getImplementation() ==
116  aDecorator.getImplementation()
117  )
118  );
119  }
120 
121  //
122  // Accessors
123  //
124 
130  virtual Implementation getImplementation( void ) const
131  {
132  return theImplementation;
133  }
134 
135  //
136  // Mutators
137  //
138 
144  virtual void setImplementation( Implementation aImplementation )
145  throw(Exception)
146  {
147  theImplementation = aImplementation;
148  }
149 
150  protected:
151 
152  //
153  // Constructors
154  //
155 
163  Decorator( void )
164  throw (Assertion)
165  :
167  {
168  NEVER_GET_HERE;
169  }
170 
171 
172  protected:
173 
175 
176  Implementation theImplementation;
177 
178 
179  };
180 
181 }
182 
183 #endif // if !defined(__DECORATOR_HPP)
184 
185 /*
186  Common rcs information do not modify
187  $Author: prudhomm $
188  $Revision: 1.1 $
189  $Date: 2000/04/23 20:43:13 $
190  $Locker: $
191 */
192 
193 
194 
195 
Decorators can attach additional responsibilities to an object dynamically which provide a more flexi...
Definition: Decorator.hpp:39
Decorator(void)
Default Constructor Because a Decorator requires a implementation to work, you can not construct one ...
Definition: Decorator.hpp:163
Decorator(Implementation aImplementation)
Default Constructor requires a Implementation.
Definition: Decorator.hpp:52
Implementation theImplementation
Storage for theImplementation object.
Definition: Decorator.hpp:176
virtual void setImplementation(Implementation aImplementation)
Sets current theImplementation to aImplementation.
Definition: Decorator.hpp:144
Decorator(const Decorator &aDecorator)
Copy Constructor copies theImplementation.
Definition: Decorator.hpp:65
Forward reference the various common classes.
Definition: AbstractAllocator.hpp:32
Exception is the base exception class used in the CoreLinux++ libraries.
Definition: Exception.hpp:51
Decorator & operator=(const Decorator &aDecorator)
Assignment operator overload.
Definition: Decorator.hpp:94
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 Decorator &aDecorator) const
Equality operator overload.
Definition: Decorator.hpp:109
virtual ~Decorator(void)
Virtual Destructor.
Definition: Decorator.hpp:78
virtual Implementation getImplementation(void) const
Gets current theImplementation.
Definition: Decorator.hpp:130

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