31 #include <Ice/Properties.h>
36 #include "../parser/XMLScenarioParser.h"
41 const std::string& creationTime,
42 const std::string& lastChangedTime,
44 const std::string& globalConfigName,
45 const std::string& subfolder) :
47 creationTime(creationTime),
48 lastChangedTime(lastChangedTime),
49 globalConfigName(globalConfigName),
54 globalConfig(new
armarx::PropertyDefinitionContainer(name))
60 globalConfig->setProperties(cfgProperties);
61 globalConfig->setPrefix(
"");
62 globalConfig->setDescription(
"Global Config from Scenario " + name);
74 name = std::move(scenarioName);
80 return this->creationTime;
86 return this->lastChangedTime;
92 return globalConfigName;
104 std::string scenarioPath = package.lock()->getScenarioPath();
106 if (subfolder.empty())
108 scenarioPath.append(
"/").append(name).append(
"/").append(name).append(
".scx");
112 scenarioPath.append(
"/")
127 std::string scenarioPath = package.lock()->getScenarioPath();
129 scenarioPath.append(
"/").append(name);
138 ofs.open(getPath().c_str(), std::ofstream::out | std::ofstream::app);
139 ARMARX_DEBUG << getPath() <<
" is writeable: " << ofs.is_open();
141 return ofs.is_open();
144 if ((
s.permissions() & std::filesystem::perms::owner_write) != std::filesystem::perms::none)
154 return package.lock();
161 for (
const auto& app : *applications)
163 if (!app->getEnabled())
235 this->lastChangedTime = std::move(time);
241 globalConfigName = std::move(configName);
253 for (
auto app : *applications)
255 if (app->getName() == appName)
267 applications->push_back(application);
274 for (
auto iter = applications->begin(); iter != applications->end(); ++iter)
276 if (*iter == application)
278 (*iter)->deleteConfig();
279 applications->erase(iter);
289 parser.saveScenario(shared_from_this(), saveApplications);
300 if (!std::filesystem::is_symlink(getGlobalConfigPath()))
302 ARMARX_WARNING <<
"Make local called on non-linked global scenario config";
306 std::filesystem::remove(getGlobalConfigPath());
309 this->reloadGlobalConf();
315 return std::filesystem::is_symlink(getGlobalConfigPath());
321 for (
const auto& it : *applications)
330 if (isGlobalConfigFileexistent())
332 globalConfig->getProperties()->load(getGlobalConfigPath());
345 std::filesystem::path scenarioPath;
346 if (subfolder.empty())
348 scenarioPath = std::filesystem::path(
349 package.lock()->getScenarioPath().append(
"/").append(name).append(
"/"));
353 scenarioPath = std::filesystem::path(package.lock()
356 .append(subfolder +
"/")
363 std::filesystem::path(globalConfigName.empty() ?
"./config/global.cfg" : globalConfigName);
364 return scenarioPath.string();
371 ofs.open(getGlobalConfigPath().c_str(), std::ofstream::out | std::ofstream::app);
372 ARMARX_DEBUG << getGlobalConfigPath() <<
" is writeable: " << ofs.is_open();
374 return ofs.is_open();
380 return std::filesystem::exists(std::filesystem::path(getGlobalConfigPath()));
386 for (
const auto& app : *applications)
388 if (app->getStatusWriteBlock())
399 for (
const auto& app : *applications)
401 app->setStatusWriteBlock(state);
405 std::vector<std::string>
408 std::vector<std::string> result;
409 for (
const auto& app : *applications)
411 result.push_back(app->getEffectiveNodeName());
419 for (
const auto& app : *applications)
422 if (!app->getFound())