Support for the macOS platform
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / macos / trigger-event.h
1 #pragma once
2
3 /*
4  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/signals/callback.h>
22
23 // INTERNAL INCLUDES
24 #include <dali/public-api/dali-adaptor-common.h>
25 #include <dali/integration-api/adaptor-framework/trigger-event-interface.h>
26
27 #include <memory>
28
29 namespace Dali::Internal::Adaptor
30 {
31
32 class TriggerEvent : public TriggerEventInterface
33 {
34 public:
35
36   /**
37    * Constructor
38    * Creates an event file descriptor and starts a GSource which reads from the file
39    * descriptor when there is data.
40    *
41    * @param[in] callback The callback to call
42    * @param[in] options Trigger event options.
43    * @note The ownership of callback is taken by this class.
44    */
45   TriggerEvent( CallbackBase* callback, TriggerEventInterface::Options options );
46
47   /**
48    * Triggers the event.
49    *
50    * This can be called from one thread in order to wake up another thread.
51    */
52   void Trigger() override;
53
54   struct Impl;
55
56 private:
57
58   /**
59    * @brief Called when our event file descriptor has been written to.
60    * @param[in] eventBitMask bit mask of events that occured on the file descriptor
61    */
62   void Triggered();
63
64   std::unique_ptr<CallbackBase> mCallback;
65   std::unique_ptr<Impl> mImpl;
66 };
67
68 } // namespace Dali::Internal::Adaptor