Open ostkamp opened 6 months ago
If you want access to the private members from child classes, send a PR which provides it through protected member functions; we will not make the member variables protected.
Hi @ostkamp I managed to extend reactor couple of years ago, and the only way I found is to copy the Reactor code and doing my own class
SocketReactor has a virtual
run()
method, see https://github.com/pocoproject/poco/blob/ad72b25ace25da47ff3250f349d00e7ee46fb4b5/Net/include/Poco/Net/SocketReactor.h#L184If it gets overridden by a
run()
method in a child class for extending its functionality, this child method has zero access to the required data of the base class (e.g. params provided to constructor, data added later through method calls etc.), since that data is completely private in base class. This also applies to several methods used in the original code of run() in the base class.It is thus not possible to extend the functionality of the base class
run()
method.To Reproduce Create a child class inheriting from SocketReactor and add a run() method which overrides. Try to copy in the code from original
run()
method of the base class. It won´t compile because of accessing private members and methods. Try to instantiate an object just to ensure compilation is attempted.Expected behavior The currently private data of the base class SocketReactor should become protected so it can be accessed from overridden
run()
method in child class. This also applies to private methods used by the originalrun()
method of the base class. Steps outlined in "To reproduce" should compile, link and work ok.Logs N/A
Screenshots N/A
Please add relevant environment information:
Additional context N/A