Circular Includes

in Help Center
Hello,
Is it possible to use the IceUtil::Handle smart pointer class for circular includes? I cannot seem to figure it out without getting a billion errors. If I use a forward declaration and then declare a smart pointer of that class in my interface, I obviously cannot since it's simply a template class and it will try to instantiate the unknown class in the header. I can probably store a pointer to the smart pointer, but I haven't tried it because that just seems very wrong.
For now as a work around, I just look up what room the player is in each time the player makes a request that requires a room. You can see that I'd much rather just store a smart pointer to the room the player is in.
I'm sure that I'm just misusing something. Can you please shed some light down on me?
Thanks a lot,
Pete
Is it possible to use the IceUtil::Handle smart pointer class for circular includes? I cannot seem to figure it out without getting a billion errors. If I use a forward declaration and then declare a smart pointer of that class in my interface, I obviously cannot since it's simply a template class and it will try to instantiate the unknown class in the header. I can probably store a pointer to the smart pointer, but I haven't tried it because that just seems very wrong.
For now as a work around, I just look up what room the player is in each time the player makes a request that requires a room. You can see that I'd much rather just store a smart pointer to the room the player is in.
I'm sure that I'm just misusing something. Can you please shed some light down on me?
Thanks a lot,
Pete
0
Comments
You cannot use IceUtil::Handle for circular includes, as the IceUtil::Handle needs to see the declaration of the class parameter.
If you're adventurous, you could use IceInternal::Handle, which is very similar to IceUtil::Handle but supports such cyclic includes. From Ice/Handle.h:
IceInternal::Handle is also compatible with IceUtil::Handle. However, like any IceInternal type, it's undocumented and can change at anytime.
Cheers,
Bernard
I should have double-checked this comment before copying it here
Cheers,
Bernard
This is very useful information, and I doubt that I would have come across it myself. I'm surprised ZeroC doesn't offer this class in the public API. It surely must come up often?
Thanks again,
Pete