7f81a32b08bbe6ebcd3ab44e3138febc68880d88
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / bridge / bridge-value.cpp
1 /*
2  * Copyright (c) 2021 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
18 // CLASS HEADER
19 #include <dali/internal/accessibility/bridge/bridge-value.h>
20
21 // EXTERNAL INCLUDES
22 #include <iostream>
23
24 using namespace Dali::Accessibility;
25
26 BridgeValue::BridgeValue()
27 {
28 }
29
30 void BridgeValue::RegisterInterfaces()
31 {
32   DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceValue};
33   AddGetSetPropertyToInterface(desc, "CurrentValue", &BridgeValue::GetCurrentValue, &BridgeValue::SetCurrentValue);
34   AddGetPropertyToInterface(desc, "MaximumValue", &BridgeValue::GetMaximumValue);
35   AddGetPropertyToInterface(desc, "MinimumIncrement", &BridgeValue::GetMinimumIncrement);
36   AddGetPropertyToInterface(desc, "MinimumValue", &BridgeValue::GetMinimumValue);
37   mDbusServer.addInterface("/", desc, true);
38 }
39
40 Value* BridgeValue::FindSelf() const
41 {
42   auto self = BridgeBase::FindSelf();
43   assert(self);
44   auto valueInterface = dynamic_cast<Value*>(self);
45   if(!valueInterface)
46   {
47     throw std::domain_error{"object " + self->GetAddress().ToString() + " doesn't have Value interface"};
48   }
49   return valueInterface;
50 }
51
52 double BridgeValue::GetCurrentValue()
53 {
54   return FindSelf()->GetCurrent();
55 }
56
57 void BridgeValue::SetCurrentValue(double newValue)
58 {
59   FindSelf()->SetCurrent(newValue);
60 }
61
62 double BridgeValue::GetMaximumValue()
63 {
64   return FindSelf()->GetMaximum();
65 }
66
67 double BridgeValue::GetMinimumIncrement()
68 {
69   return FindSelf()->GetMinimumIncrement();
70 }
71
72 double BridgeValue::GetMinimumValue()
73 {
74   return FindSelf()->GetMinimum();
75 }