So, you need two things: the local interface, which your web page can use to configure the application in C ++ and the web page itself.
There are several common mechanisms for such local interfaces:
change the configuration file and send SIGHUP so that the application re-read it
- Advantage
- is that you can test (and use) it directly from the shell, regardless of the web interface
- also note that changes are saved automatically
- is that you need some kind of scheme to store the βlast goodβ configuration file in case the edited file is damaged.
use a local socket stream and a simple protocol (either a UNIX socket, if supported, or a TCP port with a local host: TCP port only)
- the advantage is that you do not touch (and possibly damage) the configuration file (s)
- that is, then you will need another way to save the changes if you want, and that you must first write this protocol
- note that as long as the protocol is not text-based and not binary, you can at least test it with
telnet or netcat, so you can use it directly from the shell anyway- a simple protocol, such as
set variable=value , get variable , etc., should not be too complicated.
If you really want to separate web and C ++ applications, make sure you can query for available parameters, ideally by providing types, valid ranges and groups for them. You can then avoid re-encoding the web page every time you add or change a parameter.
You can control this by using magical comments in the configuration file (make sure that nothing is disabled by default without comments) or by using the list command on the stream socket.
With a little effort, you can probably create your own grouping, data type, and check constraints into the type system of your C ++ application, so you can automatically control the local interface and web application.
source share