Add post processor
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-sound-player.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <dali/public-api/object/base-object.h>
18 #include <dali/devel-api/common/singleton-service.h>
19 #include <dali/devel-api/adaptor-framework/sound-player.h>
20
21 using namespace Dali;
22
23 namespace Dali
24 {
25 class Adaptor;
26
27 namespace Internal
28 {
29 namespace Adaptor
30 {
31
32
33 class SoundPlayer : public Dali::BaseObject
34 {
35 public:
36   static Dali::SoundPlayer New()
37   {
38     Dali::SoundPlayer player = Dali::SoundPlayer( new SoundPlayer() );
39     return player;
40   }
41
42   static Dali::SoundPlayer Get()
43   {
44     Dali::SoundPlayer player;
45
46     Dali::SingletonService service( Dali::SingletonService::Get() );
47     if ( service )
48     {
49       // Check whether the singleton is already created
50       Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::SoundPlayer ) );
51       if ( handle )
52       {
53         // If so, downcast the handle
54         player = Dali::SoundPlayer( dynamic_cast< SoundPlayer* >( handle.GetObjectPtr() ) );
55       }
56       else
57       {
58         player = Dali::SoundPlayer( New() );
59         service.Register( typeid( player ), player );
60       }
61     }
62     return player;
63   }
64
65   int PlaySound(const std::string fileName)
66   {
67     return 0;
68   }
69
70   void Stop(int handle)
71   {
72   }
73
74 private:
75   SoundPlayer()
76   {
77   }
78
79   virtual ~SoundPlayer()
80   {
81   }
82
83   SoundPlayer(const SoundPlayer&);
84   SoundPlayer& operator=(SoundPlayer&);
85 };
86
87 } // Adaptor namespace
88 } // Internal namespace
89
90 inline Internal::Adaptor::SoundPlayer& GetImplementation(Dali::SoundPlayer& player)
91 {
92   DALI_ASSERT_ALWAYS( player && "SoundPlayer handle is empty" );
93   BaseObject& handle = player.GetBaseObject();
94   return static_cast<Internal::Adaptor::SoundPlayer&>(handle);
95 }
96
97 inline const Internal::Adaptor::SoundPlayer& GetImplementation(const Dali::SoundPlayer& player)
98 {
99   DALI_ASSERT_ALWAYS( player && "SoundPlayer handle is empty" );
100   const BaseObject& handle = player.GetBaseObject();
101   return static_cast<const Internal::Adaptor::SoundPlayer&>(handle);
102 }
103
104 SoundPlayer SoundPlayer::Get()
105 {
106   return Internal::Adaptor::SoundPlayer::Get();
107 }
108
109 SoundPlayer::SoundPlayer()
110 {
111 }
112
113 SoundPlayer::SoundPlayer(Internal::Adaptor::SoundPlayer*player)
114 :BaseHandle(player)
115 {
116 }
117
118 SoundPlayer::~SoundPlayer()
119 {
120 }
121
122 int SoundPlayer::PlaySound(const std::string fileName)
123 {
124   return GetImplementation(*this).PlaySound(fileName);
125 }
126
127 } // Dali