Application.cpp
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#include "Application.h"
27
28#include <filesystem>
29
30#include <Ice/Properties.h>
31
32#include <SimoxUtility/algorithm/string/string_tools.h>
33
35
36using namespace ScenarioManager;
37using namespace armarx;
38
39std::string
40prettify(const std::string& executableName)
41{
42 //reduce Run from the name
43 using simox::alg::ends_with;
44
45 if (ends_with(executableName, "Run"))
46 {
47 return simox::alg::replace_last(executableName, "Run", "");
48 }
49
50 if (ends_with(executableName, "_run"))
51 {
52 return simox::alg::replace_last(executableName, "_run", "");
53 }
54
55 return executableName;
56}
57
59 std::string executablePath,
60 std::string packageName) :
61 name(prettify(executableName)),
62 executableName(executableName),
63 executablePath(executablePath),
64 packageName(packageName),
65 found(false),
67{
69
71 armarx::IceProperties* cfgInternal = static_cast<armarx::IceProperties*>(cfgProperties.get());
72 cfgInternal->setInheritanceSolver(nullptr);
73 properties->setProperties(cfgProperties);
74}
75
77 name(application.name),
78 executableName(application.executableName),
79 executablePath(application.executablePath),
80 packageName(application.packageName),
81 found(application.found),
83{
84 Ice::PropertiesPtr cfgProperties =
85 IceProperties::create(application.getProperties()->getProperties()->clone());
86 armarx::IceProperties* cfgInternal = static_cast<armarx::IceProperties*>(cfgProperties.get());
87 cfgInternal->setInheritanceSolver(nullptr);
88 properties->setProperties(cfgProperties);
89}
90
91std::string
93{
94 return this->name;
95}
96
97std::string
99{
100 return this->executablePath;
101}
102
103std::string
105{
106 return packageName;
107}
108
114
115void
117 PropertyDefinitionsPtr properties) //oder Ice::StringSeq und create-Methode
118{
119 armarx::IceProperties* cfgInternal =
120 static_cast<armarx::IceProperties*>(properties->getProperties().get());
121 cfgInternal->setInheritanceSolver(nullptr);
122
123 this->properties = properties;
124 this->properties->setPrefix("");
125 this->properties->setDescription(name + " properties");
126}
127
128bool
130{
131 return std::filesystem::exists(executablePath / executableName);
132}
133
134void
139
140bool
142{
143 if (defaultMap.count(name) == 0)
144 {
145 return false;
146 }
147 if (enabledMap.count(name) == 0)
148 {
149 return false;
150 }
151 return enabledMap[name];
152}
153
154void
156{
157 if (defaultMap.count(name) == 0)
158 {
159 return;
160 }
161 enabledMap[name] = enabled;
162}
163
164bool
166{
167 if (defaultMap.count(name) == 0)
168 {
169 return false;
170 }
171 return defaultMap[name];
172}
173
174void
175Data_Structure::Application::setIsDefaultProperty(std::string name, bool defaultValue)
176{
177 defaultMap[name] = defaultValue;
178}
179
181{
182 std::string
184 {
185 return executableName;
186 }
187
188 std::string
190 {
191 return executablePath / executableName;
192 }
193
194} // namespace ScenarioManager::Data_Structure
Class containing data about an application Provides methods to get and set the date contained in the ...
Definition Application.h:47
void setProperties(armarx::PropertyDefinitionsPtr properties)
Sets the properties of this application.
void setDefaultPropertyEnabled(std::string name, bool enabled)
armarx::PropertyDefinitionsPtr properties
Definition Application.h:57
Application(std::string name, std::string executablePath, std::string packageName)
Constructor that sets the name and the path to the executable of the application.
void setIsDefaultProperty(std::string name, bool defaultValue)
armarx::PropertyDefinitionsPtr getProperties()
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)
::IceInternal::Handle<::Ice::Properties > PropertiesPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
bool ends_with(const std::string &haystack, const std::string &needle)
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
std::string prettify(const std::string &executableName)