1

I need to develop a library where I need to track list of objects dependent on another object. Boost library provides some features like shared_ptr and intrusive_ptr which allow us to track dependencies but they don't give us details like list of all the other objects pointing to a dependent object.

Suppose we have

Object B is dependent on A
Object C is dependent on A
(Multiple objects dependent on A)

I need some interface like

//Adding dependencies
B.dep_obj = A obj
C.dep_obj = A obj

After the above operations A should have refcount of 2 (plus a list containing B and C).

//Removing dependencies
B.dep_obj = NULL

One challenge I see if I opt for overloading operator= is to get reference of object B/C since the operator= will be part of class representing dep_obj object (and Not class representing B or C). Hence I won't be able to fetch object representing A and B using dep_obj (in generic way)

4

0 回答 0