ComponentParameter move from const ptr* to unique_ptr
The main change is
typedef std::pair<std::unique_ptr<Trk::TrackParameters>, double> SimpleComponentParameters;
typedef std::vector<SimpleComponentParameters> SimpleMultiComponentState;
/**
* Component parameter typedef
*/
typedef std::pair<const TrackParameters*, double> ComponentParameters;//Needed by MultiComponentState
} // end Trk namespace
to
typedef std::pair<std::unique_ptr<Trk::TrackParameters>,double> ComponentParameters;
The rest somehow follow from this ... Although there are naturally many places where this enters.
-
@amorley with this change we do not need to have
Simple
versions for the unique_ptr semantics and this can helps us simplify the ownership chain quite a bit. We can know there is a "unique" owner of non-const things and ownership can be passed via from -> to functions accepting/returning these etc. -
Perhaps we can do one or two
final
rounds on reducingcloning
(i.e we can modify the payload when ownership is passed) and moving a bit more things tounique_ptr
or evenby-value
(e.g return statements) -
For the reviewer , some places are still far from ideal in how they manage things. Especially at the later stages where one communicates with EDM like objects that need / take ownership. I have been trying to use
const ptr*
to mark these cases. Also there is a bit ofrelease
-ing to them . This is seen more in theSmoother
andfitter
rather in the intermediate steps / calculation where ownership is clear .
On a side note
if (statesToMerge.size() <= m_maximumNumberOfComponents) {
ATH_MSG_VERBOSE("State is already sufficiently small... no component reduction required");
MultiComponentStateAssembler::addMultiState( cache, std::move(statesToMerge) );
return MultiComponentStateAssembler::assembledState(cache);
}
if (statesToMerge.empty()) {
ATH_MSG_ERROR("Attempting to merge multi-state with zero components");
return nullptr;
}
the 2nd check was practically doing nothing as if empty the size is already prb < a value greater than 0... Removed it for now ....