mKnownObjects is redundant as we already store accessbles in a map in bridge-impl.
Removig the data and update the path calculation logic.wq
Change-Id: I40899257ab293f2afe0bcdf9c3a7791dbc4e88bc
virtual void RemoveAccessible(uint32_t actorId) = 0;
/**
- * @brief Gets the accessible object associated with given actor from the brige.
+ * @brief Gets the accessible object associated with given actor from the bridge.
*/
virtual std::shared_ptr<Accessible> GetAccessible(Actor actor) const = 0;
+ /**
+ * @brief Gets the accessible object associated with given path from the bridge.
+ */
+ virtual std::shared_ptr<Accessible> GetAccessible(const std::string& path) const = 0;
+
/**
* @brief Returns true if GetChildren should include hidden objects; false otherwise.
*/
protected:
struct Data
{
- std::unordered_set<const Accessible*> mKnownObjects;
std::string mBusName;
Bridge* mBridge = nullptr;
Actor mHighlightActor;
class DALI_ADAPTOR_API Accessible
{
public:
- virtual ~Accessible() noexcept;
+ virtual ~Accessible() noexcept = default;
/**
* @brief Gets accessibility name.
std::string DumpTree(DumpDetailLevel detailLevel);
protected:
- Accessible();
+ Accessible() = default;
Accessible(const Accessible&) = delete;
Accessible(Accessible&&) = delete;
Accessible& operator=(const Accessible&) = delete;
} // anonymous namespace
-Accessible::Accessible()
-{
-}
-
-Accessible::~Accessible() noexcept
-{
- auto handle = mBridgeData.lock();
- if(handle)
- {
- handle->mKnownObjects.erase(this);
- }
-}
-
std::shared_ptr<Bridge::Data> Accessible::GetBridgeData() const
{
auto handle = mBridgeData.lock();
handle->mBridge->RegisterOnBridge(this);
}
}
- std::ostringstream tmp;
- tmp << this;
- return {handle ? handle->mBusName : "", tmp.str()};
+ std::string path;
+ auto actor = GetInternalActor();
+ if(actor)
+ {
+ uint32_t actorId = actor.GetProperty<int>(Dali::Actor::Property::ID);
+ path = std::to_string(actorId);
+ }
+ return {handle ? handle->mBusName : "", path};
}
void Bridge::RegisterOnBridge(const Accessible* object)
if(!object->mBridgeData.lock())
{
assert(mData);
- mData->mKnownObjects.insert(object);
object->mBridgeData = mData;
}
}
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
return &mApplication;
}
- void* accessible;
- std::istringstream tmp{path};
- if(!(tmp >> accessible))
- {
- throw std::domain_error{"invalid path '" + path + "'"};
- }
-
- auto it = mData->mKnownObjects.find(static_cast<Accessible*>(accessible));
- if(it == mData->mKnownObjects.end() || (!mApplication.mShouldIncludeHidden && (*it)->IsHidden()))
+ auto accessible = GetAccessible(path);
+ if(!accessible || (!mApplication.mShouldIncludeHidden && accessible->IsHidden()))
{
throw std::domain_error{"unknown object '" + path + "'"};
}
- return static_cast<Accessible*>(accessible);
+ return accessible.get();
}
Accessible* BridgeBase::Find(const Address& ptr) const
return iter != mAccessibles.end() ? iter->second : nullptr;
}
+ /**
+ * @copydoc Dali::Accessibility::Bridge::GetAccessible()
+ */
+ std::shared_ptr<Accessible> GetAccessible(const std::string& path) const override
+ {
+ try
+ {
+ uint32_t actorId = static_cast<uint32_t>(std::stoi(path));
+ auto iter = mAccessibles.find(actorId);
+ return iter != mAccessibles.end() ? iter->second : nullptr;
+ }
+ catch(const std::invalid_argument& ia)
+ {
+ // Handle invalid argument (e.g., non-numeric characters in the string)
+ throw std::runtime_error("Invalid argument: string is not a valid integer");
+ }
+ catch(const std::out_of_range& oor)
+ {
+ // Handle out of range (e.g., the number is too large for uint32_t)
+ throw std::runtime_error("Out of range: number is too large for uint32_t");
+ }
+ }
+
/**
* @copydoc Dali::Accessibility::Bridge::ShouldIncludeHidden()
*/
void SwitchBridge()
{
//If DBusClient is not ready, don't remove initialize timer.
- if (mInitializeTimer && mInitializeTimer.IsRunning()) return;
+ if(mInitializeTimer && mInitializeTimer.IsRunning()) return;
bool isScreenReaderEnabled = mIsScreenReaderEnabled && !mIsScreenReaderSuppressed;
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
namespace Dali
{
-Accessibility::Accessible::Accessible()
-{
-}
-
-Accessibility::Accessible::~Accessible() noexcept
-{
-}
-
std::vector<Accessibility::Accessible*> Accessibility::Accessible::GetChildren()
{
return {};
std::shared_ptr<Accessible> GetAccessible(Actor actor) const override
{
return nullptr;
- };
+ }
+
+ std::shared_ptr<Accessible> GetAccessible(const std::string& path) const override
+ {
+ return nullptr;
+ }
bool ShouldIncludeHidden() const override
{