Ignore:
Timestamp:
12/15/22 15:56:11 (17 months ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Event object creation is moved into a factory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/hu/varadiistvan/scpl/io/_win32/EventFailable.h

    r6 r28  
    3333#include "../Failable.h"
    3434
     35#include "EventFactory.h"
     36
     37#include <memory>
     38
    3539//------------------------------------------------------------------------------
    3640
     
    5155class EventFailable : public Failable
    5256{
     57protected:
     58    /**
     59     * The event factory for this object.
     60     */
     61    std::unique_ptr<EventFactory> eventFactory;
     62
     63protected:
     64    /**
     65     * Construct the object with the given event factory.
     66     */
     67    EventFailable(std::unique_ptr<EventFactory> eventFactory);
     68
     69    /**
     70     * Create an event for this object using the event factory.
     71     */
     72    HANDLE createEvent();
     73
     74    /**
     75     * Set the event represented by the given handle using the event factory.
     76     */
     77    bool setEvent(HANDLE handle);
     78
     79    /**
     80     * Set the event represented by the given handle using the event factory.
     81     */
     82    bool resetEvent(HANDLE handle);
     83
     84    /**
     85     * Destroy the event represented by the given handle using the event factory.
     86     */
     87    void destroyEvent(HANDLE handle);
     88
    5389    friend class Event;
    5490};
     91
     92//------------------------------------------------------------------------------
     93// Inline definitions
     94//------------------------------------------------------------------------------
     95
     96inline EventFailable::EventFailable(std::unique_ptr<EventFactory> eventFactory) :
     97    eventFactory(std::move(eventFactory))
     98{
     99}
     100
     101//------------------------------------------------------------------------------
     102
     103inline HANDLE EventFailable::createEvent()
     104{
     105    return eventFactory->createEvent();
     106}
     107
     108//------------------------------------------------------------------------------
     109
     110inline bool EventFailable::setEvent(HANDLE handle)
     111{
     112    return eventFactory->setEvent(handle);
     113}
     114
     115//------------------------------------------------------------------------------
     116
     117inline bool EventFailable::resetEvent(HANDLE handle)
     118{
     119    return eventFactory->resetEvent(handle);
     120}
     121
     122//------------------------------------------------------------------------------
     123
     124inline void EventFailable::destroyEvent(HANDLE handle)
     125{
     126    eventFactory->destroyEvent(handle);
     127}
    55128
    56129//------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.