31#include <Ice/Properties.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);
141 return ofs.is_open();
143 std::filesystem::file_status s = std::filesystem::status(std::filesystem::path(
getPath()));
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);
302 ARMARX_WARNING <<
"Make local called on non-linked global scenario config";
321 for (
const auto& it : *applications)
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();
374 return ofs.is_open();
386 for (
const auto& app : *applications)
388 if (app->getStatusWriteBlock())
399 for (
const auto& app : *applications)
401 app->setStatusWriteBlock(state);
405std::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())
bool allApplicationsFound()
std::string getSubfolder()
std::string getLastChangedTime()
ApplicationInstancePtr getApplicationByName(const std::string &name)
Scenario(const std::string &name, const std::string &creationTime, const std::string &lastChangedTime, const PackagePtr &package, const std::string &globalConfigName="./config/global.cfg", const std::string &subfolder="")
Constructor that sets some base information about the scenario.
void removeApplication(const ApplicationInstancePtr &application)
Removes an Application from this scenario.
void setNodeName(const std::string &value)
bool isGlobalConfigFileexistent()
std::string getGlobalConfigName()
bool isGlobalConfigWritable()
bool isScenarioFileWriteable()
void makeLocalGlobalConfig()
std::vector< std::string > getAllDeploymendNodeNames()
std::string getGlobalConfigPath()
void setStatusWriteBlock(bool state)
void setLastChangedTime(std::string time)
Sets the last-changed-time to now.
bool getStatusWriteBlock()
void save(bool saveApplications=true)
void addApplication(const ApplicationInstancePtr &application)
Adds an Application to this scenario.
void setName(std::string name)
void reloadAppInstances()
ApplicationInstanceVectorPtr getApplications()
void setGlobalConfigName(std::string name)
std::string getNodeName() const
std::string getCreationTime()
SCENARIO_H.
armarx::PropertyDefinitionsPtr getGlobalConfig()
This class provides different methods to parse and save scenario data in XML-Files.
IceProperties stores ice properties and resolves property inheritance.
virtual void setInheritanceSolver(const InheritanceSolverPtr &inheritanceSolver)
Sets an inheritance solver in case of testing or using a non-default solver.
static Ice::PropertiesPtr create(const Ice::PropertiesPtr &iceProperties=nullptr)
#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.
::IceInternal::Handle<::Ice::Properties > PropertiesPtr
std::shared_ptr< Package > PackagePtr
std::shared_ptr< ApplicationInstance > ApplicationInstancePtr
std::shared_ptr< std::vector< ApplicationInstancePtr > > ApplicationInstanceVectorPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
static const std::string Stopped
static const std::string Mixed
static const std::string Unknown
static const std::string Inactive
static const std::string Waiting
static const std::string Running