I am making a C++ glfw wrapper for myself to use. I want to have classes like
Context that would be wrappers for glfw objects like
GLFWWindow*. The problem is that if I want to have a method
create_window() in the
Window class, it must have access to the underlying raw glfw pointer in
Monitor class. At the same time, if I wanted the
Monitor class to have a method like
enumerate_windows(), it would need access to the underlying glfw window pointer. I could have a public method
get_raw_handle() in both classes, but implementation details are supposed to be hidden and I don't want the user to be able to access this information. It should only be available to the library.
I thought that I could
friend the classes to each other, but that doesn't seem right, as if I wanted to add a new class, I would have to
friend all existing classes to it and the other way around. It would also require forward declarations for everything and right now my library is header only.
I also thought that maybe all these objects could inherit from some kind of super
WindowingSystemObject class that would have a
get_raw_handle(), but that would mean that the handle would need to be universal (like a
void*) and then cast to the appropriate type.
All this seems so complicated. Instead of writing code I feel like some kind of a philosopher. I don't know anymore if I should make it in C++ (with classes) or just make it in C and don't care about any encapsulation as long as it works.