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

Re: [IMP-dev] pointers and copy constructors / assignment operators



On 4/14/16 4:39 AM, Samuel Hanot wrote:
I know if I was writing standard c++ that's what i'd have to do, but I
admit that I am a bit lost when it comes to IMP due to the entanglement
with python and automatic memory management.

Don't use raw Restraint* to store things in your class. Use IMP::Pointer<Restraint> or IMP::PointerMember<Restraint> (the latter also sets the ownership flag), just like is done for anything else that inherits from IMP::Object. They will handle the necessary reference counting to ensure that your objects stay alive. I'm not sure what you mean by "entanglement with python and automatic memory management" but IMP::Pointer is a pretty simple implementation of a reference counting intrusive smart pointer.

	Ben
--
                      https://salilab.org/~ben/
"It is a capital mistake to theorize before one has data."
	- Sir Arthur Conan Doyle