28 #include "../parser/iceparser.h"
63 return this->readOnly;
67 std::string instanceName, std::string configPath,
70 :
Application(executableName, executablePath, packageName), instanceName(instanceName)
71 , configPath(configPath)
81 instanceName(instanceName),
82 configPath(configPath),
83 status(ApplicationStatus::Unknown),
87 statusWriteBlock(false),
99 return this->instanceName;
104 this->instanceName = newName;
109 return this->configPath;
114 this->configPath = configPath;
119 std::filesystem::path scenariosFolder(scenario->getPackage()->getScenarioPath());
120 std::filesystem::path scenarioFolder = scenariosFolder / scenario->getName();
121 std::filesystem::path scenarioCfgFolder = scenarioFolder /
"config";
123 std::filesystem::path configPath = scenarioCfgFolder;
125 if (!this->instanceName.empty() && this->instanceName != R
"("")" && this->instanceName != R"(" ")")
127 configPath = configPath / (this->getName() + "." + this->getInstanceName() +
".cfg");
131 configPath = configPath / (this->getName() +
".cfg");;
134 if (configPath != this->configPath)
136 std::filesystem::remove(std::filesystem::path(this->configPath));
138 this->configPath = configPath.string();
168 if (!properties->isPropertySet(name))
170 properties->defineOptionalProperty(name, std::string(
"::NOT_DEFINED::"),
"Custom Property");
172 properties->getProperties()->setProperty(name,
value);
177 if (!properties->isPropertySet(name))
179 properties->defineOptionalProperty(name, std::string(
"::NOT_DEFINED::"),
"Custom Property");
181 properties->getProperties()->setProperty(name,
value);
187 parser.saveCfg(shared_from_this());
197 if (!std::filesystem::is_symlink(configPath))
203 std::filesystem::remove(configPath);
213 auto target_path = other.configPath.lexically_relative(configPath.parent_path());
214 std::filesystem::create_symlink(target_path, configPath);
222 std::filesystem::copy_file(other.configPath, configPath,
223 std::filesystem::copy_options::overwrite_existing);
229 if (std::filesystem::exists(this->configPath))
231 std::filesystem::remove(this->configPath);
237 if (!std::filesystem::exists(configPath))
239 ARMARX_WARNING_S <<
"Cannot find ApplicationInstance Config at:" << configPath;
244 setProperties(
parser.mergeXmlAndCfg(shared_from_this(), firstLoad));
248 this->readOnly = std::filesystem::is_symlink(configPath);
255 ofs.open(configPath.c_str(), std::ofstream::out | std::ofstream::app);
256 ARMARX_DEBUG << configPath <<
" is writeable: " << ofs.is_open();
258 return ofs.is_open();
263 return statusWriteBlock;
268 statusWriteBlock = blocked;
278 return nodeName.empty() && scenario ? scenario->getNodeName() : nodeName;
283 this->nodeName = nodeName;