27 #include "../parser/XMLScenarioParser.h"
31 #include <Ice/Properties.h>
38 const PackagePtr &package,
const std::string& globalConfigName,
const std::string& subfolder)
39 : name(name), creationTime(creationTime),
40 lastChangedTime(lastChangedTime),
41 globalConfigName(globalConfigName),
43 nodeName(
"NodeMain"), package(package),
45 globalConfig(new
armarx::PropertyDefinitionContainer(name))
51 globalConfig->setProperties(cfgProperties);
52 globalConfig->setPrefix(
"");
53 globalConfig->setDescription(
"Global Config from Scenario " + name);
63 name = std::move(scenarioName);
68 return this->creationTime;
73 return this->lastChangedTime;
78 return globalConfigName;
88 std::string scenarioPath = package.lock()->getScenarioPath();
90 if (subfolder.empty())
92 scenarioPath.append(
"/").append(name).append(
"/").append(name).append(
".scx");
96 scenarioPath.append(
"/").append(subfolder).append(
"/").append(name).append(
"/").append(name).append(
".scx");
104 std::string scenarioPath = package.lock()->getScenarioPath();
106 scenarioPath.append(
"/").append(name);
114 ofs.open(getPath().c_str(), std::ofstream::out | std::ofstream::app);
115 ARMARX_DEBUG << getPath() <<
" is writeable: " << ofs.is_open();
117 return ofs.is_open();
120 if ((
s.permissions() & std::filesystem::perms::owner_write) != std::filesystem::perms::none)
129 return package.lock();
135 for (
const auto& app : *applications)
137 if (!app->getEnabled())
197 this->lastChangedTime = std::move(time);
202 globalConfigName = std::move(configName);
212 for (
auto app : *applications)
214 if (app->getName() == appName)
225 applications->push_back(application);
230 for (
auto iter = applications->begin(); iter != applications->end(); ++iter)
232 if (*iter == application)
234 (*iter)->deleteConfig();
235 applications->erase(iter);
244 parser.saveScenario(shared_from_this(), saveApplications);
254 if (!std::filesystem::is_symlink(getGlobalConfigPath()))
256 ARMARX_WARNING <<
"Make local called on non-linked global scenario config";
260 std::filesystem::remove(getGlobalConfigPath());
263 this->reloadGlobalConf();
268 return std::filesystem::is_symlink(getGlobalConfigPath());
273 for (
const auto& it : *applications)
281 if (isGlobalConfigFileexistent())
283 globalConfig->getProperties()->load(getGlobalConfigPath());
294 std::filesystem::path scenarioPath;
295 if (subfolder.empty())
297 scenarioPath = std::filesystem::path(package.lock()->getScenarioPath().append(
"/").append(name).append(
"/"));
301 scenarioPath = std::filesystem::path(package.lock()->getScenarioPath().append(
"/").append(subfolder +
"/").append(name).append(
"/"));
304 scenarioPath = scenarioPath / std::filesystem::path(globalConfigName.empty() ?
"./config/global.cfg" : globalConfigName);
305 return scenarioPath.string();
311 ofs.open(getGlobalConfigPath().c_str(), std::ofstream::out | std::ofstream::app);
312 ARMARX_DEBUG << getGlobalConfigPath() <<
" is writeable: " << ofs.is_open();
314 return ofs.is_open();
319 return std::filesystem::exists(std::filesystem::path(getGlobalConfigPath()));
324 for (
const auto& app : *applications)
326 if (app->getStatusWriteBlock())
336 for (
const auto& app : *applications)
338 app->setStatusWriteBlock(state);
344 std::vector<std::string> result;
345 for (
const auto& app : *applications)
347 result.push_back(app->getEffectiveNodeName());
354 for (
const auto& app : *applications)
357 if (!app->getFound())