[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [IMP-dev] Death to objects



Andrej Sali wrote:
there's got to be a way around that retaining objects? andrej
Well, we can fake it by wrapping the helper functions into a class. To do this: - leave Particles as they are now (with the addition of vector of int attributes and possibly vector of float attributes since I think coordinates should be a vector) - When you what a new particle type, for example a HierarchyParticle you write a class which wraps a Particle*. It can check that the Particle* has the necessary fields to be a HierarchyParticle. It also defines a static method "initialize" which sets up the required fields. - When a user or restraint wants to make a given Particle*, p, into a HierarchyParticle he/she calls HierarchyParticle::initialize(p) which returns a protected pointer (for now auto_ptr) to a HierarchyParticle. The user can then use that HierarchyParticle::Pointer - When a user or restraint wants to use a given Particle as a HierarchyParticle, they then call particle_cast<HierarchyParticle*>(p) to create a wrapper. The name is chosen since if it were a normal object you would have called dynamic_cast<HiearchyParticle*>. This object can then be used as desired. The return value should be ref counted pointer or something to avoid issues with deallocation (anyway, it would be called HierarchyParticle::Pointer). - The HierarchyParticle can keep all its field names internally so they don't even have to be documented. - In python you can simply call HieararchyParticle(p) (you could do that in C++ too).


This is my favorite proposal so far. And now I run.


On Nov 6, 2007, at 5:26 PM, Daniel Russel wrote:

A possible fatal blow for objects came up when talking with Jeremy.

Lets say we load a PDB file. It creates a bunch of Particles, some of
which are AtomParticles, some ResidueParticles etc. Now it happens I am
doing coarse grained modeling, so I only care about the Residues and
want to approximate them by a sphere. I have no way of adding a radius
attribute to the already existing particle. I have to copy the particle
to a new ResidueWithRadiusParticle (and delete the old one) or add a new
particle linked to the existing one. Deleting the old residue would
break all existing restraints which use the particle.


_______________________________________________
IMP-dev mailing list

https://salilab.org/mailman/listinfo/imp-dev

--
Andrej Sali, Ph.D.
Professor and Vice Chair, Department of Biopharmaceutical Sciences
Department of Pharmaceutical Chemistry
California Institute for Quantitative Biosciences
University of California at San Francisco
UCSF MC 2552
Byers Hall Room 503B
1700 4th Street
San Francisco, CA  94158-2330, USA
Tel +1 (415) 514-4227; Fax +1 (415) 514-4231
Assistant, Ms. Karin Asensio, Tel +1 (415)514-4228; Lab +1 (415) 514-4232, 4233, 4258
Email ; Web http://salilab.org