CoreLinux++  0.4.32
ScalarIdentifiers.hpp
1 #if !defined (__SCALARIDENTIFIERS_HPP)
2 #define __SCALARIDENTIFIERS_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 IN_COMMON_HPP
25  #error ScalarIdentifiers.hpp is included by Common.hpp only.
26 #endif
27 
28 namespace corelinux
29 {
36  template< class ScalarType >
38  {
39 
40  public:
41 
42  //
43  // Constructors and destructor
44  //
45 
47 
49  :
50  Identifier(),
51  theScalar(0)
52  {
53  ; // do nothing
54  }
55 
57 
58  ScalarIdentifier( ScalarType aType )
59  :
60  Identifier(),
61  theScalar(aType)
62  {
63  ; // do nothing
64  }
65 
67 
69  :
70  Identifier(aScalar),
71  theScalar( aScalar.getScalar() )
72  {
73  ; // do nothing
74  }
75 
77 
78  virtual ~ScalarIdentifier( void )
79  {
80  ; // do nothing
81  }
82 
83  //
84  // Operator overloads
85  //
87 
88  inline ScalarType & operator=( ScalarType aScalar )
89  {
90  theScalar = aScalar;
91  return ( *this );
92  }
93 
95 
96  inline ScalarIdentifier & operator=( const ScalarIdentifier &aScalar )
97  {
98  theScalar = aScalar.getScalar();
99  return ( *this );
100  }
101 
103 
104  inline operator ScalarType &( void )
105  {
106  return theScalar;
107  }
108 
110 
111  inline operator ScalarType *( void )
112  {
113  return &theScalar;
114  }
115 
116  //
117  // Accessors
118  //
120 
121  inline const ScalarType & getScalar( void ) const
122  {
123  return theScalar;
124  }
125 
126  protected:
127 
134  virtual bool isEqual( IdentifierCref aRef ) const
135  {
136  return ( theScalar ==
137  ((const ScalarIdentifier &)aRef).theScalar );
138  }
139 
146  virtual bool isLessThan( IdentifierCref aRef ) const
147  {
148  return ( theScalar <
149  ((const ScalarIdentifier &)aRef).theScalar );
150  }
151 
158  virtual bool isLessThanOrEqual( IdentifierCref aRef ) const
159  {
160  return ( theScalar <=
161  ((const ScalarIdentifier &)aRef).theScalar );
162  }
163 
170  virtual bool isGreaterThan( IdentifierCref aRef ) const
171  {
172  return ( theScalar >
173  ((const ScalarIdentifier &)aRef).theScalar );
174  }
175 
182  virtual bool isGreaterThanOrEqual( IdentifierCref aRef ) const
183  {
184  return ( theScalar >=
185  ((const ScalarIdentifier &)aRef).theScalar );
186  }
187 
188  private:
189 
191 
192  ScalarType theScalar;
193  };
194 
195 }
196 
197 using corelinux::Dword;
198 using corelinux::Int;
199 using corelinux::Short;
200 using corelinux::Word;
201 using corelinux::UnsignedInt;
202 
204 
205 DECLARE_TYPE( CORELINUX(ScalarIdentifier<Int>), IntIdentifier );
206 
208 
209 DECLARE_TYPE( CORELINUX(ScalarIdentifier<UnsignedInt>), UnsignedIdentifier );
210 
212 
213 DECLARE_TYPE( CORELINUX(ScalarIdentifier<Short>), ShortIdentifier );
214 
216 
217 DECLARE_TYPE( CORELINUX(ScalarIdentifier<Dword>), DwordIdentifier );
218 
220 
221 DECLARE_TYPE( CORELINUX(ScalarIdentifier<Word>), WordIdentifier );
222 
224 
225 DECLARE_TYPE( ShortIdentifier, SemaphoreIdentifier );
226 
228 
229 DECLARE_TYPE( IntIdentifier, SemaphoreGroupIdentifier );
230 
232 
233 DECLARE_TYPE( IntIdentifier, ThreadIdentifier );
234 
236 
237 DECLARE_TYPE( IntIdentifier, ProcessIdentifier );
238 
240 
241 DECLARE_TYPE( IntIdentifier, MemoryIdentifier );
242 
244 
245 DECLARE_TYPE( UnsignedIdentifier, UserIdentifier );
246 
248 
249 DECLARE_TYPE( UnsignedIdentifier, GroupIdentifier );
250 
251 
252 #endif // if defined(__SCALARIDENTIFIERS_HPP)
253 
254 /*
255  Common rcs information do not modify
256  $Author: frankc $
257  $Revision: 1.2 $
258  $Date: 2000/05/25 04:26:14 $
259  $Locker: $
260 */
261 
262 
ScalarIdentifier(void)
Default constructor.
Definition: ScalarIdentifiers.hpp:48
virtual ~ScalarIdentifier(void)
Virtual Destructor.
Definition: ScalarIdentifiers.hpp:78
ScalarIdentifier(const ScalarIdentifier &aScalar)
Copy constructor.
Definition: ScalarIdentifiers.hpp:68
const ScalarType & getScalar(void) const
Returns a const reference.
Definition: ScalarIdentifiers.hpp:121
virtual bool isGreaterThan(IdentifierCref aRef) const
Greater than method.
Definition: ScalarIdentifiers.hpp:170
An Identifier is a abstract representation of identity.
Definition: Identifier.hpp:40
virtual bool isGreaterThanOrEqual(IdentifierCref aRef) const
Greater than or equal method.
Definition: ScalarIdentifiers.hpp:182
ScalarType & operator=(ScalarType aScalar)
Operator assignment for scalars.
Definition: ScalarIdentifiers.hpp:88
ScalarIdentifier provides a templated interface for declaring CoreLinux Identifiers for simple scalar...
Definition: ScalarIdentifiers.hpp:37
ScalarIdentifier(ScalarType aType)
Initializing constructor.
Definition: ScalarIdentifiers.hpp:58
virtual bool isLessThanOrEqual(IdentifierCref aRef) const
Less than or equal method.
Definition: ScalarIdentifiers.hpp:158
virtual bool isLessThan(IdentifierCref aRef) const
Less than method.
Definition: ScalarIdentifiers.hpp:146
ScalarIdentifier & operator=(const ScalarIdentifier &aScalar)
Operator assignment of Identifiers.
Definition: ScalarIdentifiers.hpp:96
virtual bool isEqual(IdentifierCref aRef) const
Equality method.
Definition: ScalarIdentifiers.hpp:134

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