[dali_2.3.28] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / internal / haptics / common / feedback-player-impl.h
1 #ifndef DALI_INTERNAL_FEEDBACK_PLAYER_H
2 #define DALI_INTERNAL_FEEDBACK_PLAYER_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/object/base-object.h>
23 #include <string>
24
25 // INTERNAL INCLUDES
26 #include <dali/devel-api/adaptor-framework/feedback-player.h>
27 #include <dali/internal/haptics/common/feedback-plugin-proxy.h>
28
29 namespace Dali
30 {
31 namespace Internal
32 {
33 namespace Adaptor
34 {
35 class FeedbackPluginProxy;
36
37 /**
38  * Plays haptic effects.
39  */
40 class FeedbackPlayer : public Dali::BaseObject
41 {
42 public:
43   /**
44    * Create a FeedbackPlayer.
45    * This should only be called once by the Adaptor class.
46    * @return A newly created FeedbackPlayer.
47    */
48   static Dali::FeedbackPlayer New();
49
50   /**
51    * Retrieve a handle to the FeedbackPlayer. This creates an instance if none has been created.
52    * @return A handle to the FeedbackPlayer.
53    */
54   static Dali::FeedbackPlayer Get();
55
56   /**
57    * @copydoc Dali::FeedbackPlayer::PlayMonotone()
58    */
59   void PlayMonotone(unsigned int duration);
60
61   /**
62    * @copydoc Dali::FeedbackPlayer::PlayFile()
63    */
64   void PlayFile(const std::string& filePath);
65
66   /**
67    * @copydoc Dali::FeedbackPlayer::Stop()
68    */
69   void Stop();
70
71   /**
72    * @copydoc Dali::FeedbackPlayer::PlaySound()
73    */
74   int PlaySound(const std::string& fileName);
75
76   /**
77    * @copydoc Dali::FeedbackPlayer::StopSound()
78    */
79   void StopSound(int handle);
80
81   /**
82    * @copydoc Dali::FeedbackPlayer::PlayFeedbackPattern()
83    */
84   void PlayFeedbackPattern(int type, int pattern);
85
86   /**
87    * @copydoc Dali::FeedbackPlayer::LoadFile()
88    */
89   bool LoadFile(const std::string& filename, std::string& data);
90
91 private:
92   /**
93    * Private Constructor; see also FeedbackPlayer::New()
94    */
95   FeedbackPlayer();
96
97   /**
98    * Virtual Destructor
99    */
100   ~FeedbackPlayer() override;
101
102   // Undefined
103   FeedbackPlayer(const FeedbackPlayer&);
104
105   // Undefined
106   FeedbackPlayer& operator=(FeedbackPlayer&);
107
108 private:
109   FeedbackPluginProxy mPlugin;
110 };
111
112 } // namespace Adaptor
113
114 } // namespace Internal
115
116 // Helpers for public-api forwarding methods
117
118 inline Internal::Adaptor::FeedbackPlayer& GetImplementation(Dali::FeedbackPlayer& player)
119 {
120   DALI_ASSERT_ALWAYS(player && "FeedbackPlayer handle is empty");
121
122   BaseObject& handle = player.GetBaseObject();
123
124   return static_cast<Internal::Adaptor::FeedbackPlayer&>(handle);
125 }
126
127 inline const Internal::Adaptor::FeedbackPlayer& GetImplementation(const Dali::FeedbackPlayer& player)
128 {
129   DALI_ASSERT_ALWAYS(player && "FeedbackPlayer handle is empty");
130
131   const BaseObject& handle = player.GetBaseObject();
132
133   return static_cast<const Internal::Adaptor::FeedbackPlayer&>(handle);
134 }
135
136 } // namespace Dali
137
138 #endif // DALI_INTERNAL_FEEDBACK_PLAYER_H