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 <string>
30#include <vector>
31
33{
34 class Scenario;
35 using ScenarioPtr = std::shared_ptr<Scenario>;
36 using ScenarioWPtr = std::weak_ptr<Scenario>;
37 using ScenarioVectorPtr = std::shared_ptr<std::vector<ScenarioPtr>>;
38} // namespace ScenarioManager::Data_Structure
39
40#include "ApplicationInstance.h"
41#include "Package.h"
42
44{
45 class Package;
46 using PackagePtr = std::shared_ptr<Package>;
47 typedef std::map<std::string, std::string> IceEnvMap;
48
49 /**
50 * @class Scenario
51 * @ingroup data_structure
52 * @brief Class containing data about a scenario and its applications.
53 * Provides methods to get and set the data contained in the scenario. It is only representative
54 * and doesn't actually manage the scenario.
55 */
56 class Scenario : public std::enable_shared_from_this<Scenario>
57 {
58 private:
59 std::string name;
60 std::string creationTime;
61 std::string lastChangedTime;
62 std::string globalConfigName;
63 std::string subfolder;
64 std::string nodeName;
65 std::weak_ptr<Package> package;
67
69
70 public:
71 /** Constructor that sets some base information about the scenario.
72 * @param name name of the scenario
73 * @param creationTime when this scenario was first created
74 * @param lastChangedTime when this scenario was last changed. Should usually be the same as the time of
75 * creation, except when creating an exact copy of another Scenario.
76 * @param path path to the root of this scenario
77 */
78 Scenario(const std::string& name,
79 const std::string& creationTime,
80 const std::string& lastChangedTime,
81 const PackagePtr& package,
82 const std::string& globalConfigName = "./config/global.cfg",
83 const std::string& subfolder = "");
84
85 /*
86 * @return name of this scenario
87 */
88 std::string getName();
89
90 /*
91 * Sets the name of this scenario.
92 * @param name new name
93 */
94 void setName(std::string name);
95
96 /**SCENARIO_H
97 * @return time this scenario was created.
98 */
99 std::string getCreationTime();
100
101 /**
102 * @return time this scenario was last changed
103 */
104 std::string getLastChangedTime();
105
106 std::string getGlobalConfigName();
107 void setGlobalConfigName(std::string name);
108
109 /**
110 * @return the path to the scx file
111 */
112 std::string getPath();
113 /**
114 * @return path to the root of this scenario
115 */
116 std::string getFolder();
117
119
121
122 /**
123 * @return status of this scenario
124 */
125 std::string getStatus();
126
127 bool getStatusWriteBlock();
128 void setStatusWriteBlock(bool state);
129
130 /**
131 * @returns subfolder
132 **/
133 std::string getSubfolder();
134
135 /**
136 * Sets the last-changed-time to now
137 */
138 void setLastChangedTime(std::string time);
139
140 /**
141 * @return all applications this scenario contains
142 */
144
145 ApplicationInstancePtr getApplicationByName(const std::string& name);
146
147 /**
148 * Adds an Application to this scenario.
149 * @param application Application to be added to this scenario
150 */
151 void addApplication(const ApplicationInstancePtr& application);
152
153 /**
154 * Removes an Application from this scenario
155 * @param application application to be removed
156 */
157 void removeApplication(const ApplicationInstancePtr& application);
158
159 void save(bool saveApplications = true);
160
162
163 bool isReadOnly();
164
166
167 void reloadAppInstances();
168 void reloadGlobalConf();
169
171
172 std::string getGlobalConfigPath();
175
176 std::vector<std::string> getAllDeploymendNodeNames();
177
178 std::string getNodeName() const;
179 void setNodeName(const std::string& value);
180 };
181} // namespace ScenarioManager::Data_Structure
Class containing data about a scenario and its applications.
Definition Scenario.h:57
ApplicationInstancePtr getApplicationByName(const std::string &name)
Definition Scenario.cpp:251
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:40
void removeApplication(const ApplicationInstancePtr &application)
Removes an Application from this scenario.
Definition Scenario.cpp:271
void setNodeName(const std::string &value)
Definition Scenario.cpp:437
std::vector< std::string > getAllDeploymendNodeNames()
Definition Scenario.cpp:406
void setLastChangedTime(std::string time)
Sets the last-changed-time to now.
Definition Scenario.cpp:233
void save(bool saveApplications=true)
Definition Scenario.cpp:286
void addApplication(const ApplicationInstancePtr &application)
Adds an Application to this scenario.
Definition Scenario.cpp:265
ApplicationInstanceVectorPtr getApplications()
Definition Scenario.cpp:245
void setGlobalConfigName(std::string name)
Definition Scenario.cpp:239
std::string getCreationTime()
SCENARIO_H.
Definition Scenario.cpp:78
armarx::PropertyDefinitionsPtr getGlobalConfig()
Definition Scenario.cpp:337
std::shared_ptr< Scenario > ScenarioPtr
Definition Scenario.h:35
std::shared_ptr< std::vector< ScenarioPtr > > ScenarioVectorPtr
Definition Scenario.h:37
std::weak_ptr< Scenario > ScenarioWPtr
Definition Scenario.h:36
std::shared_ptr< Package > PackagePtr
Definition Package.h:122
std::shared_ptr< ApplicationInstance > ApplicationInstancePtr
std::shared_ptr< std::vector< ApplicationInstancePtr > > ApplicationInstanceVectorPtr
std::map< std::string, std::string > IceEnvMap
Definition Scenario.h:47
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.