I have a control class that interacts with hardware attached to the computer. That includes a large number of function calls for performing actions (like turning it on or off, specifying settings, and so on), and it also involves a large number of calls for retrieving data.
From the start I've broken it into other files, and then, as I got used to C++ (this is my first work in C++, so I've been using this language for less than 3 weeks now), I created a class in each file and changed over to OOP. (Please, no comments on how I should have done that from the start -- I had to learn the different facets of the language as I went along.)
I have the main class, which I'll call HWControl, then I have the class that actually sends commands to the hardware, which we can call HWCommands, then a listener that receives all the output from the hardware, processes it, and turns it into usable data, HWListener.
As I said, both HWCommands and HWListener have a LOT of specialized functions. Putting all the function calls in one class would be unwieldy, but on the other hand, I want them all available to anyone using this class.
I doubt what I'm asking is possible, but is there a way to pass a function call through from one object to the next without having to specify each function itself? I know I can do something like this:
but is there some way to do this by getting a list of functions in HWListen and HWCommands and if a call is made to HWControl through such a function, just pass it on to the other class? If I do it this way, whenever I change HWCommands or HWListen, I have to make the similar changes in HWControl, which can be a maintenance issue (at least in terms of my own senility).Code:string HWControl::getPowerState() { return hwlisten.getPowerState(); }
While I don't think this is possible, I've been quite impressed by the flexibility of C++ and figure by asking about this, that there's a good chance there's a feature I don't know about that might help me in some way here or some other way to handle it.
I've seriously considered, instead of having, say, 40 function calls for commands, to have one function that will process a string with the command and the arguments (which is quite easy and already done for my command line testing). I could do the same for getting output from the device by having one function call that takes a string with the name of the info needed as a parameter instead of providing 20-30 calls asking for each different piece of information, but I know programmers don't seem to like that kind of interface.
Any suggestions or comments?