diff --git a/applications/gui/src/main.cpp b/applications/gui/src/main.cpp index 64c65eb4e08df1713f37a2517fd2d2e4c3c93d96..5ebc552fa0ee0664c7a0b7898a723b90bf87f29c 100644 --- a/applications/gui/src/main.cpp +++ b/applications/gui/src/main.cpp @@ -30,7 +30,7 @@ int main(int argc, char **argv) { ftl::UUID peer = p->id(); auto cs = controller->getConfigurables(peer); for (auto c : cs) { - LOG(INFO) << "NET CONFIG: " << c; + //LOG(INFO) << "NET CONFIG: " << c; ftl::config::json_t *configuration = new ftl::config::json_t; *configuration = controller->get(peer, c); if (!configuration->empty()) { diff --git a/applications/reconstruct/src/main.cpp b/applications/reconstruct/src/main.cpp index 551a2dfe309bf8a5a29c17cc4856acb48f70f09c..0dd0a51912e10157a44ea26d793d8364dd60a441 100644 --- a/applications/reconstruct/src/main.cpp +++ b/applications/reconstruct/src/main.cpp @@ -241,7 +241,7 @@ static void run(ftl::Configurable *root) { //ftl::voxhash::SceneRep *scene = ftl::create<ftl::voxhash::SceneRep>(root, "voxelhash"); ftl::rgbd::Streamer *stream = ftl::create<ftl::rgbd::Streamer>(root, "stream", net); ftl::rgbd::VirtualSource *virt = ftl::create<ftl::rgbd::VirtualSource>(root, "virtual"); - root->set("tags", nlohmann::json::array({ root->getID()+"/virtual" })); + //root->set("tags", nlohmann::json::array({ root->getID()+"/virtual" })); ftl::render::Triangular *splat = ftl::create<ftl::render::Triangular>(root, "renderer", &scene_B); ftl::rgbd::Group *group = new ftl::rgbd::Group; ftl::ILW *align = ftl::create<ftl::ILW>(root, "merge"); diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp index 4c813914ade72d57944a2493632e4f6b9ba7b727..0cd014cfb474ad041414a95c87694c25134fcb5d 100644 --- a/components/common/cpp/src/configuration.cpp +++ b/components/common/cpp/src/configuration.cpp @@ -229,6 +229,7 @@ void ftl::config::registerConfigurable(ftl::Configurable *cfg) { auto tags = cfg->get<vector<string>>("tags"); if (tags) { for (auto &t : *tags) { + //LOG(INFO) << "REGISTER TAG: " << t; tag_index[t].push_back(cfg); } } @@ -237,22 +238,45 @@ void ftl::config::registerConfigurable(ftl::Configurable *cfg) { json_t null_json; +/* To allow for custom tag format */ +static std::string preprocessURI(const std::string &uri) { + if (uri[0] == '[') { + size_t closing = uri.find_last_of(']'); + string tags = uri.substr(1, closing-1); + + // TODO: Allow for multiple tags + + const auto &cfgs = ftl::config::findByTag(tags); + + // FIXME: Check for more than one tag result + if (cfgs.size() > 0) { + //LOG(INFO) << "PREPROC URI " << cfgs[0]->getID() + uri.substr(closing+1); + return cfgs[0]->getID() + uri.substr(closing+1); + } else { + return uri; + } + } else { + return uri; + } +} + bool ftl::config::update(const std::string &puri, const json_t &value) { // Remove last component of URI string tail = ""; string head = ""; - size_t last_hash = puri.find_last_of('#'); + string uri = preprocessURI(puri); + size_t last_hash = uri.find_last_of('#'); if (last_hash != string::npos) { - size_t last = puri.find_last_of('/'); + size_t last = uri.find_last_of('/'); if (last != string::npos && last > last_hash) { - tail = puri.substr(last+1); - head = puri.substr(0, last); + tail = uri.substr(last+1); + head = uri.substr(0, last); } else { - tail = puri.substr(last_hash+1); - head = puri.substr(0, last_hash); + tail = uri.substr(last_hash+1); + head = uri.substr(0, last_hash); } } else { - LOG(WARNING) << "Expected a # in an update URI: " << puri; + LOG(WARNING) << "Expected a # in an update URI: " << uri; return false; } @@ -289,18 +313,19 @@ json_t &ftl::config::get(const std::string &puri) { // Remove last component of URI string tail = ""; string head = ""; - size_t last_hash = puri.find_last_of('#'); + string uri = preprocessURI(puri); + size_t last_hash = uri.find_last_of('#'); if (last_hash != string::npos) { - size_t last = puri.find_last_of('/'); + size_t last = uri.find_last_of('/'); if (last != string::npos && last > last_hash) { - tail = puri.substr(last+1); - head = puri.substr(0, last); + tail = uri.substr(last+1); + head = uri.substr(0, last); } else { - tail = puri.substr(last_hash+1); - head = puri.substr(0, last_hash); + tail = uri.substr(last_hash+1); + head = uri.substr(0, last_hash); } } else { - LOG(WARNING) << "Expected a # in an update URI: " << puri; + LOG(WARNING) << "Expected a # in an update URI: " << uri; return null_json; }