Skip to content

Commit

Permalink
BUG: Use GDCM as private dependency in ITKIOGDCM
Browse files Browse the repository at this point in the history
Make the third partly library a private dependency, for the ITK GDCM
ImageIO modules. This follows best practices of data encapsulation.

Move the implementation of the destructor to the cxx file as a best
practice as it ensure intonation of the vtable in the library.
  • Loading branch information
blowekamp committed Apr 14, 2020
1 parent a476fa9 commit 1759484
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
1 change: 1 addition & 0 deletions Modules/IO/GDCM/ITKKWStyleOverwrite.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
itkGDCMSeriesFileNames\.h Namespace Disable
1 change: 1 addition & 0 deletions Modules/IO/GDCM/ITKWKStyleOverwrite.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
itkGDCMSeriesFileNames\.h Namespace Disable
18 changes: 10 additions & 8 deletions Modules/IO/GDCM/include/itkGDCMSeriesFileNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@
#include "itkObjectFactory.h"
#include "itkMacro.h"
#include <vector>
#include "gdcmSerieHelper.h"
#include "ITKIOGDCMExport.h"

// forward declaration, to remove compile dependency on GDCM library
namespace gdcm
{
class SerieHelper;
}

namespace itk
{
/**
Expand Down Expand Up @@ -162,10 +167,7 @@ class ITKIOGDCM_EXPORT GDCMSeriesFileNames : public ProcessObject
* \warning User need to set SetUseSeriesDetails(true)
*/
void
AddSeriesRestriction(const std::string & tag)
{
m_SerieHelper->AddRestriction(tag);
}
AddSeriesRestriction(const std::string & tag);

/** Parse any sequences in the DICOM file. Defaults to false
* to skip sequences. This makes loading DICOM files faster when
Expand All @@ -184,8 +186,8 @@ class ITKIOGDCM_EXPORT GDCMSeriesFileNames : public ProcessObject
itkBooleanMacro(LoadPrivateTags);

protected:
GDCMSeriesFileNames() = default;
~GDCMSeriesFileNames() override { delete m_SerieHelper; }
GDCMSeriesFileNames();
~GDCMSeriesFileNames() override;
void
PrintSelf(std::ostream & os, Indent indent) const override;

Expand All @@ -201,7 +203,7 @@ class ITKIOGDCM_EXPORT GDCMSeriesFileNames : public ProcessObject
FileNamesContainerType m_OutputFileNames;

/** Internal structure to order serie from one directory */
gdcm::SerieHelper * m_SerieHelper = new gdcm::SerieHelper();
std::unique_ptr<gdcm::SerieHelper> m_SerieHelper;

/** Internal structure to keep the list of series UIDs */
SeriesUIDContainerType m_SeriesUIDs;
Expand Down
3 changes: 2 additions & 1 deletion Modules/IO/GDCM/itk-module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ itk_module(ITKIOGDCM
ENABLE_SHARED
DEPENDS
ITKCommon
ITKGDCM
ITKIOImageBase
PRIVATE_DEPENDS
ITKGDCM
TEST_DEPENDS
ITKTestKernel
ITKGDCM
Expand Down
16 changes: 16 additions & 0 deletions Modules/IO/GDCM/src/itkGDCMSeriesFileNames.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@
#include "itkGDCMSeriesFileNames.h"
#include "itksys/SystemTools.hxx"
#include "itkProgressReporter.h"
#include "gdcmSerieHelper.h"

namespace itk
{


GDCMSeriesFileNames::GDCMSeriesFileNames()
: m_SerieHelper{ new gdcm::SerieHelper() }
{}

GDCMSeriesFileNames::~GDCMSeriesFileNames() = default;


void
GDCMSeriesFileNames::SetInputDirectory(const char * name)
{
Expand All @@ -35,6 +45,12 @@ GDCMSeriesFileNames::SetInputDirectory(const char * name)
this->SetInputDirectory(fname);
}

void
GDCMSeriesFileNames::AddSeriesRestriction(const std::string & tag)
{
m_SerieHelper->AddRestriction(tag);
}

void
GDCMSeriesFileNames::SetInputDirectory(std::string const & name)
{
Expand Down

0 comments on commit 1759484

Please sign in to comment.