00001
#if !defined(__SEMAPHOREGROUP_HPP)
00002
#define __SEMAPHOREGROUP_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#if !defined(__COMMON_HPP)
00025
#include <Common.hpp>
00026
#endif
00027
00028
#if !defined(__SEMAPHORECOMMON_HPP)
00029
#include <SemaphoreCommon.hpp>
00030
#endif
00031
00032
#if !defined(__ABSTRACTSEMAPHORE_HPP)
00033
#include <AbstractSemaphore.hpp>
00034
#endif
00035
00036
#if !defined(__MAP_HPP)
00037
#include <Map.hpp>
00038
#endif
00039
00040
00041
namespace corelinux
00042 {
00043
const Dword NAMEBUFFERSIZE(254);
00044
00045
struct SemaphoreReference
00046 {
00047 Int theCount;
00048 AbstractSemaphorePtr theSem;
00049 };
00050
00051 CORELINUX_MAP( Index, SemaphoreReference, std::less<Index> , SemaphoreShares );
00052
00053 DECLARE_CLASS( SemaphoreGroup );
00054
00062 class SemaphoreGroup :
public Synchronized
00063 {
00064
public:
00065
00078
SemaphoreGroup( Short , Int Rights =
OWNER_ALL )
00079
throw(
Assertion,
SemaphoreException);
00080
00103
SemaphoreGroup
00104 (
00105 Short,
00106
SemaphoreGroupIdentifierCref,
00107 Int ,
00108
CreateDisposition disp=
FAIL_IF_EXISTS
00109 )
throw(
Assertion,
SemaphoreException);
00110
00132
SemaphoreGroup
00133 (
00134 Short,
00135 CharCptr,
00136 Int ,
00137
CreateDisposition disp=
FAIL_IF_EXISTS
00138 )
throw(
Assertion,
SemaphoreException);
00139
00140
00142
00143
virtual ~SemaphoreGroup(
void );
00144
00145
00146
00147
00148
00155
bool operator==(
SemaphoreGroupCref )
const;
00156
00157
00158
00164 Short
getSemaphoreCount(
void )
const;
00165
00171 inline SemaphoreGroupIdentifierCref getIdentifier(
void )
const
00172
{
00173
return theIdentifier;
00174 }
00175
00176
00177
00178
00179
00186
virtual AbstractSemaphorePtr createSemaphore(
void )
00187 throw(
SemaphoreException ) = 0;
00188
00206 virtual
AbstractSemaphorePtr createSemaphore
00207 (
00208
SemaphoreIdentifierRef aIdentifier,
00209 CreateDisposition disp = CREATE_OR_REUSE,
00210
bool Recursive=false,
00211
bool Balking = false
00212 ) throw( SemaphoreException ) = 0;
00213
00232 virtual
AbstractSemaphorePtr createSemaphore
00233 (
00234 std::string aName,
00235 CreateDisposition disp = CREATE_OR_REUSE,
00236
bool Recursive=false,
00237
bool Balking = false
00238 ) throw( SemaphoreException ) = 0;
00239
00247 virtual
void destroySemaphore(
AbstractSemaphorePtr )
00248 throw( SemaphoreException ) = 0;
00249 protected:
00250
00251
00252
00253
00255
00256
SemaphoreGroup(
void ) throw(
Assertion );
00257
00259
00260
SemaphoreGroup(
SemaphoreGroupCref )
00261 throw( Assertion );
00262
00263
00264
00265
00266
00268
00269
SemaphoreGroupRef operator=(
SemaphoreGroupCref )
00270 throw( Assertion );
00271
00272
00273
00274
00275
00284
void setGroupType( IntCref ) const;
00285
00293
00294
00295
00296
00298
00299 inline
bool isPrivate(
void )
const
00300
{
00301
return (theGroupCSA == NULLPTR);
00302 }
00303
00304
protected:
00305
00306
private:
00307
00308
friend class SemaphoreCommon;
00309
00311
00312
SemaphoreGroupIdentifier theIdentifier;
00313
00315
00316 Short theNumberOfSemaphores;
00317
00319
00320
CSAGrpHeaderPtr theGroupCSA;
00321
00323
00324 Char theName[NAMEBUFFERSIZE];
00325
00326 };
00327 }
00328
00329
#endif // if !defined(__SEMAPHOREGROUP_HPP)
00330
00331
00332
00333
00334
00335
00336
00337
00338