1 /*****************************************************************************/
2 /* Software Testing Automation Framework (STAF)                              */
3 /* (C) Copyright IBM Corp. 2001                                              */
4 /*                                                                           */
5 /* This software is licensed under the Eclipse Public License (EPL) V1.0.    */
6 /*****************************************************************************/
7 
8 #ifndef STAF_EventSemInlImpl
9 #define STAF_EventSemInlImpl
10 
11 #include "STAF.h"
12 #include "STAFEventSem.h"
13 #include "STAFRefPtr.h"
14 #include "STAFString.h"
15 #include "STAFException.h"
16 
STAFEventSem(const char * name)17 STAF_INLINE STAFEventSem::STAFEventSem(const char *name) : fEventImpl(0)
18 {
19     unsigned int osRC = 0;
20     STAFRC_t rc = STAFEventSemConstruct(&fEventImpl, name, &osRC);
21 
22     STAFException::checkRC(rc, "STAFEventSemConstruct", osRC);
23 }
24 
25 
post()26 STAF_INLINE void STAFEventSem::post()
27 {
28     unsigned int osRC = 0;
29     STAFRC_t rc = STAFEventSemPost(fEventImpl, &osRC);
30 
31     STAFException::checkRC(rc, "STAFEventSemPost", osRC);
32 }
33 
34 
reset()35 STAF_INLINE void STAFEventSem::reset()
36 {
37     unsigned int osRC = 0;
38     STAFRC_t rc = STAFEventSemReset(fEventImpl, &osRC);
39 
40     STAFException::checkRC(rc, "STAFEventSemReset", osRC);
41 }
42 
43 
wait(unsigned int timeout)44 STAF_INLINE STAFRC_t STAFEventSem::wait(unsigned int timeout)
45 {
46     unsigned int osRC = 0;
47     STAFRC_t rc = STAFEventSemWait(fEventImpl, timeout, &osRC);
48 
49     if ((rc != kSTAFOk) && (rc != kSTAFTimeout))
50         STAFException::checkRC(rc, "STAFEventSemWait", osRC);
51 
52     return rc;
53 }
54 
55 
query()56 STAF_INLINE STAFEventSemState_t STAFEventSem::query()
57 {
58     unsigned int osRC = 0;
59     STAFEventSemState_t state = kSTAFEventSemReset;
60     STAFRC_t rc = STAFEventSemQuery(fEventImpl, &state, &osRC);
61 
62     STAFException::checkRC(rc, "STAFEventSemQuery: %d", osRC);
63 
64     return state;
65 }
66 
67 
~STAFEventSem()68 STAF_INLINE STAFEventSem::~STAFEventSem()
69 {
70   unsigned int osRC = 0;
71   STAFRC_t rc = STAFEventSemDestruct(&fEventImpl, &osRC);
72 }
73 
74 #endif
75