home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / baclsema.zip / OSSEM.H < prev    next >
C/C++ Source or Header  |  1994-06-23  |  2KB  |  75 lines

  1. // ****************************************************************************
  2. //
  3. // Module:  ossem.h
  4. // Author:  Dick Lam
  5. //
  6. // Purpose: C++ class header file for osSemaphore
  7. //
  8. // Notes:  This is a base class.  It contains general implementation methods
  9. //         for semaphores used in signalling between processes and threads.
  10. //
  11. // ****************************************************************************
  12.  
  13. #ifndef MODULE_osSemaphoreh
  14. #define MODULE_osSemaphoreh
  15.  
  16. #include "ipcsem.h"
  17.  
  18. // class declaration
  19. class osSemaphore {
  20.  
  21. public:
  22.  
  23.    // constructor and destructor
  24.    osSemaphore(ipcSemaphore *interface, const char *name, ipcSemaphoreType type,
  25.                ipcSemaphoreOp operation);
  26.    virtual ~osSemaphore();
  27.  
  28.    // methods for getting semaphore parameters [name, semaphore id, type
  29.    // of semaphore (mutex or event) and whether this is the owner (creator)
  30.    // of the semaphore]
  31.    char *Name() const;
  32.    unsigned long ID() const;
  33.    ipcSemaphoreType Type() const;
  34.    int Owner() const;
  35.  
  36.    // mutex semaphore methods
  37.    void CreateMutex();
  38.    void OpenMutex();
  39.    void RequestMutex();
  40.    void ReleaseMutex();
  41.    unsigned long QueryMutex();
  42.    void CloseMutex();
  43.  
  44.    // event semaphore methods
  45.    void CreateEvent();
  46.    void OpenEvent();
  47.    void PostEvent();
  48.    void ResetEvent();
  49.    void WaitEvent();
  50.    unsigned long QueryEvent();
  51.    void CloseEvent();
  52.  
  53. protected:
  54.  
  55.    ipcSemaphore *myInterface;    // pointer to the interface instance
  56.    char *myName;                 // semaphore name, id and type
  57.    unsigned long myID;
  58.    ipcSemaphoreType myType;
  59.    int isOwner;                  // flag indicating whether this is owner
  60.  
  61. private:
  62.  
  63.    // private copy constructor and operator= (define these and make them
  64.    // public to enable copy and assignment of the class)
  65.    osSemaphore(const osSemaphore&);
  66.    osSemaphore& operator=(const osSemaphore&);
  67.  
  68. };
  69.  
  70. #endif
  71.  
  72. // ****************************************************************************
  73.  
  74. // end of ossem.h
  75.