Skip to content

Commit 17418e9

Browse files
committed
Ware operations refinements
* adjusted ware duplication checks * made examples installation verbosity optional
1 parent f8ffcd6 commit 17418e9

File tree

11 files changed

+116
-77
lines changed

11 files changed

+116
-77
lines changed

CMake.in.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SET(OFBUILD_CUSTOM_CMAKE_VERSION "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.
2323
SET(OPENFLUID_VERSION_MAJOR 2)
2424
SET(OPENFLUID_VERSION_MINOR 2)
2525
SET(OPENFLUID_VERSION_PATCH 1)
26-
SET(OPENFLUID_VERSION_STATUS "beta5") # example: SET(OPENFLUID_VERSION_STATUS "rc1")
26+
SET(OPENFLUID_VERSION_STATUS "beta6") # example: SET(OPENFLUID_VERSION_STATUS "rc1")
2727

2828
SET(OPENFLUID_VERSION_FULL "${OPENFLUID_VERSION_MAJOR}.${OPENFLUID_VERSION_MINOR}.${OPENFLUID_VERSION_PATCH}")
2929

src/apps/openfluid-devstudio/MainWindow.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -776,15 +776,16 @@ void MainWindow::onDuplicateWareRequested()
776776
// TOIMPL reuse here the filter checking if ware name OK (not existing + only accepted symbols)
777777
if (OK && !NewWareName.isEmpty() && WareInfo.WareDirName != NewWareName.toStdString())
778778
{
779-
780-
mp_WidgetsCollection->duplicateWare(WarePath, NewWareName);
781-
QMessageBox::warning(QApplication::activeWindow(),
782-
tr("Ware duplication warning"),
783-
tr("If this ware is versioned, change now the remote repository "
784-
"(using 'git remote set-url origin <newurl>'). "
785-
"It is currently the same than original ware and would "
786-
"generate conflict or data loss risk."),
787-
QMessageBox::Close);
779+
if (mp_WidgetsCollection->duplicateWare(WarePath, NewWareName))
780+
{
781+
QMessageBox::warning(QApplication::activeWindow(),
782+
tr("Ware duplication warning"),
783+
tr("If this ware is versioned, change now the remote repository "
784+
"(using 'git remote set-url origin <newurl>'). "
785+
"It is currently the same than original ware and would "
786+
"generate conflict or data loss risk."),
787+
QMessageBox::Close);
788+
}
788789
}
789790
}
790791
}

src/apps/openfluid/DataTasks.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,26 +244,27 @@ int DataTasks::processCreateData() const
244244

245245

246246
bool DataTasks::processInstall(const std::string& OptStr,
247-
std::function<bool(const std::string&, const std::string&, const std::string&, bool)>
248-
InstallFunc,
249-
std::function<bool(const std::string&, const std::string&, bool)> InstallAllFunc,
250-
const std::string& ResPath,
251-
const std::string& InstPath,
252-
const bool Force) const
247+
std::function<bool(const std::string&, const std::string&, const std::string&, bool, bool)>
248+
InstallFunc,
249+
std::function<bool(const std::string&, const std::string&, bool, bool)> InstallAllFunc,
250+
const std::string& ResPath,
251+
const std::string& InstPath,
252+
const bool Force, const bool Verbose) const
253253
{
254+
std::cout << "Verbose:" << Verbose << std::endl;
254255
if (!OptStr.empty() && OptStr != "*")
255256
{
256-
auto Selection = openfluid::tools::split(OptStr,",");
257+
auto Selection = openfluid::tools::split(OptStr, ",");
257258
bool AllIsOK = true;
258259
for (const auto& S : Selection)
259260
{
260-
AllIsOK &= InstallFunc(S,ResPath,InstPath,Force);
261+
AllIsOK &= InstallFunc(S, ResPath, InstPath, Force, Verbose);
261262
}
262263
return AllIsOK;
263264
}
264265
else
265266
{
266-
return InstallAllFunc(ResPath,InstPath,Force);
267+
return InstallAllFunc(ResPath, InstPath, Force, Verbose);
267268
}
268269
}
269270

@@ -321,7 +322,7 @@ int DataTasks::processInstallExamples() const
321322

322323
if (!m_Cmd.isOptionActive("simulators") && !m_Cmd.isOptionActive("observers") && !m_Cmd.isOptionActive("projects"))
323324
{
324-
return (openfluid::base::ExamplesManager::installAll(ResPath,InstPath,Force) ?
325+
return (openfluid::base::ExamplesManager::installAll(ResPath,InstPath,Force,true) ?
325326
0 : error("problems occurred during installation"));
326327
}
327328

src/apps/openfluid/DataTasks.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ class DataTasks : public TasksBase
5656
int processCreateData() const;
5757

5858
bool processInstall(const std::string& OptStr,
59-
std::function<bool(const std::string&, const std::string&, const std::string&, bool)>
59+
std::function<bool(const std::string&, const std::string&, const std::string&, bool, bool)>
6060
InstallFunc,
61-
std::function<bool(const std::string&, const std::string&, bool)> InstallAllFunc,
61+
std::function<bool(const std::string&, const std::string&, bool, bool)> InstallAllFunc,
6262
const std::string& ResPath,
6363
const std::string& InstPath,
64-
const bool Force) const;
64+
const bool Force, const bool Verbose=true) const;
6565

6666
int processInstallExamples() const;
6767

src/apps/openfluid/WareTasks.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,24 @@ int WareTasks::processCreate() const
113113
if (m_Cmd.isOptionActive("from"))
114114
{
115115
const std::string ReferenceWarePath = m_Cmd.getOptionValue("from");
116-
if (!openfluid::tools::Path(ReferenceWarePath).exists())
116+
if (!openfluid::tools::Path(ReferenceWarePath).exists() || (
117+
!openfluid::tools::Path(ReferenceWarePath).fromThis(openfluid::config::WARESDEV_WAREMETA_FILE).exists() &&
118+
!openfluid::tools::Path(ReferenceWarePath).fromThis(openfluid::config::WARESDEV_WARESHUB_FILE).exists()))
117119
{
118120
return error("invalid reference ware path");
119121
}
120-
const std::string WarePath = openfluid::waresdev::WareSrcFactory::duplicateWare(ID, ParentPath,
121-
m_Cmd.getOptionValue("from"),
122-
m_Cmd.isOptionActive("accept-all"));
123-
postWareCreation(WarePath);
124-
return 0;
122+
try
123+
{
124+
const std::string WarePath = openfluid::waresdev::WareSrcFactory::duplicateWare(ID, ParentPath,
125+
m_Cmd.getOptionValue("from"),
126+
m_Cmd.isOptionActive("accept-all"));
127+
postWareCreation(WarePath);
128+
return 0;
129+
}
130+
catch(const std::exception& e)
131+
{
132+
return error(e.what());
133+
}
125134
}
126135

127136
if (!m_Cmd.isOptionActive("type"))

src/apps/openfluid/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ int main(int argc, char **argv)
197197
// ---
198198

199199
auto CreateWareCmd = openfluid::utils::CommandLineCommand("create-ware","Create ware sources");
200-
CreateWareCmd.addOptions({{"type","t","type of the ware sources to create (simulator|observer|builderext) (required)",
200+
CreateWareCmd.addOptions({{"type","t","type of the ware sources to create (simulator|observer|builderext) "
201+
"(required except when 'from' is used)",
201202
true},
202203
{"id","i","ID of the ware sources to create (required)",true},
203204
{"main-class","m","name to use for the main C++ class",true},

src/openfluid/base/ExamplesManager.cpp

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,20 @@ bool ExamplesManager::installDirectory(const std::string& FromPath, const std::s
104104

105105
if (!InstallTargetPathObj.isDirectory() || Force)
106106
{
107-
InstallTargetPathObj.makeDirectory();
107+
if (!InstallTargetPathObj.makeDirectory())
108+
{
109+
openfluid::base::log::debug("Example installation", "Unable to create " + InstallTargetPathObj.toGeneric());
110+
return false;
111+
}
108112

109113
return openfluid::tools::Filesystem::copyDirectory(openfluid::tools::Filesystem::joinPath({FromPath,DirName}),
110114
ToPath,true,true);
111115
}
112116

113117
openfluid::base::log::debug("Example installation", "Unable to create " + InstallTargetPathObj.toGeneric() +
114118
"dir because it already exists and force option is set to false");
115-
return false;
119+
120+
return !std::filesystem::is_empty(InstallTargetPathObj.stdPath());
116121
}
117122

118123

@@ -122,7 +127,7 @@ bool ExamplesManager::installDirectory(const std::string& FromPath, const std::s
122127

123128
bool ExamplesManager::installProject(const std::string& ProjectDir,
124129
const std::string& ResourcesPath, const std::string& InstallPath,
125-
const bool Force)
130+
const bool Force, const bool Verbose)
126131
{
127132
std::string FromPath = openfluid::tools::Filesystem::joinPath({buildRessourcesPath(ResourcesPath),
128133
openfluid::config::PROJECTS_PATH});
@@ -136,9 +141,15 @@ bool ExamplesManager::installProject(const std::string& ProjectDir,
136141
}
137142
std::string ToPath = openfluid::tools::Filesystem::joinPath({buildInstallPath(InstallPath),
138143
openfluid::config::PROJECTS_PATH});
139-
std::cout << "-- Installing project " << ProjectDir << " from " << FromPath << " to " << ToPath << " ";
144+
if (Verbose)
145+
{
146+
std::cout << "-- Installing project " << ProjectDir << " from " << FromPath << " to " << ToPath << " ";
147+
}
140148
bool Status = installDirectory(FromPath, ToPath, ProjectDir, Force);
141-
printSuccessStatus(Status);
149+
if (Verbose)
150+
{
151+
printSuccessStatus(Status);
152+
}
142153
return Status;
143154
}
144155

@@ -149,7 +160,7 @@ bool ExamplesManager::installProject(const std::string& ProjectDir,
149160

150161
bool ExamplesManager::installSimulator(const std::string& SimulatorDir,
151162
const std::string& ResourcesPath, const std::string& InstallPath,
152-
const bool Force)
163+
const bool Force, const bool Verbose)
153164
{
154165
std::string FromPath = openfluid::tools::Filesystem::joinPath({buildRessourcesPath(ResourcesPath),
155166
openfluid::config::WARESDEV_PATH,
@@ -165,9 +176,15 @@ bool ExamplesManager::installSimulator(const std::string& SimulatorDir,
165176
std::string ToPath = openfluid::tools::Filesystem::joinPath({buildInstallPath(InstallPath),
166177
openfluid::config::WARESDEV_PATH,
167178
openfluid::config::SIMULATORS_PATH});
168-
std::cout << "-- Installing simulator " << SimulatorDir << " from " << FromPath << " to " << ToPath << " ";
179+
if (Verbose)
180+
{
181+
std::cout << "-- Installing simulator " << SimulatorDir << " from " << FromPath << " to " << ToPath << " ";
182+
}
169183
bool Status = installDirectory(FromPath,ToPath,SimulatorDir,Force);
170-
printSuccessStatus(Status);
184+
if (Verbose)
185+
{
186+
printSuccessStatus(Status);
187+
}
171188
return Status;
172189
}
173190

@@ -178,7 +195,7 @@ bool ExamplesManager::installSimulator(const std::string& SimulatorDir,
178195

179196
bool ExamplesManager::installObserver(const std::string& ObserverDir,
180197
const std::string& ResourcesPath, const std::string& InstallPath,
181-
const bool Force)
198+
const bool Force, const bool Verbose)
182199
{
183200
std::string FromPath = openfluid::tools::Filesystem::joinPath({buildRessourcesPath(ResourcesPath),
184201
openfluid::config::WARESDEV_PATH,
@@ -194,9 +211,16 @@ bool ExamplesManager::installObserver(const std::string& ObserverDir,
194211
std::string ToPath = openfluid::tools::Filesystem::joinPath({buildInstallPath(InstallPath),
195212
openfluid::config::WARESDEV_PATH,
196213
openfluid::config::OBSERVERS_PATH});
197-
std::cout << "-- Installing observer " << ObserverDir << " from " << FromPath << " to " << ToPath << " ";
214+
215+
if (Verbose)
216+
{
217+
std::cout << "-- Installing observer " << ObserverDir << " from " << FromPath << " to " << ToPath << " ";
218+
}
198219
bool Status = installDirectory(FromPath,ToPath,ObserverDir,Force);
199-
printSuccessStatus(Status);
220+
if (Verbose)
221+
{
222+
printSuccessStatus(Status);
223+
}
200224
return Status;
201225
}
202226

@@ -206,7 +230,7 @@ bool ExamplesManager::installObserver(const std::string& ObserverDir,
206230

207231

208232
bool ExamplesManager::installAllProjects(const std::string& ResourcesPath, const std::string& InstallPath,
209-
const bool Force)
233+
const bool Force, const bool Verbose)
210234
{
211235
auto ResPath = buildRessourcesPath(ResourcesPath);
212236
auto InstPath = buildInstallPath(InstallPath);
@@ -220,7 +244,7 @@ bool ExamplesManager::installAllProjects(const std::string& ResourcesPath, const
220244
bool AllIsOK = true;
221245
for (const auto& Prj : FoundProjects)
222246
{
223-
AllIsOK &= installProject(Prj,ResPath,InstPath,Force);
247+
AllIsOK &= installProject(Prj, ResPath, InstPath, Force, Verbose);
224248
}
225249
return AllIsOK;
226250
}
@@ -238,7 +262,7 @@ bool ExamplesManager::installAllProjects(const std::string& ResourcesPath, const
238262

239263

240264
bool ExamplesManager::installAllSimulators(const std::string& ResourcesPath, const std::string& InstallPath,
241-
const bool Force)
265+
const bool Force, const bool Verbose)
242266
{
243267
auto ResPath = buildRessourcesPath(ResourcesPath);
244268
auto InstPath = buildInstallPath(InstallPath);
@@ -254,7 +278,7 @@ bool ExamplesManager::installAllSimulators(const std::string& ResourcesPath, con
254278
bool AllIsOK = true;
255279
for (const auto& Sim : FoundSimulators)
256280
{
257-
AllIsOK &= installSimulator(Sim,ResPath,InstPath,Force);
281+
AllIsOK &= installSimulator(Sim, ResPath, InstPath, Force, Verbose);
258282
}
259283
return AllIsOK;
260284
}
@@ -272,7 +296,7 @@ bool ExamplesManager::installAllSimulators(const std::string& ResourcesPath, con
272296

273297

274298
bool ExamplesManager::installAllObservers(const std::string& ResourcesPath, const std::string& InstallPath,
275-
const bool Force)
299+
const bool Force, const bool Verbose)
276300
{
277301
auto ResPath = buildRessourcesPath(ResourcesPath);
278302
auto InstPath = buildInstallPath(InstallPath);
@@ -288,7 +312,7 @@ bool ExamplesManager::installAllObservers(const std::string& ResourcesPath, cons
288312
bool AllIsOK = true;
289313
for (const auto& Obs : FoundObservers)
290314
{
291-
AllIsOK &= installObserver(Obs,ResPath,InstPath,Force);
315+
AllIsOK &= installObserver(Obs, ResPath, InstPath, Force, Verbose);
292316
}
293317
return AllIsOK;
294318
}
@@ -306,11 +330,11 @@ bool ExamplesManager::installAllObservers(const std::string& ResourcesPath, cons
306330

307331

308332
bool ExamplesManager::installAllWares(const std::string& ResourcesPath, const std::string& InstallPath,
309-
const bool Force)
333+
const bool Force, const bool Verbose)
310334
{
311335
bool AllIsOK = true;
312-
AllIsOK &= installAllSimulators(ResourcesPath,InstallPath,Force);
313-
AllIsOK &= installAllObservers(ResourcesPath,InstallPath,Force);
336+
AllIsOK &= installAllSimulators(ResourcesPath,InstallPath,Force,Verbose);
337+
AllIsOK &= installAllObservers(ResourcesPath,InstallPath,Force,Verbose);
314338

315339
return AllIsOK;
316340
}
@@ -320,11 +344,12 @@ bool ExamplesManager::installAllWares(const std::string& ResourcesPath, const st
320344
// =====================================================================
321345

322346

323-
bool ExamplesManager::installAll(const std::string& ResourcesPath, const std::string& InstallPath, const bool Force)
347+
bool ExamplesManager::installAll(const std::string& ResourcesPath, const std::string& InstallPath, const bool Force,
348+
const bool Verbose)
324349
{
325350
bool AllIsOK = true;
326-
AllIsOK &= installAllProjects(ResourcesPath,InstallPath,Force);
327-
AllIsOK &= installAllWares(ResourcesPath,InstallPath,Force);
351+
AllIsOK &= installAllProjects(ResourcesPath,InstallPath,Force,Verbose);
352+
AllIsOK &= installAllWares(ResourcesPath,InstallPath,Force,Verbose);
328353

329354
return AllIsOK;
330355
}

src/openfluid/base/ExamplesManager.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class OPENFLUID_API ExamplesManager
8181
*/
8282
static bool installProject(const std::string& ProjectDir,
8383
const std::string& ResourcesPath = "", const std::string& InstallPath = "",
84-
const bool Force = false);
84+
const bool Force = false, const bool Verbose = false);
8585

8686
/**
8787
Installs a single example simulator, using its directory name
@@ -94,11 +94,11 @@ class OPENFLUID_API ExamplesManager
9494
*/
9595
static bool installSimulator(const std::string& SimulatorDir,
9696
const std::string& ResourcesPath = "", const std::string& InstallPath = "",
97-
const bool Force = false);
97+
const bool Force = false, const bool Verbose = false);
9898

9999
static bool installObserver(const std::string& ObserverDir,
100100
const std::string& ResourcesPath = "", const std::string& InstallPath = "",
101-
const bool Force = false);
101+
const bool Force = false, const bool Verbose = false);
102102

103103
/**
104104
Installs all example projects
@@ -109,7 +109,7 @@ class OPENFLUID_API ExamplesManager
109109
@param[in] Force If true, the installation is forced even if it already exists (default is false)
110110
*/
111111
static bool installAllProjects(const std::string& ResourcesPath = "", const std::string& InstallPath = "",
112-
const bool Force = false);
112+
const bool Force = false, const bool Verbose = false);
113113

114114
/**
115115
Installs all example simulators
@@ -120,7 +120,7 @@ class OPENFLUID_API ExamplesManager
120120
@param[in] Force If true, the installation is forced even if it already exists (default is false)
121121
*/
122122
static bool installAllSimulators(const std::string& ResourcesPath = "", const std::string& InstallPath = "",
123-
const bool Force = false);
123+
const bool Force = false, const bool Verbose = false);
124124

125125
/**
126126
Installs all example observers
@@ -131,7 +131,7 @@ class OPENFLUID_API ExamplesManager
131131
@param[in] Force If true, the installation is forced even if it already exists (default is false)
132132
*/
133133
static bool installAllObservers(const std::string& ResourcesPath = "", const std::string& InstallPath = "",
134-
const bool Force = false);
134+
const bool Force = false, const bool Verbose = false);
135135

136136
/**
137137
Installs all example wares (simulators and observers)
@@ -142,7 +142,7 @@ class OPENFLUID_API ExamplesManager
142142
@param[in] Force If true, the installation is forced even if it already exists (default is false)
143143
*/
144144
static bool installAllWares(const std::string& ResourcesPath = "", const std::string& InstallPath = "",
145-
const bool Force = false);
145+
const bool Force = false, const bool Verbose = false);
146146

147147
/**
148148
Installs all example projects and simulators
@@ -153,7 +153,7 @@ class OPENFLUID_API ExamplesManager
153153
@param[in] Force If true, the installation is forced even if it already exists (default is false)
154154
*/
155155
static bool installAll(const std::string& ResourcesPath = "", const std::string& InstallPath = "",
156-
const bool Force = false);
156+
const bool Force = false, const bool Verbose = false);
157157
};
158158

159159

0 commit comments

Comments
 (0)