by jasper » 17 January 2022, 15:02
You can use your own collection implementation of course, but the collection class itself must have the template type CAPEOPEN_1_2::CapeUnitPort (which translates to the interface type CAPEOPEN_1_2::ICapeUnitPort - this is a required interface on items of type port).
In all cases if the Item implementation uses a temporary smart pointer to store the interface pointer, it would normally drop this reference held by the smart pointer upon return (which is when the smart pointer goes out of scope) but the returned value must have an added reference. You could simply implement this by explicitly adding a reference (outputArgument() does the opposite, instead of adding a reference it discards the reference of the smart pointer without a release call).
I am not entirely clear on where you want to go - can you attach your working port collection as well as the version that does not work, so that I can see more clearly what you want to do?
(to answer the actual question: your port collection can of course be implemented as a collection of my_port_class, but the interface implementation of CAPEOPEN_1_2::ICapeCollection still needs to return an CAPEOPEN_1_2::ICapeUnitPort interace, which is wrapped as CAPEOPEN_1_2::CapeUnitPort).