Scenario.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package ArmarXCore::core
19  * @author Dennis Weigelt
20  * @date 2016
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 
26 #pragma once
27 
28 #include <memory>
29 #include <memory>
30 #include <vector>
31 #include <string>
32 
34 {
35  class Scenario;
36  using ScenarioPtr = std::shared_ptr<Scenario>;
37  using ScenarioWPtr = std::weak_ptr<Scenario>;
38  using ScenarioVectorPtr = std::shared_ptr<std::vector<ScenarioPtr>>;
39 }
40 
41 #include "ApplicationInstance.h"
42 #include "Package.h"
43 
44 
46 {
47  class Package;
48  using PackagePtr = std::shared_ptr<Package>;
49  typedef std::map<std::string, std::string> IceEnvMap;
50 
51  /**
52  * @class Scenario
53  * @ingroup data_structure
54  * @brief Class containing data about a scenario and its applications.
55  * Provides methods to get and set the data contained in the scenario. It is only representative
56  * and doesn't actually manage the scenario.
57  */
58  class Scenario : public std::enable_shared_from_this<Scenario>
59  {
60  private:
61  std::string name;
62  std::string creationTime;
63  std::string lastChangedTime;
64  std::string globalConfigName;
65  std::string subfolder;
66  std::string nodeName;
67  std::weak_ptr<Package> package;
68  ApplicationInstanceVectorPtr applications;
69 
70  armarx::PropertyDefinitionsPtr globalConfig;
71 
72  public:
73  /** Constructor that sets some base information about the scenario.
74  * @param name name of the scenario
75  * @param creationTime when this scenario was first created
76  * @param lastChangedTime when this scenario was last changed. Should usually be the same as the time of
77  * creation, except when creating an exact copy of another Scenario.
78  * @param path path to the root of this scenario
79  */
80  Scenario(const std::string& name, const std::string& creationTime, const std::string& lastChangedTime, const PackagePtr& package,
81  const std::string& globalConfigName = "./config/global.cfg", const std::string& subfolder = "");
82 
83  /*
84  * @return name of this scenario
85  */
86  std::string getName();
87 
88  /*
89  * Sets the name of this scenario.
90  * @param name new name
91  */
92  void setName(std::string name);
93 
94  /**SCENARIO_H
95  * @return time this scenario was created.
96  */
97  std::string getCreationTime();
98 
99  /**
100  * @return time this scenario was last changed
101  */
102  std::string getLastChangedTime();
103 
104  std::string getGlobalConfigName();
105  void setGlobalConfigName(std::string name);
106 
107  /**
108  * @return the path to the scx file
109  */
110  std::string getPath();
111  /**
112  * @return path to the root of this scenario
113  */
114  std::string getFolder();
115 
117 
119 
120  /**
121  * @return status of this scenario
122  */
123  std::string getStatus();
124 
125  bool getStatusWriteBlock();
126  void setStatusWriteBlock(bool state);
127 
128  /**
129  * @returns subfolder
130  **/
131  std::string getSubfolder();
132 
133  /**
134  * Sets the last-changed-time to now
135  */
136  void setLastChangedTime(std::string time);
137 
138  /**
139  * @return all applications this scenario contains
140  */
142 
143  ApplicationInstancePtr getApplicationByName(const std::string& name);
144 
145  /**
146  * Adds an Application to this scenario.
147  * @param application Application to be added to this scenario
148  */
149  void addApplication(const ApplicationInstancePtr& application);
150 
151  /**
152  * Removes an Application from this scenario
153  * @param application application to be removed
154  */
155  void removeApplication(const ApplicationInstancePtr& application);
156 
157  void save(bool saveApplications = true);
158 
159  void makeLocalGlobalConfig();
160 
161  bool isReadOnly();
162 
163  bool allApplicationsFound();
164 
165  void reloadAppInstances();
166  void reloadGlobalConf();
167 
169 
170  std::string getGlobalConfigPath();
171  bool isGlobalConfigWritable();
173 
174  std::vector<std::string> getAllDeploymendNodeNames();
175 
176  std::string getNodeName() const;
177  void setNodeName(const std::string& value);
178  };
179 }
ScenarioManager::Data_Structure::Scenario::getName
std::string getName()
Definition: Scenario.cpp:56
ScenarioManager::Data_Structure::Scenario::getGlobalConfigPath
std::string getGlobalConfigPath()
Definition: Scenario.cpp:292
ScenarioManager::Data_Structure::ApplicationInstancePtr
std::shared_ptr< ApplicationInstance > ApplicationInstancePtr
Definition: ApplicationInstance.h:33
ScenarioManager::Data_Structure::Scenario::getGlobalConfig
armarx::PropertyDefinitionsPtr getGlobalConfig()
Definition: Scenario.cpp:287
ScenarioManager::Data_Structure::Scenario::addApplication
void addApplication(const ApplicationInstancePtr &application)
Adds an Application to this scenario.
Definition: Scenario.cpp:223
ScenarioManager::Data_Structure::ScenarioPtr
std::shared_ptr< Scenario > ScenarioPtr
Definition: Scenario.h:36
ScenarioManager::Data_Structure::ApplicationInstanceVectorPtr
std::shared_ptr< std::vector< ApplicationInstancePtr > > ApplicationInstanceVectorPtr
Definition: ApplicationInstance.h:35
ScenarioManager::Data_Structure::Scenario::setNodeName
void setNodeName(const std::string &value)
Definition: Scenario.cpp:371
ScenarioManager::Data_Structure::Scenario::setName
void setName(std::string name)
Definition: Scenario.cpp:61
ScenarioManager::Data_Structure::IceEnvMap
std::map< std::string, std::string > IceEnvMap
Definition: Scenario.h:49
ScenarioManager::Data_Structure::Scenario::setLastChangedTime
void setLastChangedTime(std::string time)
Sets the last-changed-time to now.
Definition: Scenario.cpp:195
ScenarioManager::Data_Structure::Scenario::getPath
std::string getPath()
Definition: Scenario.cpp:86
ScenarioManager::Data_Structure::Scenario::makeLocalGlobalConfig
void makeLocalGlobalConfig()
Definition: Scenario.cpp:247
ScenarioManager::Data_Structure::Scenario::reloadGlobalConf
void reloadGlobalConf()
Definition: Scenario.cpp:279
ScenarioManager::Data_Structure::Scenario::getStatus
std::string getStatus()
Definition: Scenario.cpp:132
ScenarioManager::Data_Structure::Scenario::allApplicationsFound
bool allApplicationsFound()
Definition: Scenario.cpp:352
ScenarioManager::Data_Structure::Scenario::save
void save(bool saveApplications=true)
Definition: Scenario.cpp:241
ScenarioManager::Data_Structure::Scenario::getApplications
ApplicationInstanceVectorPtr getApplications()
Definition: Scenario.cpp:205
Package.h
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
ScenarioManager::Data_Structure::Scenario::getFolder
std::string getFolder()
Definition: Scenario.cpp:102
ScenarioManager::Data_Structure::Scenario::reloadAppInstances
void reloadAppInstances()
Definition: Scenario.cpp:271
ScenarioManager::Data_Structure::PackagePtr
std::shared_ptr< Package > PackagePtr
Definition: Package.h:121
ScenarioManager::Data_Structure::Scenario::getNodeName
std::string getNodeName() const
Definition: Scenario.cpp:366
ScenarioManager::Data_Structure::Scenario::getSubfolder
std::string getSubfolder()
Definition: Scenario.cpp:81
ScenarioManager::Data_Structure::Scenario::removeApplication
void removeApplication(const ApplicationInstancePtr &application)
Removes an Application from this scenario.
Definition: Scenario.cpp:228
ScenarioManager::Data_Structure
Definition: Application.cpp:166
ScenarioManager::Data_Structure::Scenario::getCreationTime
std::string getCreationTime()
SCENARIO_H.
Definition: Scenario.cpp:66
ScenarioManager::Data_Structure::Scenario::getGlobalConfigName
std::string getGlobalConfigName()
Definition: Scenario.cpp:76
ScenarioManager::Data_Structure::Scenario::getStatusWriteBlock
bool getStatusWriteBlock()
Definition: Scenario.cpp:322
ScenarioManager::Data_Structure::Scenario::isGlobalConfigFileexistent
bool isGlobalConfigFileexistent()
Definition: Scenario.cpp:317
ApplicationInstance.h
ScenarioManager::Data_Structure::Scenario::getAllDeploymendNodeNames
std::vector< std::string > getAllDeploymendNodeNames()
Definition: Scenario.cpp:342
ScenarioManager::Data_Structure::Scenario::isScenarioFileWriteable
bool isScenarioFileWriteable()
Definition: Scenario.cpp:111
ScenarioManager::Data_Structure::Scenario::isReadOnly
bool isReadOnly()
Definition: Scenario.cpp:266
ScenarioManager::Data_Structure::Scenario::getPackage
PackagePtr getPackage()
Definition: Scenario.cpp:127
ScenarioManager::Data_Structure::ScenarioWPtr
std::weak_ptr< Scenario > ScenarioWPtr
Definition: Scenario.h:37
IceUtil::Handle< class PropertyDefinitionContainer >
ScenarioManager::Data_Structure::Scenario::isGlobalConfigWritable
bool isGlobalConfigWritable()
Definition: Scenario.cpp:308
ScenarioManager::Data_Structure::Scenario::getLastChangedTime
std::string getLastChangedTime()
Definition: Scenario.cpp:71
ScenarioManager::Data_Structure::Scenario::setGlobalConfigName
void setGlobalConfigName(std::string name)
Definition: Scenario.cpp:200
ScenarioManager::Data_Structure::Scenario::setStatusWriteBlock
void setStatusWriteBlock(bool state)
Definition: Scenario.cpp:334
ScenarioManager::Data_Structure::Scenario::Scenario
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.
Definition: Scenario.cpp:37
ScenarioManager::Data_Structure::Scenario
Class containing data about a scenario and its applications. Provides methods to get and set the data...
Definition: Scenario.h:58
ScenarioManager::Data_Structure::Scenario::getApplicationByName
ApplicationInstancePtr getApplicationByName(const std::string &name)
Definition: Scenario.cpp:210
ScenarioManager::Data_Structure::ScenarioVectorPtr
std::shared_ptr< std::vector< ScenarioPtr > > ScenarioVectorPtr
Definition: Scenario.h:38