Commit 9974b898 authored by Antoine Regimbeau's avatar Antoine Regimbeau

REFAC: removing function and code modernization

parent 188bc185
......@@ -130,7 +130,7 @@ public:
protected:
ModelComponentBase();
~ModelComponentBase() override {}
~ModelComponentBase() override = default;
void PrintSelf(std::ostream& os, itk::Indent indent) const override;
virtual void GenerateData();
......
......@@ -48,7 +48,7 @@ public:
typedef uint64_t DurationType;
/** Constructs a timer instance */
Stopwatch();
Stopwatch() = default;
/** Start the timer if not already running */
void Start();
......
......@@ -32,7 +32,7 @@
namespace otb
{
/** \class System
/** \namespace System
* \brief System operations.
*
* System operations, filename or strings manipulations, etc.
......@@ -40,27 +40,22 @@ namespace otb
*
* \ingroup OTBCommon
*/
class OTBCommon_EXPORT System
namespace System OTBCommon_EXPORT
{
public:
/** Standard class typedefs. */
typedef System Self;
/** Get the root name */
static std::string GetRootName(const std::string& filename);
std::string GetRootName(const std::string& filename);
/** Get list of file find in a directory */
static std::vector<std::string> Readdir(const std::string& pszPath);
std::vector<std::string> Readdir(const std::string& pszPath);
/** Parse the hdf subset name */
static bool ParseHdfSubsetName(const std::string& id, std::string& key, std::string& name);
bool ParseHdfSubsetName(const std::string& id, std::string& key, std::string& name);
/** Parse a filename with dataset information */
static bool ParseHdfFileName(const std::string& id, std::string& file, unsigned int& datasetNum);
bool ParseHdfFileName(const std::string& id, std::string& file, unsigned int& datasetNum);
/** Parse a filename with additional information */
static bool ParseFileNameForAdditionalInfo(const std::string& id, std::string& file, unsigned int& addNum);
bool ParseFileNameForAdditionalInfo(const std::string& id, std::string& file, unsigned int& addNum);
};
} // namespace otb
......
......@@ -57,8 +57,8 @@ public:
itkTypeMacro(UnaryFunctorImageFilter, itk::UnaryFunctorImageFilter);
protected:
UnaryFunctorImageFilter() {};
~UnaryFunctorImageFilter() override {}
UnaryFunctorImageFilter() = default;
~UnaryFunctorImageFilter() override = default;
/** UnaryFunctorImageFilter can produce an image which has a different number of bands
* than its input image. As such, UnaryFunctorImageFilter
......
......@@ -108,7 +108,7 @@ public:
protected:
UnaryFunctorNeighborhoodVectorImageFilter();
~UnaryFunctorNeighborhoodVectorImageFilter() override { }
~UnaryFunctorNeighborhoodVectorImageFilter() override = default;
/** UnaryFunctorNeighborhoodVectorImageFilter can be implemented as a multithreaded filter.
* Therefore, this implementation provides a ThreadedGenerateData() routine
......@@ -123,12 +123,13 @@ protected:
void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
itk::ThreadIdType threadId) override;
/**
* Since the number of components per pixel depends on the radius range, one must reimplement
* this method to set the proper number of component on the filter output.
*/
void GenerateOutputInformation(void) override;
///**
// * Since the number of components per pixel depends on the radius range, one must reimplement
// * this method to set the proper number of component on the filter output.
// */
// void GenerateOutputInformation(void) override;
// No need as ProcessObject is calling ouput->CopyInformation(input);
RadiusType m_Radius;
private:
......
......@@ -36,24 +36,8 @@ template <class TInputImage, class TOutputImage, class TFunction>
UnaryFunctorNeighborhoodVectorImageFilter<TInputImage, TOutputImage, TFunction>
::UnaryFunctorNeighborhoodVectorImageFilter()
{
this->SetNumberOfRequiredInputs(1);
this->InPlaceOff();
for ( unsigned int i = 0; i < InputImageDimension; ++i )
m_Radius[i] = 3;
}
/**
* Generate the output information
*/
template <class TInputImage, class TOutputImage, class TFunction>
void
UnaryFunctorNeighborhoodVectorImageFilter<TInputImage, TOutputImage, TFunction>
::GenerateOutputInformation(void)
{
Superclass::GenerateOutputInformation();
this->GetOutput()->SetNumberOfComponentsPerPixel(
this->GetInput()->GetNumberOfComponentsPerPixel() );
m_Radius.Fill(3);
}
/**
......
......@@ -93,7 +93,7 @@ public:
protected:
UnaryFunctorVectorImageFilter();
~UnaryFunctorVectorImageFilter() override { }
~UnaryFunctorVectorImageFilter() override = default;
/** UnaryFunctorVectorImageFilter can be implemented as a multithreaded filter.
* Therefore, this implementation provides a ThreadedGenerateData() routine
......@@ -108,11 +108,12 @@ protected:
void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
itk::ThreadIdType threadId) override;
/**
* Since the number of components per pixel depends on the radius range, one must reimplement
* this method to set the proper number of component on the filter output.
*/
void GenerateOutputInformation(void) override;
///**
// * Since the number of components per pixel depends on the radius range, one must reimplement
// * this method to set the proper number of component on the filter output.
// */
// void GenerateOutputInformation(void) override;
// No need as ProcessObject is calling ouput->CopyInformation(input);
private:
UnaryFunctorVectorImageFilter(const Self &) = delete;
......
......@@ -35,24 +35,9 @@ template <class TInputImage, class TOutputImage, class TFunction>
UnaryFunctorVectorImageFilter<TInputImage, TOutputImage, TFunction>
::UnaryFunctorVectorImageFilter()
{
this->SetNumberOfRequiredInputs(1);
this->InPlaceOff();
}
/**
* Generate the output information
*/
template <class TInputImage, class TOutputImage, class TFunction>
void
UnaryFunctorVectorImageFilter<TInputImage, TOutputImage, TFunction>
::GenerateOutputInformation(void)
{
Superclass::GenerateOutputInformation();
this->GetOutput()->SetNumberOfComponentsPerPixel(
this->GetInput()->GetNumberOfComponentsPerPixel() );
}
/**
* ThreadedGenerateData Performs the neighborhood-wise operation
*/
......
......@@ -107,11 +107,11 @@ protected:
/**
* Constructor
*/
UnaryFunctorWithIndexWithOutputSizeImageFilter();
UnaryFunctorWithIndexWithOutputSizeImageFilter() = default;
/**
* Destructor
*/
~UnaryFunctorWithIndexWithOutputSizeImageFilter() override {}
~UnaryFunctorWithIndexWithOutputSizeImageFilter() override = default;
/** UnaryFunctorWithIndexWithOutputSizeImageFilter can be implemented as a multithreaded filter.
* Therefore, this implementation provides a ThreadedGenerateData() routine
......
......@@ -27,15 +27,6 @@
namespace otb
{
/**
* Constructor
*/
template <class TInputImage, class TOutputImage, class TFunction>
UnaryFunctorWithIndexWithOutputSizeImageFilter<TInputImage, TOutputImage, TFunction>
::UnaryFunctorWithIndexWithOutputSizeImageFilter()
{
this->SetNumberOfRequiredInputs(1);
}
template <class TInputImage, class TOutputImage, class TFunction>
void
UnaryFunctorWithIndexWithOutputSizeImageFilter<TInputImage, TOutputImage, TFunction>
......
......@@ -43,7 +43,7 @@ class ITK_EXPORT UniformAlphaBlendingFunctor
{
public:
UniformAlphaBlendingFunctor(): m_Alpha(0.5) {}
~UniformAlphaBlendingFunctor(){}
~UniformAlphaBlendingFunctor() = default;
typedef TInputPixel InputPixelType;
typedef TInputPixel2 InputPixel2Type;
......@@ -60,7 +60,7 @@ public:
return m_Alpha;
}
inline OutputPixelType operator ()(InputPixelType input1, InputPixel2Type input2) const
OutputPixelType operator ()(InputPixelType input1, InputPixel2Type input2) const
{
OutputPixelType resp;
resp.Fill(itk::NumericTraits<OutputInternalPixelType>::max());
......
......@@ -72,8 +72,8 @@ public:
}
protected:
VariableLengthVectorConverter(){}
~VariableLengthVectorConverter() override{}
VariableLengthVectorConverter() = default;
~VariableLengthVectorConverter() override = default;
void PrintSelf(std::ostream& os, itk::Indent indent) const override
{
Superclass::PrintSelf(os, indent);
......@@ -115,8 +115,8 @@ public:
}
protected:
VariableLengthVectorConverter(){}
~VariableLengthVectorConverter() override{}
VariableLengthVectorConverter() = default;
~VariableLengthVectorConverter() override = default;
void PrintSelf(std::ostream& os, itk::Indent indent) const override
{
Superclass::PrintSelf(os, indent);
......@@ -156,8 +156,8 @@ public:
OutputType Convert(InputType input);
protected:
VariableLengthVectorConverter(){}
~VariableLengthVectorConverter() override{}
VariableLengthVectorConverter() = default;
~VariableLengthVectorConverter() override = default;
void PrintSelf(std::ostream& os, itk::Indent indent) const override
{
Superclass::PrintSelf(os, indent);
......@@ -197,8 +197,8 @@ public:
OutputType Convert(InputType input);
protected:
VariableLengthVectorConverter(){}
~VariableLengthVectorConverter() override{}
VariableLengthVectorConverter() = default;
~VariableLengthVectorConverter() override = default;
void PrintSelf(std::ostream& os, itk::Indent indent) const override
{
Superclass::PrintSelf(os, indent);
......@@ -238,8 +238,8 @@ public:
OutputType Convert(InputType input);
protected:
VariableLengthVectorConverter(){}
~VariableLengthVectorConverter() override{}
VariableLengthVectorConverter() = default;
~VariableLengthVectorConverter() override = default;
void PrintSelf(std::ostream& os, itk::Indent indent) const override
{
Superclass::PrintSelf(os, indent);
......@@ -278,8 +278,8 @@ public:
OutputType Convert(InputType input);
protected:
VariableLengthVectorConverter(){}
~VariableLengthVectorConverter() override{}
VariableLengthVectorConverter() = default;
~VariableLengthVectorConverter() override = default;
void PrintSelf(std::ostream& os, itk::Indent indent) const override
{
Superclass::PrintSelf(os, indent);
......
......@@ -65,8 +65,8 @@ public:
typedef typename Superclass::PixelContainerConstPointer PixelContainerConstPointer;
protected:
VectorImageToASImageAdaptor() {}
~VectorImageToASImageAdaptor() override {}
VectorImageToASImageAdaptor() = default;
~VectorImageToASImageAdaptor() override = default;
private:
VectorImageToASImageAdaptor(const Self &) = delete;
......
......@@ -26,13 +26,6 @@
namespace otb
{
Stopwatch
::Stopwatch()
: m_StartTime(), m_ElapsedMilliseconds(), m_IsRunning()
{
}
void
Stopwatch
::Start()
......@@ -91,9 +84,9 @@ Stopwatch
auto result = this->GetElapsedMilliseconds();
DurationType seconds = result / 1000;
DurationType hours = seconds / 3600;
seconds -= hours * 3600;
seconds %= 3600;
DurationType minutes = seconds / 60;
seconds -= minutes * 60;
seconds %= 60;
std::ostringstream os;
if (hours > 0)
oss << hours << "h " << std::setfill('0') << std::setw(2);
......
......@@ -44,9 +44,10 @@
namespace otb
{
namespace System
{
//GetRootName from uiig library.
std::string
System::GetRootName(const std::string& filename)
std::string GetRootName(const std::string& filename)
{
const std::string fileExt = itksys::SystemTools::GetFilenameLastExtension(filename);
......@@ -69,7 +70,7 @@ System::GetRootName(const std::string& filename)
WIN32 / MSVC++ implementation
*====================================================================*/
std::vector<std::string> System::Readdir(const std::string& pszPath)
std::vector<std::string> Readdir(const std::string& pszPath)
{
struct _finddata_t c_file;
long hFile;
......@@ -117,7 +118,7 @@ std::vector<std::string> System::Readdir(const std::string& pszPath)
* doesn't exist.
*/
std::vector<std::string> System::Readdir(const std::string& pszPath)
std::vector<std::string> Readdir(const std::string& pszPath)
{
DIR * hDir;
std::vector<std::string> listFileFind;
......@@ -146,7 +147,7 @@ std::vector<std::string> System::Readdir(const std::string& pszPath)
* it will set key to SUBDATASET_7_NAME
* and name to HDF4_EOS:EOS_GRID:"file/MOD13Q1.A2010001.h17v05.005.2010028003734.hdf":MODIS_Grid_16DAY...
*/
bool System::ParseHdfSubsetName(const std::string& id, std::string& key, std::string& name)
bool ParseHdfSubsetName(const std::string& id, std::string& key, std::string& name)
{
std::size_t pos = id.find("=");
if (pos == std::string::npos) return false;
......@@ -160,7 +161,7 @@ bool System::ParseHdfSubsetName(const std::string& id, std::string& key, std::st
* it will return filelocation/file.hdf in file
* and 10 in datasetNum
*/
bool System::ParseHdfFileName(const std::string& id, std::string& file, unsigned int& datasetNum)
bool ParseHdfFileName(const std::string& id, std::string& file, unsigned int& datasetNum)
{
std::size_t pos = id.rfind(":");
if (pos == std::string::npos) return false;
......@@ -183,7 +184,7 @@ bool System::ParseHdfFileName(const std::string& id, std::string& file, unsigned
* it will return filelocation/file.*** in file
* and 10 in addNum additional
*/
bool System::ParseFileNameForAdditionalInfo(const std::string& id, std::string& file, unsigned int& addNum)
bool ParseFileNameForAdditionalInfo(const std::string& id, std::string& file, unsigned int& addNum)
{
std::size_t pos = id.rfind(":");
if (pos == std::string::npos) return false;
......@@ -202,4 +203,5 @@ bool System::ParseFileNameForAdditionalInfo(const std::string& id, std::string&
return true;
}
}
} // end namespace system
} // end namespace otb
......@@ -31,12 +31,6 @@ int otbSystemTest(int itkNotUsed(argc), char * argv[])
const char * inputDirName = argv[2];
std::ostringstream msg;
// Check instantiation test
otb::System * var(nullptr);
var = new otb::System();
delete var;
var = nullptr;
if (itksys::SystemTools::FileExists(inputFileName, true) == false)
{
itkGenericExceptionMacro(<< "itksys::SystemTools::FileExists() error : the filename " << inputFileName << " is not detected.");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment