Archived

This forum has been archived. Please start a new discussion on GitHub.

Puzzle on smart pointer

I try to write a GUIExplorer for the distributed file system which is descriped in the document.

I use MFC CTreeCtrl to show the structure, and want to store Pxy in the tree node via SetItemData function, but that require object to be in heap, so data in the tree node could be the pointer to that object, but I found it cannot work because all Pxy object is just like in the stack, so how could I store it ? Another question is if I use evictor on the server side, and for a long time, the object may be evicted on the server, but if I try to use the Pxy made early, does there be some problem?

Another way is to store the UUID of object in the tree node by store a pointer to a std::string, but the shortcoming is each time I use the object, it should begin with locator from the very beginning, seem not a good idea.

Can any body help me? Thanks a lot!

Eric.

Comments

  • I'm not an MFC programmer but, from looking at the MSDN documentation for CTreeCtrl, I would create a table that holds your proxies (so the proxies that are pointed at by the tree items won't go out of scope). Then insert pointers to the proxies in the table into the CTreeCtrl.

    Cheers,

    Michi.