Skip to content
Snippets Groups Projects
Commit 7d6df365 authored by fxk8y's avatar fxk8y :spider:
Browse files

ST: Add fancy name rendering stuff

parent 0c0d5cb4
No related branches found
No related tags found
No related merge requests found
......@@ -100,8 +100,17 @@ namespace SiliconTorch {
}
void Service::setIcon(const str& icon) {
if (!attrsLocked) {
this->icon = icon;
} else {
// TODO: report error somehow?
}
}
void Service::setName(const str& name) {
if (!attrsLocked) {
// TODO: length check!! (reason: NVS)
this->name = name;
} else {
// TODO: report error somehow?
......@@ -110,12 +119,22 @@ namespace SiliconTorch {
void Service::setNameSpace(const str& nameSpace) {
if (!attrsLocked) {
// TODO: length check!! (reason: NVS)
this->nameSpace = nameSpace;
} else {
// TODO: report error somehow?
}
}
void Service::setDisplayName(const str& displayName) {
if (!attrsLocked) {
this->displayName = displayName;
} else {
// TODO: report error somehow?
}
}
void Service::addWantedService(const str& name) {
if (!attrsLocked) {
......@@ -162,6 +181,10 @@ namespace SiliconTorch {
}
const str& Service::getIcon() const {
return icon;
}
const str& Service::getName() const {
return name;
}
......@@ -170,5 +193,23 @@ namespace SiliconTorch {
return nameSpace;
}
const str& Service::getDisplayName() const {
if (displayName.length() > 0) return displayName;
else return name;
}
str Service::getFancyName() const {
str out = getDisplayName();
if (icon.length() > 0) {
out += str("[");
out += icon;
out += str("]");
}
return out;
}
}
}
......@@ -48,8 +48,12 @@ namespace SiliconTorch {
// ╚════════════════════════════╝
const str& getIcon() const;
const str& getName() const;
const str& getNameSpace() const;
const str& getDisplayName() const;
str getFancyName() const; // <== Use this for logging!!
bool isEnabled() const;
void setEnabled(bool enabled);
......@@ -65,8 +69,10 @@ namespace SiliconTorch {
protected:
void setIcon(const str& icon);
void setName(const str& name);
void setNameSpace(const str& nameSpace);
void setDisplayName(const str& displayName);
// Service will be started after the wanted one (if wanted is disabled this limitation is waived) // TODO: (waived / raised / lowered?)
void addWantedService(const str& name);
......@@ -81,8 +87,10 @@ namespace SiliconTorch {
bool hasErrors = false; // Set if an error is detected. Prevents the service from being started
bool attrsLocked = false;
str icon = "";
str name = "";
str nameSpace = "";
str displayName = "";
std::set<std::string>* wantedNames = new std::set<std::string>();
std::set<std::string>* requiredNames = new std::set<std::string>();
......
......@@ -39,14 +39,14 @@ namespace SiliconTorch {
registrationLocked = true;
for (auto& [ignored, service] : serviceMap)
for (auto& [name, service] : serviceMap)
service->postInit();
auto sers = startAlgo();
ESP_LOGI(TAG, "===== Services starting order =====");
for (const auto& s : sers) ESP_LOGI(TAG, "Service: %s", s->getName().c_str());
for (const auto& s : sers) ESP_LOGI(TAG, "Service: %s", s->getFancyName().c_str());
ESP_LOGI(TAG, "=======================================");
......@@ -70,7 +70,7 @@ namespace SiliconTorch {
std::map<Service*, ServiceSet> services;
// prepare our data structures
for (const auto& [name, service] : serviceMap) {
for (const auto& [_, service] : serviceMap) {
if (service->isEnabled()) {
......@@ -103,11 +103,11 @@ namespace SiliconTorch {
for (const auto& [service, deps] : services) {
std::set<std::string> depsnames;
for (const auto& d : deps) depsnames.insert(d->getName());
for (const auto& d : deps) depsnames.insert(d->getFancyName());
std::string sdeps = SpiderLib::Util::join(depsnames, " ");
ESP_LOGI(TAG, "Service[ %s ] has deps{ %s }", service->getName().c_str(), sdeps.c_str());
ESP_LOGI(TAG, "Service[ %s ] has deps{ %s }", service->getFancyName().c_str(), sdeps.c_str());
}
ESP_LOGI(TAG, "=======================================");
......@@ -136,7 +136,7 @@ namespace SiliconTorch {
for (const auto& starting : startOrder)
for (auto& [ignored, deps] : services)
for (auto& [_, deps] : services)
deps.erase(starting);
......@@ -228,9 +228,9 @@ namespace SiliconTorch {
std::vector<Service*> services = getServicesInStartOrder();
for (const auto& service : services) {
u8 nameSize = service->getName().length();
u8 nameSize = service->getFancyName().length();
ESP_LOGI(TAG, "│ %s %s│ % 5d %s│%s%s%s│",
service->getName().c_str(),
service->getFancyName().c_str(),
strmul(" ", nameColSize - 2 - nameSize).c_str(),
1337, // service->getStartOrder(),
strmul(" ", startOrderColSize - 2 - 5).c_str(),
......@@ -291,7 +291,7 @@ namespace SiliconTorch {
serviceMap[s->getName()] = s;
ESP_LOGI(TAG, "Registered service[ %s ]", s->getName().c_str());
ESP_LOGI(TAG, "Registered service[ %s ]", s->getFancyName().c_str());
} else {
ESP_LOGW(TAG, "Service registration is locked");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment