Merge "Ensure BaseHandle class move noexcept (core public-api)" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / events / key-event.cpp
index 27e3ed4..9693649 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <dali/public-api/events/key-event.h>
 
 // INTERNAL INCLUDES
-#include <dali/devel-api/events/key-event-devel.h>
-#include <dali/devel-api/common/map-wrapper.h>
+#include <dali/internal/event/events/key-event-impl.h>
 
 namespace Dali
 {
-
-namespace
-{
-const unsigned int MODIFIER_SHIFT = 0x1;
-const unsigned int MODIFIER_CTRL  = 0x2;
-const unsigned int MODIFIER_ALT   = 0x4;
-const int KEY_INVALID_CODE = -1;
-
-struct KeyEventImpl
+KeyEvent::KeyEvent()
+: BaseHandle()
 {
-  KeyEventImpl()
-    :deviceName("")
-  {
-  };
-
-  KeyEventImpl& operator=( const KeyEventImpl& rhs )
-  {
-    if( this != &rhs )
-    {
-      deviceName = rhs.deviceName;
-    }
-
-    return *this;
-  }
+}
 
-  KeyEventImpl( const KeyEventImpl& rhs )
-  {
-    deviceName =  rhs.deviceName;
-  }
+KeyEvent::KeyEvent(const KeyEvent& rhs) = default;
 
-  std::string deviceName;
-};
+KeyEvent::KeyEvent(KeyEvent&& rhs) noexcept = default;
 
-typedef std::map< const KeyEvent*, KeyEventImpl*> KeyEventMap;
-typedef KeyEventMap::const_iterator KeyEventMapIter;
+KeyEvent::~KeyEvent() = default;
 
+KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) = default;
 
-KeyEventMap keyEventImplMap;
+KeyEvent& KeyEvent::operator=(KeyEvent&& rhs) noexcept = default;
 
+bool KeyEvent::IsShiftModifier() const
+{
+  return GetImplementation(*this).IsShiftModifier();
 }
 
-KeyEvent::KeyEvent()
-: keyPressedName(""),
-  keyPressed(""),
-  keyCode(KEY_INVALID_CODE),
-  keyModifier(0),
-  time(0),
-  state(KeyEvent::Down)
+bool KeyEvent::IsCtrlModifier() const
 {
-  KeyEventImpl* impl = new KeyEventImpl;
-  keyEventImplMap[this] = impl;
+  return GetImplementation(*this).IsCtrlModifier();
 }
 
-KeyEvent::KeyEvent(const std::string& keyName, const std::string& keyString, int keyCode, int keyModifier,unsigned long timeStamp, const State& keyState)
-: keyPressedName(keyName),
-  keyPressed(keyString),
-  keyCode(keyCode),
-  keyModifier(keyModifier),
-  time(timeStamp),
-  state(keyState)
+bool KeyEvent::IsAltModifier() const
 {
-  keyEventImplMap[this] = new KeyEventImpl;
+  return GetImplementation(*this).IsAltModifier();
 }
 
-KeyEvent::KeyEvent( const KeyEvent& rhs )
-: keyPressedName( rhs.keyPressedName ),
-  keyPressed( rhs.keyPressed ),
-  keyCode( rhs.keyCode ),
-  keyModifier( rhs.keyModifier ),
-  time( rhs.time ),
-  state( rhs.state )
+const std::string& KeyEvent::GetCompose() const
 {
-  keyEventImplMap[this] = new KeyEventImpl( *keyEventImplMap[ &rhs ] );
+  return GetImplementation(*this).GetCompose();
 }
 
-KeyEvent& KeyEvent::operator=( const KeyEvent& rhs )
+const std::string& KeyEvent::GetDeviceName() const
 {
-  if( this != &rhs )
-  {
-    keyPressedName = rhs.keyPressedName;
-    keyPressed = rhs.keyPressed;
-    keyCode = rhs.keyCode;
-    keyModifier = rhs.keyModifier;
-    time = rhs.time;
-    state = rhs.state;
-
-    *keyEventImplMap[ this ] = *keyEventImplMap[ &rhs ];
-  }
-
-  return *this;
+  return GetImplementation(*this).GetDeviceName();
 }
 
-KeyEvent::~KeyEvent()
+Device::Class::Type KeyEvent::GetDeviceClass() const
 {
-  delete keyEventImplMap[this];
-  keyEventImplMap.erase( this );
+  return GetImplementation(*this).GetDeviceClass();
 }
 
-bool KeyEvent::IsShiftModifier() const
+Device::Subclass::Type KeyEvent::GetDeviceSubclass() const
 {
-  if ((MODIFIER_SHIFT & keyModifier) == MODIFIER_SHIFT)
-  {
-    return true;
-  }
-
-  return false;
+  return GetImplementation(*this).GetDeviceSubclass();
 }
 
-bool KeyEvent::IsCtrlModifier() const
+const std::string& KeyEvent::GetKeyName() const
 {
-  if ((MODIFIER_CTRL & keyModifier) == MODIFIER_CTRL)
-  {
-    return true;
-  }
-
-  return false;
+  return GetImplementation(*this).GetKeyName();
 }
 
-bool KeyEvent::IsAltModifier() const
+const std::string& KeyEvent::GetKeyString() const
 {
-  if ((MODIFIER_ALT & keyModifier) == MODIFIER_ALT)
-  {
-    return true;
-  }
-
-  return false;
+  return GetImplementation(*this).GetKeyString();
 }
 
-std::string DevelKeyEvent::GetDeviceName( const KeyEvent& keyEvent )
+const std::string& KeyEvent::GetLogicalKey() const
 {
-  KeyEventMapIter search = keyEventImplMap.find( &keyEvent );
+  return GetImplementation(*this).GetLogicalKey();
+}
 
-  if( search != keyEventImplMap.end())
-  {
-    return search->second->deviceName;
-  }
+int32_t KeyEvent::GetKeyCode() const
+{
+  return GetImplementation(*this).GetKeyCode();
+}
 
-  return std::string("");
+int32_t KeyEvent::GetKeyModifier() const
+{
+  return GetImplementation(*this).GetKeyModifier();
 }
 
-void DevelKeyEvent::SetDeviceName( KeyEvent& keyEvent, const std::string& deviceName )
+unsigned long KeyEvent::GetTime() const
 {
-  KeyEventMapIter search = keyEventImplMap.find( &keyEvent );
+  return GetImplementation(*this).GetTime();
+}
 
-  if( search != keyEventImplMap.end())
-  {
-    search->second->deviceName = deviceName;
-  }
+KeyEvent::State KeyEvent::GetState() const
+{
+  return GetImplementation(*this).GetState();
 }
 
+KeyEvent::KeyEvent(Internal::KeyEvent* internal)
+: BaseHandle(internal)
+{
+}
 
 } // namespace Dali