1 #include "ObjectMapper.h"
3 ObjectMapper::ObjectMapper() : mObjectMap{}, mObjCounter{0} {}
5 ObjectMapper::~ObjectMapper() {}
7 ObjectMapper *ObjectMapper::getInstance()
9 static ObjectMapper *mInstance = new ObjectMapper();
13 std::string ObjectMapper::addElement(std::unique_ptr<UiObject> object)
16 std::string key = std::to_string(mObjCounter);
17 mObjectMap[key] = std::move(object);
21 UiObject *ObjectMapper::getElement(const std::string &key)
23 unsigned long long keyCnt = (unsigned long long)std::stoi(key); // this key is a result of calling std:to_string(mObjCounter)
24 if (keyCnt <= 0 || keyCnt > mObjCounter) return nullptr;
25 if (mObjectMap.count(key)) {
26 UiObject *obj = mObjectMap[key].get();
27 const_cast<const UiObject *>(obj)->refresh();