Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Make PrintSelf implementation style consistent #3872

Commits on Feb 5, 2023

  1. STYLE: Make PrintSelf implementation style consistent

    Make `PrintSelf`implementation style consistent following the ITK SWG
    coding style guideline and the available ITK macros:
    - Always print the superclass first.
    - Print only the class instance variables.
    - Use the `os << indent << "{ivarName}: " << m_ivarName << std::endl`
      recipe: do not print the leading `m_` of the ivar; use a colon after
      printing its name; leave a whitespace between the colon and the
      printed value of the ivar.
    - For boolean ivars print `On`/`Off` according to their values using the
      ternary operator.
    - Use `itkPrintSelfObjectMacro` to print objects inheriting from
      `itk::LightObject` that can be null.
    - For pointers that do not inherit from `itk::LightObject` check whether
      they are non-null before attempting to print them and print the
      `(empty)` string otherwise.
    - Rely on the self printing ability of the ITK classes to avoid
      boilerplate code when printing the corresponding ivars in other
      classes' `PrintSelf` methods.
    - Take advantage of the output stream `<<` insertion operator overload
      for `std::vector` types in the `itk::print_helper` namespace defined
      in `itkPrintHelper.h` to print such types consistently.
    - Cast custom types to their numerical values using
      `itk::NumericTraits::PrinType` so that they are printed as expected.
    - Remove statements printing the hard-coded class name and its own
      pointer, e.g.
      ```
      os << indent << "ArrowSpatialObject(" << this << ")" << std::endl;
      ```
      `PrintSelf` does this without requiring the removed line.
    - Save typing `this->` to point to the instance of the current class.
    
    Apply the same principles to the `<<` operator overloads.
    
    Overload the ostream operator for the `FixedImageSamplePoint` class used
    by the `itk::ImageToImageMetric` class.
    
    Overload the ostream operator for the `ImageVoxel` class used by the
    `itk::DeformableSimplexMesh3DGradientConstraintForceFilter` class.
    jhlegarreta committed Feb 5, 2023
    Configuration menu
    Copy the full SHA
    173752f View commit details
    Browse the repository at this point in the history