12std::shared_ptr<T>& ot::IconManager::getOrCreate(
const QString& _subPath, std::map<QString, std::shared_ptr<T>>& _dataMap, std::shared_ptr<T>& _default) {
13 std::lock_guard<std::mutex> lock(this->m_mutex);
16 std::optional<std::shared_ptr<T>*> existing = this->getWhileLocked<T>(_subPath, _dataMap);
17 if (existing.has_value()) {
18 if (existing.value()) {
19 return *existing.value();
24 QString path = this->findFullPath(_subPath);
26 OT_LOG_E(
"Icon \"" + _subPath.toStdString() +
"\" not found");
31 std::shared_ptr<T> newShared(
new T(path));
32 auto result = _dataMap.insert_or_assign(_subPath, newShared);
33 return result.first->second;
37std::optional<std::shared_ptr<T>*> ot::IconManager::get(
const QString& _subPath, std::map<QString, std::shared_ptr<T>>& _dataMap) {
38 std::lock_guard<std::mutex> lock(this->m_mutex);
39 return this->getWhileLocked<T>(_subPath, _dataMap);
43std::optional<std::shared_ptr<T>*> ot::IconManager::getWhileLocked(
const QString& _subPath, std::map<QString, std::shared_ptr<T>>& _dataMap) {
45 const auto& it = _dataMap.find(_subPath);
46 if (it != _dataMap.end()) {
#define OT_LOG_E(___text)
Log a error message according to the service logger configuration.
Definition Logger.h:186
int result
Definition dllmain.cpp:82