Hello
I have class A. Class A is responsible for managing the lifetime of B objects and it contains container of B objects that is map<BGuid,B>
, and each B object contains container of C objects which is map<CGuid,C>
.I have one global A object for the entire application.
I have the following problem: I have CGuid object and I want to use it to find my C object. But to that I also need to know the BGuid object which will tell me in which B object I should look my C object. But all I have is the CGuid, which means that I have to check every B object to see if it contains my C object. However I think that this is messy. I thought that maybe I should have another class say M which will contain map of all my C objects , and I can search directly in it just with CGuid, still this means that I need to maintain extra map just for searching.
Also I except in the future my C class to contain map<Dguid,D>
so I will have the same problem for the the D objects , this time even worse, I will need Bguid,Cguid, and Dguid to find my D object.
How to solve this problem ?