diff --git a/Code/Core/test/mapSDXMLFileReaderTest.cxx b/Code/Core/test/mapSDXMLFileReaderTest.cxx
index 477e652..d9abf43 100644
--- a/Code/Core/test/mapSDXMLFileReaderTest.cxx
+++ b/Code/Core/test/mapSDXMLFileReaderTest.cxx
@@ -1,138 +1,138 @@
// -----------------------------------------------------------------------
// MatchPoint - DKFZ translational registration framework
//
// Copyright (c) German Cancer Research Center (DKFZ),
// Software development for Integrated Diagnostics and Therapy (SIDT).
// ALL RIGHTS RESERVED.
// See mapCopyright.txt or
// http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notices for more information.
//
//------------------------------------------------------------------------
/*!
// @file
// @version $Revision$ (last changed revision)
// @date $Date$ (last change date)
// @author $Author$ (last changed by)
// Subversion HeadURL: $HeadURL$
*/
#include "mapSDXMLFileReader.h"
#include "mapSDExceptions.h"
#include "mapSDTags.h"
#include "litCheckMacros.h"
namespace map
{
namespace testing
{
int mapSDXMLFileReaderTest(int argn, char* argv[])
{
PREPARE_DEFAULT_TEST_REPORTING;
core::String dataDir = argv[1];
core::String validFile = dataDir+"/validXML.xml";
core::String invalidFile1 = dataDir+"/invalidXML1.xml";
core::String invalidFile2 = dataDir+"/invalidXML2.xml";
core::String invalidFile3 = dataDir+"/invalidXML3.xml";
core::String invalidFile4 = dataDir+"/invalidXML4.xml";
core::String emptyFile = dataDir+"/emptyXML.xml";
map::structuredData::XMLFileReader::Pointer spReader = map::structuredData::XMLFileReader::New();
- map::structuredData::Element::Pointer spRoot = NULL;
+ map::structuredData::Element::Pointer spRoot;
CHECK(spReader->getXMLContent().IsNull());
CHECK_NO_THROW(spRoot = spReader->read(validFile));
CHECK(spRoot.IsNotNull());
CHECK_EQUAL("ROOT", spRoot->getTag());
map::structuredData::Element::Pointer spMain = spRoot->getSubElement(0);
CHECK(spMain.IsNotNull());
CHECK_EQUAL("Main", spMain->getTag());
CHECK_EQUAL("boss", spMain->getValue());
CHECK_EQUAL("demo", spMain->getAttribute("type"));
CHECK_EQUAL(tags::SDInternalSourceReader_file, spMain->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spMain->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(validFile, spMain->getAttribute(tags::SDInternalSourceURI));
CHECK_EQUAL(4, spMain->getAttributeNames().size());
CHECK_EQUAL(4, spMain->getSubElementsCount());
map::structuredData::Element::Pointer spSub = spMain->getSubElement(0);
CHECK(spSub.IsNotNull());
CHECK_EQUAL("Sub", spSub->getTag());
CHECK_EQUAL("1st", spSub->getValue());
CHECK_EQUAL("1", spSub->getAttribute("id"));
CHECK_EQUAL(tags::SDInternalSourceReader_file, spSub->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spSub->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(validFile, spSub->getAttribute(tags::SDInternalSourceURI));
CHECK_EQUAL(4, spSub->getAttributeNames().size());
CHECK_EQUAL(0, spSub->getSubElementsCount());
spSub = spMain->getSubElement(1);
CHECK(spSub.IsNotNull());
CHECK_EQUAL("Sub", spSub->getTag());
CHECK_EQUAL("2nd", spSub->getValue());
CHECK_EQUAL("2", spSub->getAttribute("id"));
CHECK_EQUAL("###", spSub->getAttribute("attr2"));
CHECK_EQUAL(tags::SDInternalSourceReader_file, spSub->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spSub->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(validFile, spSub->getAttribute(tags::SDInternalSourceURI));
CHECK_EQUAL(5, spSub->getAttributeNames().size());
CHECK_EQUAL(0, spSub->getSubElementsCount());
spSub = spMain->getSubElement(2);
CHECK(spSub.IsNotNull());
CHECK_EQUAL("Sub", spSub->getTag());
CHECK_EQUAL("", spSub->getValue());
CHECK_EQUAL("3", spSub->getAttribute("id"));
CHECK_EQUAL(tags::SDInternalSourceReader_file, spSub->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spSub->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(validFile, spSub->getAttribute(tags::SDInternalSourceURI));
CHECK_EQUAL(4, spSub->getAttributeNames().size());
CHECK_EQUAL(1, spSub->getSubElementsCount());
CHECK_EQUAL("Sub", spSub->getSubElement(0)->getTag());
CHECK_EQUAL("", spSub->getSubElement(0)->getValue());
CHECK_EQUAL("3.1", spSub->getSubElement(0)->getAttribute("id"));
CHECK_EQUAL(tags::SDInternalSourceReader_file, spSub->getSubElement(0)->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spSub->getSubElement(0)->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(validFile, spSub->getSubElement(0)->getAttribute(tags::SDInternalSourceURI));
CHECK_EQUAL(4, spSub->getSubElement(0)->getAttributeNames().size());
CHECK_EQUAL(0, spSub->getSubElement(0)->getSubElementsCount());
spSub = spMain->getSubElement(3);
CHECK(spSub.IsNotNull());
CHECK_EQUAL("Add", spSub->getTag());
CHECK_EQUAL("", spSub->getValue());
CHECK_EQUAL(tags::SDInternalSourceReader_file, spSub->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spSub->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(validFile, spSub->getAttribute(tags::SDInternalSourceURI));
CHECK_EQUAL(3, spSub->getAttributeNames().size());
CHECK_EQUAL(0, spSub->getSubElementsCount());
CHECK_EQUAL(spMain.GetPointer(), spReader->getXMLContent().GetPointer());
CHECK_THROW(spReader->read(invalidFile1));
CHECK_THROW(spReader->read(invalidFile1));
CHECK_THROW(spReader->read(invalidFile1));
CHECK_THROW(spReader->read(invalidFile1));
CHECK_THROW(spReader->read(emptyFile));
CHECK_EQUAL(spMain.GetPointer(), spReader->getXMLContent().GetPointer());
RETURN_AND_REPORT_TEST_SUCCESS;
}
} //namespace testing
} //namespace map
diff --git a/Code/Core/test/mapSDXMLStrReaderTest.cpp b/Code/Core/test/mapSDXMLStrReaderTest.cpp
index e3b2c29..5c1b9c1 100644
--- a/Code/Core/test/mapSDXMLStrReaderTest.cpp
+++ b/Code/Core/test/mapSDXMLStrReaderTest.cpp
@@ -1,196 +1,196 @@
// -----------------------------------------------------------------------
// MatchPoint - DKFZ translational registration framework
//
// Copyright (c) German Cancer Research Center (DKFZ),
// Software development for Integrated Diagnostics and Therapy (SIDT).
// ALL RIGHTS RESERVED.
// See mapCopyright.txt or
// http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notices for more information.
//
//------------------------------------------------------------------------
/*!
// @file
// @version $Revision$ (last changed revision)
// @date $Date$ (last change date)
// @author $Author$ (last changed by)
// Subversion HeadURL: $HeadURL$
*/
#include "litCheckMacros.h"
#include "mapSDXMLStrReader.h"
#include "mapSDExceptions.h"
#include "mapSDTags.h"
namespace map
{
namespace testing
{
int mapSDXMLStrReaderTest(int, char* [])
{
PREPARE_DEFAULT_TEST_REPORTING;
::map::core::String dataStr1 =
"boss1st2nd";
map::structuredData::XMLStrReader::Pointer spReader = map::structuredData::XMLStrReader::New();
- map::structuredData::Element::Pointer spRoot = NULL;
+ map::structuredData::Element::Pointer spRoot;
CHECK_NO_THROW(spRoot = spReader->read(dataStr1));
CHECK_EQUAL("ROOT", spRoot->getTag());
map::structuredData::Element::Pointer spMain = spRoot->getSubElement(0);
CHECK(spMain.IsNotNull());
CHECK_EQUAL("Main", spMain->getTag());
CHECK_EQUAL("boss", spMain->getValue());
CHECK_EQUAL("demo", spMain->getAttribute("type"));
CHECK_EQUAL(tags::SDInternalSourceReader_string,
spMain->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spMain->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(3, spMain->getAttributeNames().size());
CHECK_EQUAL(4, spMain->getSubElementsCount());
map::structuredData::Element::Pointer spSub = spMain->getSubElement(0);
CHECK(spSub.IsNotNull());
CHECK_EQUAL("Sub", spSub->getTag());
CHECK_EQUAL("1st", spSub->getValue());
CHECK_EQUAL("1", spSub->getAttribute("id"));
CHECK_EQUAL(tags::SDInternalSourceReader_string, spSub->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spSub->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(3, spSub->getAttributeNames().size());
CHECK_EQUAL(0, spSub->getSubElementsCount());
spSub = spMain->getSubElement(1);
CHECK(spSub.IsNotNull());
CHECK_EQUAL("Sub", spSub->getTag());
CHECK_EQUAL("2nd", spSub->getValue());
CHECK_EQUAL("2", spSub->getAttribute("id"));
CHECK_EQUAL("###", spSub->getAttribute("attr2"));
CHECK_EQUAL(tags::SDInternalSourceReader_string, spSub->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spSub->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(4, spSub->getAttributeNames().size());
CHECK_EQUAL(0, spSub->getSubElementsCount());
spSub = spMain->getSubElement(2);
CHECK(spSub.IsNotNull());
CHECK_EQUAL("Sub", spSub->getTag());
CHECK_EQUAL("", spSub->getValue());
CHECK_EQUAL("3", spSub->getAttribute("id"));
CHECK_EQUAL(tags::SDInternalSourceReader_string,
spMain->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spMain->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(3, spSub->getAttributeNames().size());
CHECK_EQUAL(1, spSub->getSubElementsCount());
CHECK_EQUAL("Sub", spSub->getSubElement(0)->getTag());
CHECK_EQUAL("", spSub->getSubElement(0)->getValue());
CHECK_EQUAL("3.1", spSub->getSubElement(0)->getAttribute("id"));
CHECK_EQUAL(tags::SDInternalSourceReader_string,
spSub->getSubElement(0)->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml,
spSub->getSubElement(0)->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(3, spSub->getSubElement(0)->getAttributeNames().size());
CHECK_EQUAL(0, spSub->getSubElement(0)->getSubElementsCount());
spSub = spMain->getSubElement(3);
CHECK(spSub.IsNotNull());
CHECK_EQUAL("Add", spSub->getTag());
CHECK_EQUAL("", spSub->getValue());
CHECK_EQUAL(tags::SDInternalSourceReader_string, spSub->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spSub->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(2, spSub->getAttributeNames().size());
CHECK_EQUAL(0, spSub->getSubElementsCount());
::map::core::String faultyDataStr1 = "";
::map::core::String faultyDataStr2 = " ";
::map::core::String faultyDataStr3 = "";
::map::core::String faultyDataStr4 = " ";
CHECK_THROW(spReader->read(faultyDataStr1));
CHECK_THROW(spReader->read(faultyDataStr2));
CHECK_THROW(spReader->read(faultyDataStr3));
CHECK_THROW(spReader->read(faultyDataStr4));
//check direct content access
CHECK_NO_THROW(spMain = spReader->readXMLContent(dataStr1));
CHECK(spMain.IsNotNull());
CHECK_EQUAL("Main", spMain->getTag());
CHECK_EQUAL("boss", spMain->getValue());
CHECK_EQUAL("demo", spMain->getAttribute("type"));
CHECK_EQUAL(tags::SDInternalSourceReader_string,
spMain->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spMain->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(3, spMain->getAttributeNames().size());
CHECK_EQUAL(4, spMain->getSubElementsCount());
spSub = spMain->getSubElement(0);
CHECK(spSub.IsNotNull());
CHECK_EQUAL("Sub", spSub->getTag());
CHECK_EQUAL("1st", spSub->getValue());
CHECK_EQUAL("1", spSub->getAttribute("id"));
CHECK_EQUAL(tags::SDInternalSourceReader_string, spSub->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spSub->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(3, spSub->getAttributeNames().size());
CHECK_EQUAL(0, spSub->getSubElementsCount());
spSub = spMain->getSubElement(1);
CHECK(spSub.IsNotNull());
CHECK_EQUAL("Sub", spSub->getTag());
CHECK_EQUAL("2nd", spSub->getValue());
CHECK_EQUAL("2", spSub->getAttribute("id"));
CHECK_EQUAL("###", spSub->getAttribute("attr2"));
CHECK_EQUAL(tags::SDInternalSourceReader_string, spSub->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spSub->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(4, spSub->getAttributeNames().size());
CHECK_EQUAL(0, spSub->getSubElementsCount());
spSub = spMain->getSubElement(2);
CHECK(spSub.IsNotNull());
CHECK_EQUAL("Sub", spSub->getTag());
CHECK_EQUAL("", spSub->getValue());
CHECK_EQUAL("3", spSub->getAttribute("id"));
CHECK_EQUAL(tags::SDInternalSourceReader_string, spSub->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spSub->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(3, spSub->getAttributeNames().size());
CHECK_EQUAL(1, spSub->getSubElementsCount());
CHECK_EQUAL("Sub", spSub->getSubElement(0)->getTag());
CHECK_EQUAL("", spSub->getSubElement(0)->getValue());
CHECK_EQUAL("3.1", spSub->getSubElement(0)->getAttribute("id"));
CHECK_EQUAL(tags::SDInternalSourceReader_string,
spSub->getSubElement(0)->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml,
spSub->getSubElement(0)->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(3, spSub->getSubElement(0)->getAttributeNames().size());
CHECK_EQUAL(0, spSub->getSubElement(0)->getSubElementsCount());
spSub = spMain->getSubElement(3);
CHECK(spSub.IsNotNull());
CHECK_EQUAL("Add", spSub->getTag());
CHECK_EQUAL("", spSub->getValue());
CHECK_EQUAL(tags::SDInternalSourceReader_string, spSub->getAttribute(tags::SDInternalSourceReader));
CHECK_EQUAL(tags::SDInternalSourceFormat_xml, spSub->getAttribute(tags::SDInternalSourceFormat));
CHECK_EQUAL(2, spSub->getAttributeNames().size());
CHECK_EQUAL(0, spSub->getSubElementsCount());
::map::core::String emptyDataStr1 = "";
CHECK_THROW(spReader->readXMLContent(emptyDataStr1));
RETURN_AND_REPORT_TEST_SUCCESS;
}
} //namespace Testing
} //namespace FREE
diff --git a/Code/Core/test/mapSDXMLStrWriterTest.cxx b/Code/Core/test/mapSDXMLStrWriterTest.cxx
index 294d13a..2e1f22f 100644
--- a/Code/Core/test/mapSDXMLStrWriterTest.cxx
+++ b/Code/Core/test/mapSDXMLStrWriterTest.cxx
@@ -1,65 +1,65 @@
// -----------------------------------------------------------------------
// MatchPoint - DKFZ translational registration framework
//
// Copyright (c) German Cancer Research Center (DKFZ),
// Software development for Integrated Diagnostics and Therapy (SIDT).
// ALL RIGHTS RESERVED.
// See mapCopyright.txt or
// http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notices for more information.
//
//------------------------------------------------------------------------
/*!
// @file
// @version $Revision$ (last changed revision)
// @date $Date$ (last change date)
// @author $Author$ (last changed by)
// Subversion HeadURL: $HeadURL$
*/
#include "mapSDXMLStrWriter.h"
#include "mapSDXMLStrReader.h"
#include "mapSDExceptions.h"
#include "litCheckMacros.h"
namespace map
{
namespace testing
{
int mapSDXMLStrWriterTest(int, char* [] )
{
PREPARE_DEFAULT_TEST_REPORTING;
core::String dataStr1 = "boss1st2nd";
map::structuredData::XMLStrReader::Pointer spReader = map::structuredData::XMLStrReader::New();
map::structuredData::XMLStrWriter::Pointer spWriter = map::structuredData::XMLStrWriter::New();
- map::structuredData::Element::Pointer spMain = NULL;
+ map::structuredData::Element::Pointer spMain;
spMain = spReader->readXMLContent(dataStr1);
core::String result = "";
CHECK_NO_THROW(result = spWriter->write(spMain));
CHECK_EQUAL(dataStr1, result);
CHECK_THROW(spWriter->write(NULL));
map::structuredData::XMLIntendedStrWriter::Pointer spWriter2 = map::structuredData::XMLIntendedStrWriter::New();
core::String intendedResult = "";
core::String intendedDataStr = "boss\n 1st\n 2nd\n \n \n \n \n\n";
CHECK_NO_THROW(intendedResult = spWriter2->write(spMain));
CHECK_EQUAL(intendedDataStr, intendedResult);
RETURN_AND_REPORT_TEST_SUCCESS;
}
} //namespace Testing
} //namespace FREE
diff --git a/Code/Deployment/test/mapDeploymentDLLAccessTest.cpp b/Code/Deployment/test/mapDeploymentDLLAccessTest.cpp
index bfb40d5..df78544 100644
--- a/Code/Deployment/test/mapDeploymentDLLAccessTest.cpp
+++ b/Code/Deployment/test/mapDeploymentDLLAccessTest.cpp
@@ -1,209 +1,209 @@
// -----------------------------------------------------------------------
// MatchPoint - DKFZ translational registration framework
//
// Copyright (c) German Cancer Research Center (DKFZ),
// Software development for Integrated Diagnostics and Therapy (SIDT).
// ALL RIGHTS RESERVED.
// See mapCopyright.txt or
// http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notices for more information.
//
//------------------------------------------------------------------------
/*!
// @file
// @version $Revision$ (last changed revision)
// @date $Date$ (last change date)
// @author $Author$ (last changed by)
// Subversion HeadURL: $HeadURL$
*/
#include "mapDeploymentDLLAccess.h"
#include "litCheckMacros.h"
#include "itksys/SystemTools.hxx"
#include "itkDynamicLoader.h"
namespace map
{
namespace testing
{
//defined by mapDeploymentTests.cpp. It is tha path to the current running executable.
//It is needed to bypass the problem that when using MS Visual Studio the actual binary
//path depends of the compile mode (release/debug) and is not the CMake binary path.
extern const char* _callingAppPath;
int mapDeploymentDLLAccessTest(int, char* argv[])
{
PREPARE_DEFAULT_TEST_REPORTING;
std::string dllPath = itksys::SystemTools::GetProgramPath(_callingAppPath);
//////////////////////////////////////////////////
// Test: openDeploymentDLL + getRegistrationAlgorithm + closeDeploymentDLL
//Test open with wrong path pointer
CHECK_THROW(map::deployment::openDeploymentDLL(NULL));
//Test open non existing file
CHECK_THROW_EXPLICIT(map::deployment::openDeploymentDLL("nonExistingFile.???"),
deployment::InvalidDLLException);
//Test open file with wrong file extension
CHECK_THROW_EXPLICIT(map::deployment::openDeploymentDLL("nonExistingFile.???"),
deployment::InvalidDLLException);
//Test open file regular DLL
- deployment::DLLHandle::Pointer spHandle1 = NULL;
+ deployment::DLLHandle::Pointer spHandle1;
std::string validDLLPath = dllPath + "/" + itksys::DynamicLoader::LibPrefix() + "mapTestAlgorithm" + map::deployment::getDeploymentDLLExtension();
CHECK_NO_THROW(spHandle1 = map::deployment::openDeploymentDLL(validDLLPath));
//now check the returned information
CHECK(spHandle1.IsNotNull());
CHECK_EQUAL(validDLLPath, spHandle1->getLibraryFilePath());
CHECK_EQUAL("de.dkfz.matchpoint", spHandle1->getAlgorithmUID().getNamespace());
CHECK_EQUAL("TestAlgorithm", spHandle1->getAlgorithmUID().getName());
CHECK_EQUAL("1.0.0", spHandle1->getAlgorithmUID().getVersion());
CHECK_EQUAL("testprofile", spHandle1->getAlgorithmProfileStr());
- map::algorithm::RegistrationAlgorithmBase::Pointer spInstance = NULL;
+ map::algorithm::RegistrationAlgorithmBase::Pointer spInstance;
CHECK_NO_THROW(spInstance = map::deployment::getRegistrationAlgorithm(spHandle1));
CHECK(spInstance.IsNotNull());
- spInstance = NULL; //Enforce the destruction of the instance before the DLL is closed!
+ spInstance = nullptr; //Enforce the destruction of the instance before the DLL is closed!
CHECK_NO_THROW(map::deployment::closeDeploymentDLL(spHandle1));
//Test open file invalid DLL (missing mapGetDLLInterfaceVersion symbol)
std::string invalidDLLPath = dllPath + "/" + itksys::DynamicLoader::LibPrefix() +
"mapTestAlgorithmInvalid1" + map::deployment::getDeploymentDLLExtension();
CHECK_THROW_EXPLICIT(map::deployment::openDeploymentDLL(invalidDLLPath),
deployment::MissingSymbolException);
//Test open file invalid DLL (missing mapGetRegistrationAlgorithmUID symbol)
invalidDLLPath = dllPath + "/" + itksys::DynamicLoader::LibPrefix() + "mapTestAlgorithmInvalid2" + map::deployment::getDeploymentDLLExtension();
CHECK_THROW_EXPLICIT(map::deployment::openDeploymentDLL(invalidDLLPath),
deployment::MissingSymbolException);
//Test open file invalid DLL (missing mapGetRegistrationAlgorithmInstance symbol)
invalidDLLPath = dllPath + "/" + itksys::DynamicLoader::LibPrefix() + "mapTestAlgorithmInvalid3" + map::deployment::getDeploymentDLLExtension();
CHECK_THROW_EXPLICIT(map::deployment::openDeploymentDLL(invalidDLLPath),
deployment::MissingSymbolException);
//Test open file invalid DLL (missing mapGetRegistrationAlgorithmProfile symbol)
invalidDLLPath = dllPath + "/" + itksys::DynamicLoader::LibPrefix() + "mapTestAlgorithmInvalid7" + map::deployment::getDeploymentDLLExtension();
CHECK_THROW_EXPLICIT(map::deployment::openDeploymentDLL(invalidDLLPath),
deployment::MissingSymbolException);
//Test open file invalid DLL (wrong version)
invalidDLLPath = dllPath + "/" + itksys::DynamicLoader::LibPrefix() + "mapTestAlgorithmInvalid4" + map::deployment::getDeploymentDLLExtension();
CHECK_THROW_EXPLICIT(map::deployment::openDeploymentDLL(invalidDLLPath),
deployment::InvalidInterfaceVersionException);
//Test open file invalid DLL (invalid UID when calling mapGetRegistrationAlgorithmUID)
invalidDLLPath = dllPath + "/" + itksys::DynamicLoader::LibPrefix() + "mapTestAlgorithmInvalid5" + map::deployment::getDeploymentDLLExtension();
CHECK_THROW_EXPLICIT(map::deployment::openDeploymentDLL(invalidDLLPath),
deployment::InvalidUIDException);
//////////////////////////////////////////////////
// Test: getRegistrationAlgorithm errors
CHECK_THROW(map::deployment::getRegistrationAlgorithm(NULL));
//////////////////////////////////////////////////
// Test: peekDeploymentDLL
map::algorithm::UID::ConstPointer spUID;
//Test peek with wrong path pointer
CHECK_THROW(map::deployment::peekDeploymentDLL(NULL));
//Test peek non existing file
CHECK_THROW_EXPLICIT(map::deployment::peekDeploymentDLL("nonExistingFile.???"),
deployment::InvalidDLLException);
//Test peek file with wrong file extension
CHECK_THROW_EXPLICIT(map::deployment::peekDeploymentDLL("nonExistingFile.???"),
deployment::InvalidDLLException);
//Test peek with valid DLL (using String)
CHECK_NO_THROW(spUID = map::deployment::peekDeploymentDLL(validDLLPath));
CHECK(spUID.IsNotNull());
CHECK_EQUAL("de.dkfz.matchpoint", spUID->getNamespace());
CHECK_EQUAL("TestAlgorithm", spUID->getName());
CHECK_EQUAL("1.0.0", spUID->getVersion());
//Test peek with valid DLL (using char*)
CHECK_NO_THROW(spUID = map::deployment::peekDeploymentDLL(validDLLPath.c_str()));
CHECK(spUID.IsNotNull());
CHECK_EQUAL("de.dkfz.matchpoint", spUID->getNamespace());
CHECK_EQUAL("TestAlgorithm", spUID->getName());
CHECK_EQUAL("1.0.0", spUID->getVersion());
//Test alternative peek with valid dll
spUID = NULL;
::map::core::String testProfile = "";
CHECK_NO_THROW(map::deployment::peekDeploymentDLL(validDLLPath, spUID, testProfile));
CHECK(spUID.IsNotNull());
CHECK_EQUAL("de.dkfz.matchpoint", spUID->getNamespace());
CHECK_EQUAL("TestAlgorithm", spUID->getName());
CHECK_EQUAL("1.0.0", spUID->getVersion());
CHECK_EQUAL("testprofile", testProfile);
spUID = NULL;
testProfile = "";
CHECK_NO_THROW(map::deployment::peekDeploymentDLL(validDLLPath.c_str(), spUID, testProfile));
CHECK(spUID.IsNotNull());
CHECK_EQUAL("de.dkfz.matchpoint", spUID->getNamespace());
CHECK_EQUAL("TestAlgorithm", spUID->getName());
CHECK_EQUAL("1.0.0", spUID->getVersion());
CHECK_EQUAL("testprofile", testProfile);
//skipped testing other errors with peekDeploymentDLL because it just calls openDeploymentDLL and closeDeploymentDLL, which have been tested above
//////////////////////////////////////////////////
// Test: checkNameIsSharedLibrary
::map::core::String noLib = "iAmNoLib.other";
::map::core::String aLib = core::String("iAmALib.") + map::deployment::getDeploymentDLLExtension();
CHECK_THROW(map::deployment::checkNameIsSharedLibrary(NULL));
CHECK(map::deployment::checkNameIsSharedLibrary(aLib.c_str()));
CHECK(! map::deployment::checkNameIsSharedLibrary(noLib.c_str()));
//////////////////////////////////////////////////
// Test: checkFileNameIsMDRACompliant
::map::core::String validMDRA = core::String("mdra");
#if _DEBUG || (__linux__ && !defined(NDEBUG))
validMDRA = validMDRA + "-D";
#endif
::map::core::OStringStream ostr;
ostr << "-" << MAP_VERSION_MAJOR << "-" << MAP_VERSION_MINOR << "_";
::map::core::String versionPart = ostr.str();
::map::core::String invalidMDRA_DFlag = core::String("mdra-B") + versionPart + "MyInvalidDFlagAlgorithm" + map::deployment::getDeploymentDLLExtension();
::map::core::String invalidMDRA_Version = validMDRA + "0-0_" + "MyInvalidVersionAlgorithm" + map::deployment::getDeploymentDLLExtension();
::map::core::String invalidMDRA_Extension = validMDRA + "0-0_" + "MyInvalidExtensionAlgorithm.other";
validMDRA = validMDRA + versionPart + "MyValidAlgorithm" + map::deployment::getDeploymentDLLExtension();
::map::core::String validMDRA_withPath = core::String("./myPath/") + validMDRA;
CHECK_THROW(map::deployment::checkFileNameIsMDRACompliant(NULL));
CHECK(! map::deployment::checkFileNameIsMDRACompliant(aLib.c_str()));
CHECK(! map::deployment::checkFileNameIsMDRACompliant(noLib.c_str()));
CHECK(! map::deployment::checkFileNameIsMDRACompliant(invalidMDRA_DFlag.c_str()));
CHECK(! map::deployment::checkFileNameIsMDRACompliant(invalidMDRA_Version.c_str()));
CHECK(! map::deployment::checkFileNameIsMDRACompliant(invalidMDRA_Extension.c_str()));
CHECK(map::deployment::checkFileNameIsMDRACompliant(validMDRA.c_str()));
CHECK(map::deployment::checkFileNameIsMDRACompliant(validMDRA_withPath.c_str()));
RETURN_AND_REPORT_TEST_SUCCESS;
}
} //namespace testing
} //namespace map
diff --git a/Code/Deployment/test/mapDeploymentDLLConfigTest.cpp b/Code/Deployment/test/mapDeploymentDLLConfigTest.cpp
index f43a9d9..7992048 100644
--- a/Code/Deployment/test/mapDeploymentDLLConfigTest.cpp
+++ b/Code/Deployment/test/mapDeploymentDLLConfigTest.cpp
@@ -1,100 +1,100 @@
// -----------------------------------------------------------------------
// MatchPoint - DKFZ translational registration framework
//
// Copyright (c) German Cancer Research Center (DKFZ),
// Software development for Integrated Diagnostics and Therapy (SIDT).
// ALL RIGHTS RESERVED.
// See mapCopyright.txt or
// http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notices for more information.
//
//------------------------------------------------------------------------
/*!
// @file
// @version $Revision$ (last changed revision)
// @date $Date$ (last change date)
// @author $Author$ (last changed by)
// Subversion HeadURL: $HeadURL$
*/
#include "mapDeploymentDLLAccess.h"
#include "mapLogbook.h"
#include "mapFileDispatch.h"
#include "litCheckMacros.h"
#include "itksys/SystemTools.hxx"
#include "itkDynamicLoader.h"
namespace map
{
namespace testing
{
//defined by mapDeploymentTests.cpp. It is tha path to the current running executable.
//It is needed to bypass the problem that when using MS Visual Studio the actual binary
//path depends of the compile mode (release/debug) and is not the CMake binary path.
extern const char* _callingAppPath;
int mapDeploymentDLLConfigTest(int argc, char* argv[])
{
PREPARE_DEFAULT_TEST_REPORTING;
map::core::String dllPath = itksys::SystemTools::GetProgramPath(_callingAppPath);
map::core::String logPath = dllPath;
if (argc > 1)
{
logPath = argv[1];
}
logPath = map::core::FileDispatch::createFullPath(logPath, "DeploymentSyncTest.log");
if (itksys::SystemTools::FileExists(logPath.c_str(), true))
{
itksys::SystemTools::RemoveFile(logPath.c_str());
}
map::core::Logbook::setDefaultLogFileName(logPath);
map::core::Logbook::fatal("Initialize Log for sync test. Waiting for dll entry...");
//Test open special test dll that should post a special log entryfile in the test log
- deployment::DLLHandle::Pointer spHandle1 = NULL;
+ deployment::DLLHandle::Pointer spHandle1;
std::string validDLLPath = map::core::FileDispatch::createFullPath(dllPath,
map::core::String(itksys::DynamicLoader::LibPrefix()) + "mapTestAlgorithmConfig" + map::deployment::getDeploymentDLLExtension());
spHandle1 = map::deployment::openDeploymentDLL(validDLLPath);
- map::algorithm::RegistrationAlgorithmBase::Pointer spInstance = NULL;
+ map::algorithm::RegistrationAlgorithmBase::Pointer spInstance;
spInstance = map::deployment::getRegistrationAlgorithm(spHandle1);
//now test for the log entry;
map::core::Logbook::flush();
std::ifstream logFile;
logFile.open(logPath.c_str());
map::core::String fileContent;
bool foundDLLTokenInLog = false;
while (!logFile.fail())
{
map::core::String line;
logFile >> line;
fileContent.append(line);
}
logFile.close();
foundDLLTokenInLog = map::core::String::npos != fileContent.find("TestEntryOfTheDll.");
CHECK(foundDLLTokenInLog);
RETURN_AND_REPORT_TEST_SUCCESS;
}
} //namespace testing
} //namespace map
diff --git a/Code/IO/source/mapGenericImageReader.cpp b/Code/IO/source/mapGenericImageReader.cpp
index 53361bf..c412c8c 100644
--- a/Code/IO/source/mapGenericImageReader.cpp
+++ b/Code/IO/source/mapGenericImageReader.cpp
@@ -1,384 +1,384 @@
// -----------------------------------------------------------------------
// MatchPoint - DKFZ translational registration framework
//
// Copyright (c) German Cancer Research Center (DKFZ),
// Software development for Integrated Diagnostics and Therapy (SIDT).
// ALL RIGHTS RESERVED.
// See mapCopyright.txt or
// http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notices for more information.
//
//------------------------------------------------------------------------
/*!
// @file
// @version $Revision$ (last changed revision)
// @date $Date$ (last change date)
// @author $Author$ (last changed by)
// Subversion HeadURL: $HeadURL$
*/
#include "mapGenericImageReader.h"
namespace map
{
namespace io
{
////////////////////////////////////////////////////////////////////////
/// Implementation of map::GenericImageReader ////////////////////////////////
////////////////////////////////////////////////////////////////////////
void
GenericImageReader::
load()
{
_spImage = nullptr;
::map::core::String probeFileName = this->_fileName;
if (this->_seriesReadStyle == ImageSeriesReadStyle::Numeric)
{
using NamesType = ::itk::NumericSeriesFileNames;
NamesType::Pointer names = NamesType::New();
names->SetStartIndex(1);
names->SetEndIndex(1);
names->SetSeriesFormat(this->_fileName.c_str());
probeFileName = names->GetFileNames()[0];
}
::itk::ImageIOBase::Pointer imageIO =
::itk::ImageIOFactory::CreateImageIO(probeFileName.c_str(),
- ::itk::ImageIOFactory::ReadMode);
+ ::itk::IOFileModeEnum::ReadMode);
if (imageIO == nullptr)
{
mapDefaultExceptionMacro( <<
"No ImageIO found for given file. Please check if the file exists and has a supported format. File:"
<< probeFileName);
return;
}
// Now that we found the appropriate ImageIO class, ask it to
// read the meta data from the image file.
imageIO->SetFileName(probeFileName.c_str());
imageIO->ReadImageInformation();
this->_loadedComponentType = imageIO->GetComponentType();
this->_loadedPixelType = imageIO->GetPixelType();
if (this->_loadedPixelType == ::itk::IOPixelEnum::RGB && imageIO->GetNumberOfComponents() == 1)
{
//if only one channel per pixel handle as scalar as long as RGB etc. is not supported
this->_loadedPixelType = ::itk::IOPixelEnum::SCALAR;
}
this->_loadedComponentTypeStr = imageIO->GetComponentTypeAsString(this->_loadedComponentType);
this->_loadedPixelTypeStr = imageIO->GetPixelTypeAsString(this->_loadedPixelType);
this->_loadedDimensions = imageIO->GetNumberOfDimensions();
if (this->_seriesReadStyle == ImageSeriesReadStyle::Numeric &&
this->_loadedDimensions == 2)
{
this->_loadedDimensions = 3; //it is a stack of 2D images -> 3D
}
if (this->_loadedDimensions < 2 || this->_loadedDimensions > 3)
{
mapDefaultExceptionMacro( <<
"The file uses a number of dimensions that is not supported in this application. PixelType: " <<
this->_loadedPixelTypeStr << "; ComponentType: " << this->_loadedComponentTypeStr <<
"; Number of dimension: " << this->_loadedDimensions);
}
switch (_loadedPixelType)
{
case ::itk::IOPixelEnum::SCALAR:
{
if (this->_loadedDimensions == 2)
{
loadScalar<2>();
}
else
{
loadScalar<3>();
}
break;
}
default:
{
mapDefaultExceptionMacro( <<
"The file uses a pixel type that is not supported in this application. PixelType: " <<
this->_loadedPixelTypeStr << "; ComponentType: " << this->_loadedComponentTypeStr <<
"; Number of pixel channels: " << imageIO->GetNumberOfComponents() <<
"; Number of image dimensions: " << this->_loadedDimensions);
}
}
_upToDate = true;
};
template
void
GenericImageReader::
loadScalar()
{
// Use the pixel type to instantiate the appropriate reader
switch (this->_loadedComponentType)
{
case ::itk::IOComponentEnum::UCHAR:
{
this->_spImage = readImage(_fileName, _seriesReadStyle,
false, 0, 0, _upperSeriesLimit, &_dictionaryArray);
break;
}
case ::itk::IOComponentEnum::CHAR:
{
this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0,
_upperSeriesLimit, &_dictionaryArray);
break;
}
case ::itk::IOComponentEnum::USHORT:
{
this->_spImage = readImage(_fileName, _seriesReadStyle,
false, 0, 0, _upperSeriesLimit, &_dictionaryArray);
break;
}
case ::itk::IOComponentEnum::SHORT:
{
this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0,
_upperSeriesLimit, &_dictionaryArray);
break;
}
case ::itk::IOComponentEnum::UINT:
{
this->_spImage = readImage(_fileName, _seriesReadStyle,
false, 0, 0, _upperSeriesLimit, &_dictionaryArray);
break;
}
case ::itk::IOComponentEnum::INT:
{
this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0,
_upperSeriesLimit, &_dictionaryArray);
break;
}
case ::itk::IOComponentEnum::ULONG:
{
this->_spImage = readImage(_fileName, _seriesReadStyle,
false, 0, 0, _upperSeriesLimit, &_dictionaryArray);
break;
}
case ::itk::IOComponentEnum::LONG:
{
this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0,
_upperSeriesLimit, &_dictionaryArray);
break;
}
case ::itk::IOComponentEnum::FLOAT:
{
this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0,
_upperSeriesLimit, &_dictionaryArray);
break;
}
case ::itk::IOComponentEnum::DOUBLE:
{
this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0,
_upperSeriesLimit, &_dictionaryArray);
break;
}
default:
{
mapDefaultExceptionMacro( <<
"The file uses a pixel component type that is not supported in this application. PixelType: " <<
this->_loadedPixelTypeStr << "; ComponentType: " << this->_loadedComponentTypeStr <<
"; Number of dimension: " << this->_loadedDimensions);
}
}
};
//template
//void
// GenericImageReader::
// loadRGB()
//{
// assert(false);
// mapDefaultExceptionStaticMacro(<<"RGB support is yet not implemented.");
// switch( this->_loadedComponentType )
// {
// case ::itk::IOComponentEnum::UCHAR:
// {
// this->_spImage = readImageA< ::itk::RGBPixel, ::itk::RGBPixel, IDimension>(_fileName,_seriesReadStyle);
// break;
// }
// case ::itk::IOComponentEnum::CHAR:
// {
// this->_spImage = readImageA< ::itk::RGBPixel, ::itk::RGBPixel, IDimension>(_fileName,_seriesReadStyle);
// break;
// }
// case ::itk::IOComponentEnum::USHORT:
// {
// this->_spImage = readImageA< ::itk::RGBPixel, ::itk::RGBPixel, IDimension>(_fileName,_seriesReadStyle);
// break;
// }
// case ::itk::IOComponentEnum::SHORT:
// {
// this->_spImage = readImageA< ::itk::RGBPixel, ::itk::RGBPixel, IDimension>(_fileName,_seriesReadStyle);
// break;
// }
// case ::itk::IOComponentEnum::UINT:
// {
// this->_spImage = readImageA< ::itk::RGBPixel, ::itk::RGBPixel, IDimension>(_fileName,_seriesReadStyle);
// break;
// }
// case ::itk::IOComponentEnum::INT:
// {
// this->_spImage = readImageA< ::itk::RGBPixel, ::itk::RGBPixel, IDimension>(_fileName,_seriesReadStyle);
// break;
// }
// case ::itk::IOComponentEnum::ULONG:
// {
// this->_spImage = readImageA< ::itk::RGBPixel, ::itk::RGBPixel, IDimension>(_fileName,_seriesReadStyle);
// break;
// }
// case ::itk::IOComponentEnum::LONG:
// {
// this->_spImage = readImageA< ::itk::RGBPixel, ::itk::RGBPixel, IDimension>(_fileName,_seriesReadStyle);
// break;
// }
// case ::itk::IOComponentEnum::FLOAT:
// {
// this->_spImage = readImageA< ::itk::RGBPixel, ::itk::RGBPixel, IDimension>(_fileName,_seriesReadStyle);
// break;
// }
// case ::itk::IOComponentEnum::DOUBLE:
// {
// this->_spImage = readImageA< ::itk::RGBPixel, ::itk::RGBPixel, IDimension>(_fileName,_seriesReadStyle);
// break;
// }
// default:
// {
// mapDefaultExceptionMacro(<<"The file uses a pixel component type that is not supported in this application. PixelType: "<_loadedPixelTypeStr<<"; ComponentType: "<_loadedComponentTypeStr<<"; Number of dimension: "<_loadedDimensions);
// }
// }
//};
const core::String&
GenericImageReader::
getFileName() const
{
return _fileName;
};
void
GenericImageReader::
setFileName(const core::String& fileName)
{
if (fileName != _fileName)
{
_upToDate = false;
_fileName = fileName;
}
}
unsigned int
GenericImageReader::
getUpperSeriesLimit() const
{
return _upperSeriesLimit;
};
void
GenericImageReader::
setUpperSeriesLimit(const unsigned int upperLimit)
{
if (upperLimit != _upperSeriesLimit)
{
_upToDate = false;
_upperSeriesLimit = upperLimit;
};
};
ImageSeriesReadStyle::Type
GenericImageReader::
getSeriesReadStyle() const
{
return _seriesReadStyle;
};
void
GenericImageReader::
setSeriesReadStyle(ImageSeriesReadStyle::Type readStyle)
{
if (readStyle != _seriesReadStyle)
{
_upToDate = false;
_seriesReadStyle = readStyle;
};
};
GenericImageReader::GenericOutputImageType*
GenericImageReader::
GetOutput(unsigned int& loadedDimensions, LoadedPixelType& loadedPixelType,
LoadedComponentType& loadedComponentType)
{
if (!_upToDate)
{
load();
loadedPixelType = _loadedPixelType;
loadedComponentType = _loadedComponentType;
loadedDimensions = _loadedDimensions;
};
return _spImage;
};
GenericImageReader::
GenericImageReader()
{
_fileName = "";
_upperSeriesLimit = 255;
_upToDate = false;
_seriesReadStyle = ImageSeriesReadStyle::Default;
};
GenericImageReader::
~GenericImageReader()
= default;
const GenericImageReader::MetaDataDictionaryArrayType&
GenericImageReader::
getMetaDictionaryArray()
{
return _dictionaryArray;
};
} // namespace io
} // namespace map