00001 #if !defined(__EVENT_HPP)
00002 #define __EVENT_HPP
00003
00004 /*
00005 CoreLinux++
00006 Copyright (C) 2000 CoreLinux Consortium
00007
00008 The CoreLinux++ Library is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU Library General Public License as
00010 published by the Free Software Foundation; either version 2 of the
00011 License, or (at your option) any later version.
00012
00013 The CoreLinux++ Library Library is distributed in the hope that it will
00014 be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016 Library General Public License for more details.
00017
00018 You should have received a copy of the GNU Library General Public
00019 License along with the GNU C Library; see the file COPYING.LIB. If not,
00020 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021 Boston, MA 02111-1307, USA.
00022 */
00023
00024 #if !defined(__COMMON_HPP)
00025 #include <Common.hpp>
00026 #endif
00027
00028 namespace corelinux
00029 {
00034 template < class IdentifierType = Identifier >
00035 class Event
00036 {
00037 public:
00038 //
00039 // Constructors and destructor
00040 //
00041
00043
00044 Event( void )
00045 :
00046 theIdentifier( NULLPTR )
00047 {
00048 ; // do nothing
00049 }
00050
00052
00053 Event( const IdentifierType & aId )
00054 :
00055 theIdentifier( new IdentifierType(aId) )
00056 {
00057 ; // do nothing
00058 }
00060
00061 Event( const Event & aEvent )
00062 :
00063 theIdentifier( NULLPTR )
00064 {
00065 if( aEvent.theIdentifier != NULLPTR )
00066 {
00067 theIdentifier = new IdentifierType
00068 (
00069 *(aEvent.theIdentifier)
00070 );
00071 }
00072 }
00073
00075
00076 virtual ~Event( void )
00077 {
00078 if( theIdentifier != NULLPTR )
00079 {
00080 delete theIdentifier;
00081 theIdentifier = NULLPTR;
00082 }
00083 else
00084 {
00085 ; // do nothing
00086 }
00087 }
00088
00089 //
00090 // Operator overloads
00091 //
00092
00094
00095 Event & operator=( const Event & aEvent )
00096 {
00097 if( *this == aEvent )
00098 {
00099 ; // do nothing
00100 }
00101 else
00102 {
00103 if( theIdentifier != NULLPTR )
00104 {
00105 delete theIdentifier;
00106 theIdentifier = NULLPTR;
00107 }
00108 else
00109 {
00110 ; // do nothing
00111 }
00112
00113 if( aEvent.theIdentifier != NULLPTR )
00114 {
00115 theIdentifier = new IdentifierType
00116 (
00117 *(aEvent.theIdentifier)
00118 );
00119 }
00120 else
00121 {
00122 ; // do nothing
00123 }
00124 }
00125 return (*this);
00126 }
00127
00129
00130 bool operator==( const Event & aEvent ) const
00131 {
00132 bool isSame( false );
00133
00134 if( theIdentifier != NULLPTR &&
00135 aEvent.theIdentifier != NULLPTR )
00136 {
00137 isSame = (*theIdentifier == *(aEvent.theIdentifier) );
00138 }
00139 else
00140 {
00141 isSame = ( this == &aEvent );
00142 }
00143
00144 return isSame;
00145 }
00146
00148
00149 operator const IdentifierType &( void ) const
00150 throw ( NullPointerException )
00151 {
00152 if( theIdentifier == NULLPTR )
00153 {
00154 throw NullPointerException(LOCATION);
00155 }
00156 else
00157 {
00158 ; // do nothing
00159 }
00160 return ( *theIdentifier );
00161 }
00162
00164
00165 operator IdentifierType *( void ) const
00166 throw (NullPointerException)
00167 {
00168 if( theIdentifier == NULLPTR )
00169 {
00170 throw NullPointerException(LOCATION);
00171 }
00172 else
00173 {
00174 ; // do nothing
00175 }
00176
00177 return theIdentifier;
00178 }
00179
00180 protected:
00181
00182
00183 private:
00184
00185 IdentifierType *theIdentifier;
00186
00187 };
00188
00189 }
00190
00191 #endif // if !defined(__EVENT_HPP)
00192
00193 /*
00194 Common rcs information do not modify
00195 $Author: frankc $
00196 $Revision: 1.1 $
00197 $Date: 2000/05/07 03:41:47 $
00198 $Locker: $
00199 */
00200
00201