Nonlocal: Raw -> Smart Pointers. Improved config of standalone dump_nonlocal_field.
This commit is contained in:
40
src/external/Nonlocal/PNL_PippardFitter.cpp
vendored
40
src/external/Nonlocal/PNL_PippardFitter.cpp
vendored
@@ -31,6 +31,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include <TSAXParser.h>
|
||||
#include <TMath.h>
|
||||
@@ -52,14 +53,14 @@ PNL_PippardFitterGlobal::PNL_PippardFitterGlobal()
|
||||
{
|
||||
// read XML startup file
|
||||
char startup_path_name[128];
|
||||
TSAXParser *saxParser = new TSAXParser();
|
||||
PNL_StartupHandler *fStartupHandler = new PNL_StartupHandler();
|
||||
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
|
||||
fStartupHandler = std::make_unique<PNL_StartupHandler>();
|
||||
strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data());
|
||||
saxParser->ConnectToHandler("PNL_StartupHandler", fStartupHandler);
|
||||
saxParser->ConnectToHandler("PNL_StartupHandler", fStartupHandler.get());
|
||||
//Int_t status = saxParser->ParseFile(startup_path_name);
|
||||
// parsing the file as above seems to lead to problems in certain environments;
|
||||
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
|
||||
Int_t status = parseXmlFile(saxParser, startup_path_name);
|
||||
Int_t status = parseXmlFile(saxParser.get(), startup_path_name);
|
||||
// check for parse errors
|
||||
if (status) { // error
|
||||
std::cout << std::endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal: **WARNING** Reading/parsing nonlocal_startup.xml failed.";
|
||||
@@ -67,14 +68,8 @@ PNL_PippardFitterGlobal::PNL_PippardFitterGlobal()
|
||||
fValid = false;
|
||||
}
|
||||
|
||||
// clean up
|
||||
if (saxParser) {
|
||||
delete saxParser;
|
||||
saxParser = 0;
|
||||
}
|
||||
|
||||
// check if everything went fine with the startup handler
|
||||
if (!fStartupHandler->IsValid()) {
|
||||
if (!fStartupHandler->IsValid() && fValid) {
|
||||
std::cout << std::endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal **PANIC ERROR**";
|
||||
std::cout << std::endl << ">> startup handler too unhappy. Will terminate unfriendly, sorry.";
|
||||
std::cout << std::endl;
|
||||
@@ -84,12 +79,14 @@ PNL_PippardFitterGlobal::PNL_PippardFitterGlobal()
|
||||
fFourierPoints = fStartupHandler->GetFourierPoints();
|
||||
|
||||
// load all the TRIM.SP rge-files
|
||||
fRgeHandler = new PRgeHandler("./nonlocal_startup.xml");
|
||||
if (!fRgeHandler->IsValid()) {
|
||||
std::cout << std::endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal **PANIC ERROR**";
|
||||
std::cout << std::endl << ">> rge data handler too unhappy. Will terminate unfriendly, sorry.";
|
||||
std::cout << std::endl;
|
||||
fValid = false;
|
||||
if (fValid) {
|
||||
fRgeHandler = std::make_unique<PRgeHandler>("./nonlocal_startup.xml");
|
||||
if (!fRgeHandler->IsValid()) {
|
||||
std::cout << std::endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal **PANIC ERROR**";
|
||||
std::cout << std::endl << ">> rge data handler too unhappy. Will terminate unfriendly, sorry.";
|
||||
std::cout << std::endl;
|
||||
fValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
fPlanPresent = false;
|
||||
@@ -124,15 +121,6 @@ PNL_PippardFitterGlobal::~PNL_PippardFitterGlobal()
|
||||
fftw_free(fFieldq);
|
||||
fFieldB = 0;
|
||||
}
|
||||
|
||||
if (fRgeHandler) {
|
||||
delete fRgeHandler;
|
||||
fRgeHandler = 0;
|
||||
}
|
||||
if (fStartupHandler) {
|
||||
delete fStartupHandler;
|
||||
fStartupHandler = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user