Loading...
Searching...
No Matches
elxConfiguration.h
Go to the documentation of this file.
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef elxConfiguration_h
#define elxConfiguration_h
#include "itkObject.h"
#include "elxBaseComponent.h"
#include "itkParameterFileParser.h"
#include "itkParameterMapInterface.h"
#include <map>
#include "elxlog.h"
namespace elastix
{
class Configuration
: public itk::Object
, public BaseComponent
{
public:
ITK_DISALLOW_COPY_AND_MOVE(Configuration);
using Self = Configuration;
using Superclass1 = itk::Object;
using Superclass2 = BaseComponent;
using Pointer = itk::SmartPointer<Self>;
using ConstPointer = itk::SmartPointer<const Self>;
itkNewMacro(Self);
itkTypeMacro(Configuration, itk::Object);
using CommandLineArgumentMapType = std::map<std::string, std::string>;
using CommandLineEntryType = CommandLineArgumentMapType::value_type;
std::string
GetCommandLineArgument(const std::string & key) const;
void
SetCommandLineArgument(const std::string & key, const std::string & value);
itkGetStringMacro(ParameterFileName);
itkSetStringMacro(ParameterFileName);
int
Initialize(const CommandLineArgumentMapType & _arg);
int
Initialize(const CommandLineArgumentMapType & _arg, const itk::ParameterFileParser::ParameterMapType & inputMap);
bool
IsInitialized() const; // to elxconfigurationbase
itkSetMacro(ElastixLevel, unsigned int);
itkGetConstMacro(ElastixLevel, unsigned int);
itkSetMacro(TotalNumberOfElastixLevels, unsigned int);
itkGetConstMacro(TotalNumberOfElastixLevels, unsigned int);
/***/
bool
GetPrintErrorMessages() const
{
return m_ParameterMapInterface->GetPrintErrorMessages();
}
int
BeforeAll() override;
int
BeforeAllTransformix();
std::size_t
CountNumberOfParameterEntries(const std::string & parameterName) const
{
return m_ParameterMapInterface->CountNumberOfParameterEntries(parameterName);
}
template <class T>
bool
ReadParameter(T & parameterValue,
const std::string & parameterName,
const unsigned int entry_nr,
const bool produceWarningMessage) const
{
std::string warningMessage = "";
bool found = m_ParameterMapInterface->ReadParameter(
parameterValue, parameterName, entry_nr, produceWarningMessage, warningMessage);
if (!warningMessage.empty())
{
log::warn(warningMessage);
}
return found;
}
template <class T>
bool
ReadParameter(T & parameterValue, const std::string & parameterName, const unsigned int entry_nr) const
{
std::string warningMessage = "";
bool found = m_ParameterMapInterface->ReadParameter(parameterValue, parameterName, entry_nr, warningMessage);
if (!warningMessage.empty())
{
log::warn(warningMessage);
}
return found;
}
template <class T>
bool
ReadParameter(T & parameterValue,
const std::string & parameterName,
const std::string & prefix,
const unsigned int entry_nr,
const int default_entry_nr,
const bool produceWarningMessage) const
{
std::string warningMessage = "";
bool found = m_ParameterMapInterface->ReadParameter(
parameterValue, parameterName, prefix, entry_nr, default_entry_nr, produceWarningMessage, warningMessage);
if (!warningMessage.empty())
{
log::warn(warningMessage);
}
return found;
}
template <class T>
bool
ReadParameter(T & parameterValue,
const std::string & parameterName,
const std::string & prefix,
const unsigned int entry_nr,
const int default_entry_nr) const
{
std::string warningMessage = "";
bool found = m_ParameterMapInterface->ReadParameter(
parameterValue, parameterName, prefix, entry_nr, default_entry_nr, warningMessage);
if (!warningMessage.empty())
{
log::warn(warningMessage);
}
return found;
}
bool
HasParameter(const std::string & parameterName) const
{
return m_ParameterMapInterface->HasParameter(parameterName);
}
std::vector<std::string>
GetValuesOfParameter(const std::string & parameterName) const
{
return m_ParameterMapInterface->GetValues(parameterName);
}
template <typename T>
std::unique_ptr<std::vector<T>>
RetrieveValuesOfParameter(const std::string & parameterName) const
{
return m_ParameterMapInterface->RetrieveValues<T>(parameterName);
}
template <typename T>
T
RetrieveParameterValue(const T & defaultParameterValue,
const std::string & parameterName,
const unsigned int entry_nr,
const bool produceWarningMessage) const
{
auto parameterValue = defaultParameterValue;
(void)Self::ReadParameter<T>(parameterValue, parameterName, entry_nr, produceWarningMessage);
return parameterValue;
}
std::string
RetrieveParameterStringValue(const std::string & defaultParameterValue,
const std::string & parameterName,
const unsigned int entry_nr,
const bool produceWarningMessage) const
{
return Self::RetrieveParameterValue(defaultParameterValue, parameterName, entry_nr, produceWarningMessage);
}
template <class T>
bool
ReadParameter(std::vector<T> & parameterValues,
const std::string & parameterName,
const unsigned int entry_nr_start,
const unsigned int entry_nr_end,
const bool produceWarningMessage) const
{
std::string warningMessage = "";
bool found = m_ParameterMapInterface->ReadParameter(
parameterValues, parameterName, entry_nr_start, entry_nr_end, produceWarningMessage, warningMessage);
if (!warningMessage.empty())
{
log::warn(warningMessage);
}
return found;
}
protected:
Configuration();
~Configuration() override = default;
void
PrintParameterFile() const;
private:
CommandLineArgumentMapType m_CommandLineArgumentMap{};
std::string m_ParameterFileName{};
const itk::ParameterFileParser::Pointer m_ParameterFileParser{ itk::ParameterFileParser::New() };
const itk::ParameterMapInterface::Pointer m_ParameterMapInterface{ itk::ParameterMapInterface::New() };
bool m_IsInitialized{ false };
unsigned int m_ElastixLevel{ 0 };
unsigned int m_TotalNumberOfElastixLevels{ 1 };
};
} // end namespace elastix
#endif // end #ifndef elxConfiguration_h
elastix::BaseComponent::BaseComponent
BaseComponent()=default
elastix::Configuration::SetCommandLineArgument
void SetCommandLineArgument(const std::string &key, const std::string &value)
elastix::Configuration::RetrieveParameterStringValue
std::string RetrieveParameterStringValue(const std::string &defaultParameterValue, const std::string &parameterName, const unsigned int entry_nr, const bool produceWarningMessage) const
Definition elxConfiguration.h:272
elastix::Configuration::ReadParameter
bool ReadParameter(T &parameterValue, const std::string &parameterName, const std::string &prefix, const unsigned int entry_nr, const int default_entry_nr) const
Definition elxConfiguration.h:208
elastix::Configuration::ITK_DISALLOW_COPY_AND_MOVE
ITK_DISALLOW_COPY_AND_MOVE(Configuration)
elastix::Configuration::Self
Configuration Self
Definition elxConfiguration.h:58
elastix::Configuration::CommandLineArgumentMapType
std::map< std::string, std::string > CommandLineArgumentMapType
Definition elxConfiguration.h:71
elastix::Configuration::Pointer
itk::SmartPointer< Self > Pointer
Definition elxConfiguration.h:61
elastix::Configuration::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition elxConfiguration.h:62
elastix::Configuration::GetValuesOfParameter
std::vector< std::string > GetValuesOfParameter(const std::string &parameterName) const
Definition elxConfiguration.h:236
elastix::Configuration::ReadParameter
bool ReadParameter(T &parameterValue, const std::string &parameterName, const unsigned int entry_nr, const bool produceWarningMessage) const
Definition elxConfiguration.h:150
elastix::Configuration::Initialize
int Initialize(const CommandLineArgumentMapType &_arg)
elastix::Configuration::Initialize
int Initialize(const CommandLineArgumentMapType &_arg, const itk::ParameterFileParser::ParameterMapType &inputMap)
elastix::Configuration::ReadParameter
bool ReadParameter(std::vector< T > &parameterValues, const std::string &parameterName, const unsigned int entry_nr_start, const unsigned int entry_nr_end, const bool produceWarningMessage) const
Definition elxConfiguration.h:284
elastix::Configuration::GetPrintErrorMessages
bool GetPrintErrorMessages() const
Definition elxConfiguration.h:114
elastix::Configuration::RetrieveValuesOfParameter
std::unique_ptr< std::vector< T > > RetrieveValuesOfParameter(const std::string &parameterName) const
Definition elxConfiguration.h:249
elastix::Configuration::ReadParameter
bool ReadParameter(T &parameterValue, const std::string &parameterName, const unsigned int entry_nr) const
Definition elxConfiguration.h:170
elastix::Configuration::m_ParameterFileName
std::string m_ParameterFileName
Definition elxConfiguration.h:315
elastix::Configuration::CountNumberOfParameterEntries
std::vcl_size_t CountNumberOfParameterEntries(const std::string &parameterName) const
Definition elxConfiguration.h:141
elastix::Configuration::ReadParameter
bool ReadParameter(T &parameterValue, const std::string &parameterName, const std::string &prefix, const unsigned int entry_nr, const int default_entry_nr, const bool produceWarningMessage) const
Definition elxConfiguration.h:186
elastix::Configuration::BeforeAll
int BeforeAll() override
elastix::Configuration::Superclass2
BaseComponent Superclass2
Definition elxConfiguration.h:60
elastix::Configuration::HasParameter
bool HasParameter(const std::string &parameterName) const
Definition elxConfiguration.h:228
elastix::Configuration::m_TotalNumberOfElastixLevels
unsigned int m_TotalNumberOfElastixLevels
Definition elxConfiguration.h:321
elastix::Configuration::m_ParameterFileParser
const itk::ParameterFileParser::Pointer m_ParameterFileParser
Definition elxConfiguration.h:316
elastix::Configuration::RetrieveParameterValue
T RetrieveParameterValue(const T &defaultParameterValue, const std::string &parameterName, const unsigned int entry_nr, const bool produceWarningMessage) const
Definition elxConfiguration.h:258
elastix::Configuration::Superclass1
itk::Object Superclass1
Definition elxConfiguration.h:59
elastix::Configuration::m_IsInitialized
bool m_IsInitialized
Definition elxConfiguration.h:319
elastix::Configuration::IsInitialized
bool IsInitialized() const
elastix::Configuration::BeforeAllTransformix
int BeforeAllTransformix()
elastix::Configuration::m_ElastixLevel
unsigned int m_ElastixLevel
Definition elxConfiguration.h:320
elastix::Configuration::PrintParameterFile
void PrintParameterFile() const
elastix::Configuration::Configuration
Configuration()
elastix::Configuration::m_CommandLineArgumentMap
CommandLineArgumentMapType m_CommandLineArgumentMap
Definition elxConfiguration.h:314
elastix::Configuration::CommandLineEntryType
CommandLineArgumentMapType::value_type CommandLineEntryType
Definition elxConfiguration.h:72
elastix::Configuration::~Configuration
~Configuration() override=default
elastix::Configuration::m_ParameterMapInterface
const itk::ParameterMapInterface::Pointer m_ParameterMapInterface
Definition elxConfiguration.h:317
elastix::Configuration::GetCommandLineArgument
std::string GetCommandLineArgument(const std::string &key) const
elastix::log::level::warn
@ warn
Definition elxlog.h:37
itk::ParameterFileParser::ParameterMapType
std::map< std::string, ParameterValuesType > ParameterMapType
Definition itkParameterFileParser.h:97
itk::ParameterFileParser::New
static Pointer New()
itk::ParameterFileParser::Pointer
SmartPointer< Self > Pointer
Definition itkParameterFileParser.h:86
itk::ParameterMapInterface::New
static Pointer New()
itk::ParameterMapInterface::Pointer
SmartPointer< Self > Pointer
Definition itkParameterMapInterface.h:86
elxBaseComponent.h
elxlog.h
itkParameterFileParser.h
itkParameterMapInterface.h
elastix
Definition elxDefaultConstruct.h:25

Generated on 1768596610 for elastix by 1.15.0 |