00001
#if !defined(__PROXY_HPP)
00002
#define __PROXY_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#if !defined(__COMMON_HPP)
00026
#include <Common.hpp>
00027
#endif
00028
00029
namespace corelinux
00030 {
00036
template<
class SubjectImpl >
00037 class Proxy
00038 {
00039
public:
00040
00041
00042
00043
00044
00046
00047 Proxy(
void )
00048 :
00049 theSubject( NULLPTR )
00050 {
00051 ;
00052 }
00053
00059 Proxy( SubjectImpl *aSubject )
00060
throw(
Assertion)
00061 :
00062 theSubject( aSubject )
00063 {
00064 REQUIRE( aSubject != NULLPTR );
00065 }
00066
00072 Proxy(
const Proxy &aProxy )
00073 :
00074 theSubject( aProxy.theSubject )
00075 {
00076 ;
00077 }
00078
00080
00081 virtual ~Proxy(
void )
00082 {
00083 theSubject = NULLPTR;
00084 }
00085
00086
00087
00088
00089
00096 Proxy & operator=(
const Proxy &aProxy )
00097 {
00098
if( (*
this == aProxy) ==
false )
00099 {
00100 theSubject = aProxy.
getSubject();
00101 }
00102
else
00103 {
00104 ;
00105 }
00106
00107
return ( *this );
00108 }
00109
00116 bool operator==(
const Proxy &aProxy )
const
00117
{
00118
return (
this == &aProxy &&
00119 theSubject == aProxy.
getSubject() );
00120 }
00121
00127 virtual SubjectImpl *
operator->(
void )
00128 {
00129
return theSubject;
00130 }
00131
00138 virtual SubjectImpl &
operator*(
void )
00139 throw(
Assertion )
00140 {
00141 REQUIRE( theSubject != NULLPTR );
00142
return ( *theSubject );
00143 }
00144
00145
00146
00147
00154 virtual const SubjectImpl &
getSubject(
void ) const
00155 throw(
Assertion )
00156 {
00157 REQUIRE( theSubject != NULLPTR );
00158
return ( *theSubject );
00159 }
00160
00161
protected:
00162
00163
00164
00165
00166
00167
virtual void setSubject( SubjectImpl *aSubject )
00168 {
00169 theSubject = aSubject;
00170 }
00171
00172
00173
protected:
00174
00176
00177 SubjectImpl *theSubject;
00178 };
00179 }
00180
00181
#endif // if !defined(__PROXY_HPP)
00182
00183
00184
00185
00186
00187
00188
00189
00190