28 #include "../parser/iceparser.h"
63 return this->readOnly;
67 :
Application(executableName, executablePath, packageName), instanceName(instanceName)
68 , configPath(configPath)
76 instanceName(instanceName),
77 configPath(configPath),
78 status(ApplicationStatus::Unknown),
82 statusWriteBlock(false),
84 iceAutoRestart(iceAutoRestart)
95 return this->instanceName;
100 this->instanceName = newName;
105 return this->configPath;
110 this->configPath = configPath;
115 std::filesystem::path scenariosFolder(scenario->getPackage()->getScenarioPath());
116 std::filesystem::path scenarioFolder = scenariosFolder / scenario->getName();
117 std::filesystem::path scenarioCfgFolder = scenarioFolder /
"config";
119 std::filesystem::path configPath = scenarioCfgFolder;
121 if (!this->instanceName.empty() && this->instanceName != R
"("")" && this->instanceName != R"(" ")")
123 configPath = configPath / (this->getName() + "." + this->getInstanceName() +
".cfg");
127 configPath = configPath / (this->getName() +
".cfg");;
130 if (configPath != this->configPath)
132 std::filesystem::remove(std::filesystem::path(this->configPath));
134 this->configPath = configPath.string();
164 if (!properties->isPropertySet(name))
166 properties->defineOptionalProperty(name, std::string(
"::NOT_DEFINED::"),
"Custom Property");
168 properties->getProperties()->setProperty(name,
value);
173 if (!properties->isPropertySet(name))
175 properties->defineOptionalProperty(name, std::string(
"::NOT_DEFINED::"),
"Custom Property");
177 properties->getProperties()->setProperty(name,
value);
183 parser.saveCfg(shared_from_this());
193 if (!std::filesystem::is_symlink(configPath))
199 std::filesystem::remove(configPath);
209 auto target_path = other.configPath.lexically_relative(configPath.parent_path());
210 std::filesystem::create_symlink(target_path, configPath);
218 std::filesystem::copy_file(other.configPath, configPath,
219 std::filesystem::copy_options::overwrite_existing);
225 if (std::filesystem::exists(this->configPath))
227 std::filesystem::remove(this->configPath);
233 if (!std::filesystem::exists(configPath))
235 ARMARX_WARNING_S <<
"Cannot find ApplicationInstance Config at:" << configPath;
240 setProperties(
parser.mergeXmlAndCfg(shared_from_this(), firstLoad));
244 this->readOnly = std::filesystem::is_symlink(configPath);
251 ofs.open(configPath.c_str(), std::ofstream::out | std::ofstream::app);
252 ARMARX_DEBUG << configPath <<
" is writeable: " << ofs.is_open();
254 return ofs.is_open();
259 return statusWriteBlock;
264 statusWriteBlock = blocked;
274 return nodeName.empty() && scenario ? scenario->getNodeName() : nodeName;
279 this->nodeName = nodeName;
294 return iceAutoRestart;
299 this->iceAutoRestart =
enabled;