[Insight-developers] class variables for default values
Ziv Yaniv
zivy at isis.georgetown.edu
Mon May 2 16:08:55 EDT 2011
Hi all,
I have a stylistic/technical question:
Is it an explicit decision in ITK to not have default values for
instance variables shared at the class level (static const)?
My rational for having them, explicitly state that all instances share
the same defaults and expose all of them to the user - in ITK this is
implicit with numbers specified in the default constructor.
Example:
desired style (h):
-----------------------
class ITKNumerics_EXPORT MyOptimizer : public
SingleValuedNonLinearOptimizer
{
public:
itkSetMacro( MaximalNumberOfIterations, unsigned int )
itkGetMacro( MaximalNumberOfIterations, unsigned int )
static const unsigned int DEFAULT_MAXIMAL_NUMBER_OF_ITERATIONS;
private:
unsigned int m_MaximalNumberOfIterations;
};
ITK style (h):
------------------
class ITKNumerics_EXPORT MyOptimizer : public
SingleValuedNonLinearOptimizer
{
public:
itkSetMacro( MaximalNumberOfIterations, unsigned int )
itkGetMacro( MaximalNumberOfIterations, unsigned int )
private:
unsigned int m_MaximalNumberOfIterations;
};
--------------------------------------------------------------------------------------
desired style (cxx):
------------------------
const unsigned int MyOptimizer::DEFAULT_MAXIMAL_NUMBER_OF_ITERATIONS = 200;
MyOptimizer
::MyOptimizer(void) :
{
m_MaximalNumberOfIterations = DEFAULT_MAXIMAL_NUMBER_OF_ITERATIONS;
}
ITK style (cxx):
-------------------
MyOptimizer
::MyOptimizer(void) :
{
m_MaximalNumberOfIterations = 200;
}
thanks
Ziv
--
Ziv Yaniv, PhD., Research Assistant Professor
Imaging Science and Information Systems (ISIS) Center
Department of Radiology
Georgetown University Medical Center
2115 Wisconsin Avenue, Suite 603
Washington, DC, 20007,
Phone: +1-202-6877286
Fax: +1-202-784-3479
email: zivy at isis.georgetown.edu
web: http://isiswiki.georgetown.edu/zivy/
More information about the Insight-developers
mailing list