CoreLinux++  0.4.32
Event.hpp
1 #if !defined(__EVENT_HPP)
2 #define __EVENT_HPP
3 
4 /*
5  CoreLinux++
6  Copyright (C) 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 namespace corelinux
29 {
34  template < class IdentifierType = Identifier >
35  class Event
36  {
37  public:
38  //
39  // Constructors and destructor
40  //
41 
43 
44  Event( void )
45  :
46  theIdentifier( NULLPTR )
47  {
48  ; // do nothing
49  }
50 
52 
53  Event( const IdentifierType & aId )
54  :
55  theIdentifier( new IdentifierType(aId) )
56  {
57  ; // do nothing
58  }
60 
61  Event( const Event & aEvent )
62  :
63  theIdentifier( NULLPTR )
64  {
65  if( aEvent.theIdentifier != NULLPTR )
66  {
67  theIdentifier = new IdentifierType
68  (
69  *(aEvent.theIdentifier)
70  );
71  }
72  }
73 
75 
76  virtual ~Event( void )
77  {
78  if( theIdentifier != NULLPTR )
79  {
80  delete theIdentifier;
81  theIdentifier = NULLPTR;
82  }
83  else
84  {
85  ; // do nothing
86  }
87  }
88 
89  //
90  // Operator overloads
91  //
92 
94 
95  Event & operator=( const Event & aEvent )
96  {
97  if( *this == aEvent )
98  {
99  ; // do nothing
100  }
101  else
102  {
103  if( theIdentifier != NULLPTR )
104  {
105  delete theIdentifier;
106  theIdentifier = NULLPTR;
107  }
108  else
109  {
110  ; // do nothing
111  }
112 
113  if( aEvent.theIdentifier != NULLPTR )
114  {
115  theIdentifier = new IdentifierType
116  (
117  *(aEvent.theIdentifier)
118  );
119  }
120  else
121  {
122  ; // do nothing
123  }
124  }
125  return (*this);
126  }
127 
129 
130  bool operator==( const Event & aEvent ) const
131  {
132  bool isSame( false );
133 
134  if( theIdentifier != NULLPTR &&
135  aEvent.theIdentifier != NULLPTR )
136  {
137  isSame = (*theIdentifier == *(aEvent.theIdentifier) );
138  }
139  else
140  {
141  isSame = ( this == &aEvent );
142  }
143 
144  return isSame;
145  }
146 
148 
149  operator const IdentifierType &( void ) const
150  throw ( NullPointerException )
151  {
152  if( theIdentifier == NULLPTR )
153  {
154  throw NullPointerException(LOCATION);
155  }
156  else
157  {
158  ; // do nothing
159  }
160  return ( *theIdentifier );
161  }
162 
164 
165  operator IdentifierType *( void ) const
166  throw (NullPointerException)
167  {
168  if( theIdentifier == NULLPTR )
169  {
170  throw NullPointerException(LOCATION);
171  }
172  else
173  {
174  ; // do nothing
175  }
176 
177  return theIdentifier;
178  }
179 
180  protected:
181 
182 
183  private:
184 
185  IdentifierType *theIdentifier;
186 
187  };
188 
189 }
190 
191 #endif // if !defined(__EVENT_HPP)
192 
193 /*
194  Common rcs information do not modify
195  $Author: frankc $
196  $Revision: 1.1 $
197  $Date: 2000/05/07 03:41:47 $
198  $Locker: $
199 */
200 
201 
bool operator==(const Event &aEvent) const
Equality operator.
Definition: Event.hpp:130
virtual ~Event(void)
Virtual destructor.
Definition: Event.hpp:76
Event(void)
Default constructor protected.
Definition: Event.hpp:44
Event(const IdentifierType &aId)
Initializing constructor.
Definition: Event.hpp:53
Forward reference the various common classes.
Definition: AbstractAllocator.hpp:32
Event & operator=(const Event &aEvent)
Assignment operator.
Definition: Event.hpp:95
NullPointerException is the base exception type for NullPointer.
Definition: NullPointerException.hpp:40
Event provides a type basis for event ontologies.
Definition: Event.hpp:35
Event(const Event &aEvent)
Copy constructor.
Definition: Event.hpp:61

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