Merge "Enable atspi" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / trigger-event.h
1 #ifndef DALI_INTERNAL_TRIGGER_EVENT_H
2 #define DALI_INTERNAL_TRIGGER_EVENT_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/signals/callback.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/integration-api/adaptor-framework/trigger-event-interface.h>
26 #include <dali/internal/system/common/file-descriptor-monitor.h>
27 #include <dali/public-api/dali-adaptor-common.h>
28
29 namespace Dali
30 {
31 namespace Internal
32 {
33 namespace Adaptor
34 {
35 /**
36  * The TriggerEvent class is used to send events between threads.  For example, this can be used
37  * to wake up one thread from another thread.
38  *
39  * Typically, these should be created in the application thread.
40  *
41  * The observer will be informed whenever the event is triggered.
42  *
43  * The implementation of TriggerEvent uses an event file descriptor.
44  */
45 class TriggerEvent : public TriggerEventInterface
46 {
47 public:
48   /**
49    * Constructor
50    * Creates an event file descriptor and starts a GSource which reads from the file
51    * descriptor when there is data.
52    *
53    * @param[in] callback The callback to call
54    * @param[in] options Trigger event options.
55    * @note The ownership of callback is taken by this class.
56    */
57   TriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options);
58
59   /**
60    * Destructor
61    */
62   ~TriggerEvent();
63
64 public:
65   /**
66    * Triggers the event.
67    *
68    * This can be called from one thread in order to wake up another thread.
69    */
70   void Trigger();
71
72 private:
73   /**
74    * @brief Called when our event file descriptor has been written to.
75    * @param[in] eventBitMask bit mask of events that occured on the file descriptor
76    * @param[in] fileDescriptor The file descriptor
77    */
78   void Triggered(FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor);
79
80 private:
81   struct Source;
82
83 private:
84   FileDescriptorMonitor*         mFileDescriptorMonitor;
85   CallbackBase*                  mCallback;
86   int                            mFileDescriptor;
87   TriggerEventInterface::Options mOptions;
88 };
89
90 } // namespace Adaptor
91
92 } // namespace Internal
93
94 } // namespace Dali
95
96 #endif // DALI_INTERNAL_TRIGGER_EVENT_H