66 return this->readOnly;
70 std::string executablePath,
71 std::string instanceName,
72 std::string configPath,
73 std::string packageName,
77 Application(executableName, executablePath, packageName),
78 instanceName(instanceName),
79 configPath(configPath),
84 statusWriteBlock(false),
90 std::string instanceName,
91 std::string configPath,
96 instanceName(instanceName),
97 configPath(configPath),
102 statusWriteBlock(false),
116 return this->instanceName;
122 this->instanceName = newName;
128 return this->configPath;
134 this->configPath = configPath;
140 std::filesystem::path scenariosFolder(scenario->getPackage()->getScenarioPath());
141 std::filesystem::path scenarioFolder = scenariosFolder / scenario->getName();
142 std::filesystem::path scenarioCfgFolder = scenarioFolder /
"config";
144 std::filesystem::path configPath = scenarioCfgFolder;
146 if (!this->instanceName.empty() && this->instanceName != R
"("")" &&
147 this->instanceName != R"(" ")")
153 configPath = configPath / (this->
getName() +
".cfg");
157 if (configPath != this->configPath)
159 std::filesystem::remove(std::filesystem::path(this->configPath));
161 this->configPath = configPath.string();
173 bool result = status != this->status;
176 this->status = status;
198 properties->defineOptionalProperty(name, std::string(
"::NOT_DEFINED::"),
"Custom Property");
200 properties->getProperties()->setProperty(name, value);
208 properties->defineOptionalProperty(name, std::string(
"::NOT_DEFINED::"),
"Custom Property");
210 properties->getProperties()->setProperty(name, value);
217 parser.saveCfg(shared_from_this());
228 if (!std::filesystem::is_symlink(configPath))
234 std::filesystem::remove(configPath);
245 auto target_path = other.configPath.lexically_relative(configPath.parent_path());
246 std::filesystem::create_symlink(target_path, configPath);
255 std::filesystem::copy_file(
256 other.configPath, configPath, std::filesystem::copy_options::overwrite_existing);
263 if (std::filesystem::exists(this->configPath))
265 std::filesystem::remove(this->configPath);
272 if (!std::filesystem::exists(configPath))
274 ARMARX_WARNING_S <<
"Cannot find ApplicationInstance Config at:" << configPath;
279 setProperties(parser.mergeXmlAndCfg(shared_from_this(), firstLoad));
283 this->readOnly = std::filesystem::is_symlink(configPath);
291 ofs.open(configPath.c_str(), std::ofstream::out | std::ofstream::app);
292 ARMARX_DEBUG << configPath <<
" is writeable: " << ofs.is_open();
294 return ofs.is_open();
300 return statusWriteBlock;
306 statusWriteBlock = blocked;
318 return nodeName.empty() && scenario ? scenario->getNodeName() : nodeName;
324 this->nodeName = nodeName;
336 this->enabled = enabled;
ApplicationInstance(std::string executableName, std::string executablePath, std::string instanceName, std::string configPath, std::string packageName, ScenarioPtr scenarioName, std::string node, bool enabled)
Constructor that sets the base data of this ApplicationInstance.
void setInstanceName(std::string newName)
Sets the name of this ApplicationInstance.
std::string getInstanceName()
void setEnabled(bool enabled)
void setPid(int pid)
Sets the pid of this ApplicationInstance.
void resetConfigPath()
resetConfigPath.
void addProperty(std::string name, std::string value)
Adds a new property with the specified name and value to this ApplicationInstance.
void setConfigPath(std::string configPath)
Sets the config path of this ApplicationInstance.
std::string getConfigDomain() const
std::string getConfigPath()
std::string getEffectiveNodeName() const
ScenarioPtr getScenario()
void modifyProperty(std::string name, std::string value)
Changes the value of the specified property.
void setConfigDomain(const std::string &value)
std::string getStatus()
Returns the status.
void makeLocal()
Make a local copy of this instance if it is linked and nothing otherwise.
void save()
Saves the IceProperties to the configPath.
bool getStatusWriteBlock()
void copyFrom(ApplicationInstance &other)
copyFrom Copy the other instance configuration to this one.
void linkFrom(ApplicationInstance &other)
linkFrom Link this instance configuration from the other instance.
void load(bool firstLoad=false)
Loades the IceProperties from the configPath Firstload determins if properties that equal their defau...
void setNodeName(std::string nodeName)
bool setStatus(const std::string &status)
Sets the status of this ApplicationInstance.
std::string getNodeName() const
void setStatusWriteBlock(bool blocked)
void setProperties(armarx::PropertyDefinitionsPtr properties)
Sets the properties of this application.
armarx::PropertyDefinitionsPtr properties
Application(std::string name, std::string executablePath, std::string packageName)
Constructor that sets the name and the path to the executable of the application.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
#define ARMARX_WARNING_S
The logging level for unexpected behaviour, but not a serious problem.
std::shared_ptr< Scenario > ScenarioPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
static const std::string Stopped
static const std::string Mixed
static const std::string Missing
static const std::string Unknown
static const std::string Inactive
static const std::string Waiting
static const std::string Running