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

Geometry: Simplify the class hierarchy of ParametrizedComponent and other ParX classes. #2731

Closed
mantid-builder opened this issue Nov 8, 2010 · 1 comment
Milestone

Comments

@mantid-builder
Copy link
Collaborator

Original Reporter: @jzikovsky

Original Owner: @jzikovsky

This is a fairly large refactoring of the Geometry project, with the purpose of simplifying the class hierarchy significantly by folding in Parameterized versions of all the Components into a single class.

'''The design is currently this:'''

  • a Component object holds the position etc. of an instrument's (base) component.
  • For a parametrized instrument, a ParametrizedComponent is created which wraps the original Component with the addition of a const reference to a ParameterMap (m_map), as well as a pointer to the base (un-parametrized) Component (m_base).
    • Every function in Component needs to have the same implemented in ParameterizedComponent.
    • Most functions in ParameterizedComponent simply call m_base->function(...)
    • Only a few require actually different behavior (e.g. getting position).
  • The ParametrizedComponent is created by a factory.

This would not be so bad if there were only Component that needed parametrized version. However, EVERY class in the instrument needs its equivalent Par... version.

This THEN means that there needs to be an IComponent interface to interface between ParametrizedComponent and Component. So for each 1 REAL class, there are 2 MORE classes; triple the complexity!

This is then multiplied by all the classes that have their corresponding ParXXX and IXXX versions:

  • Component
  • Instrument
  • ObjComponent
  • CompAssembly
  • ObjCompAssembly
  • RectangularDetector

'''My proposed design:'''

  • The Component object will be made to act as either a parametrized Component or a base component.
  • The new Component ''can'' have a ''pointer'' to a ParameterMap object (m_map) containing its parameters, as well as a pointer to its base Component (m_base)
    • If it DOES, that means it is a parametrized Component.
    • Functions called on Component will check if it is parametrized, and act accordingly - either call the unparametrized m_base object, or perform the adjustments required by the ParameterMap.
  • The ParComponentFactory still acts the same way - except it returns a new instance of Component with the ParameterMap and base set, instead of a different class.

'''Advantages:'''

  • Two-to-Three-fold reduction in the required number of classes. Some of the interfaces will be kept at least at first; especially IComponent as it is used throughout the code.
    • Maintenance of the code will be that much easier (modify one function instead of 2-3).
    • I believe this will make the design much easier to understand for new developers.

'''Development:'''

  • A separate branch will be created for this development, and kept merged with the running trunk to try to keep things up to date.
@mantid-builder
Copy link
Collaborator Author

This issue was originally trac ticket 1884

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant