Skip to content

allow raw pointers in Stores #11

@marc1uk

Description

@marc1uk

Passing pointers to objects between tools is something I find myself wanting to do fairly often, but neither the Store nor BoostStore classes allow you to do so, at least without surrendering ownership of the object, or smuggling it in an intptr_t.

With the current BoostStore behaviour, if you re-invoke 'Set' with the same key, the previously pointed-to object gets deleted. If you're not expecting that, (and I'm not sure I would call this 'intuitive behaviour') that could be a nightmare to track down.
In addition, when the BoostStore is deleted, the pointed-to objects get deleted. What if your pointer was to an object on the stack? oh dear. Segfault.

In particular that last one - sharing stack allocated objects, such as Tool member variables - is really convenient.
It allows downstream tools to access variables without duplication, and without the need to use heap memory. The ToolDAQFramework ensures that no user code is invoked after any Tools are destroyed, so variables don't go out of scope while still in use.

Perhaps adding an 'unmanaged' argument that defaults to false or something, so that users can pass raw pointer between tools?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions