Following my proposal for share containers for particles, I have checked in a set of containers, restraints and score states which allow sets of particles to be shared between different objects. There are versions for Particles and pairs of Particles and there will be version for triplets as soon as Ben checks in the patch to the kernel. All the code is generated from common templates, so supporting different types is easy.
The general idea is that you create an appropriate container of particles: say you just have a list of particles, then you create a ListSingletonContainer and put your particles in there. If you want to create a restraint by applying a score to each singleton, you create a SingletonsRestraint and pass the score and the container to the Restraint. If you want to find the close pairs, you create a ClosePairsScoreState and pass it your container. It fills a PairsContainer with all close pairs. You pass that pairs container to a PairsRestraint (just like if you made a ListPairsContainer yourself). Since the container is shared, when the ClosePairsScoreState updates its contents, the PairsRestraint will get the new contents.
We also have a new set of base classes called Modifiers which change a particle (or pair of particles) in some way. These can be coupled with a PairsScoreState, for example, to apply the modifier to all of the pairs each time evaluate is called. This provides a way of enforcing hard symmetry constraints (by making one Particle a transformed version of another).
Containers can be joined to make another container: i.e. a SingletonContainerSet is a SingletonContainer (just like the ListSingletonContainer above) that contains all the particles container in several SingletonContainers.
My intent is to gradually move away from the following classes as their functionality is duplicated in a more flexible way by the new classes using less code: NonbondedRestraint BondedListScoreState SingletonListRestraint PairListRestraint MaxChangeScoreState PairChainRestraint BipartititeNBL AllNBL BondDecoratorListScoreState TripletChainRestraint PairChainRestraint BondDecoratorListRestraint
Any comments would be appreciated.
A list of the new classes can be found at http://salilab.org/~drussel/imp/group__restraint.html