lundi 9 mai 2022

Any way to set a hook to a variable?

I'm designing a new functionality that would override or take control of some variables' value that have been preloaded into memory during boot.

For instance, system has preloaded some bin files and parsed their contents into memory. And we have some C++ classes, say CBinaryParam, to represent them. What I am supposed to achieve is that user can set new values, by providing a setting file or by keyboard input. And when such situation happens, the new value is supposed to "override" the one in CBinaryParam. Since CBinaryParam is composed by other team, and the code is auto-generated, hence it's not convenient to change implementation of CBinaryParam, let alone it's not easy to achieve.

Hence I'm looking for a trick/solution/design pattern, that would allow me to kind of set a hook between user input and preloaded binary parameters, and if user input is present, its value would automatically "override" corresponding binary parameters, otherwise original binary parameters will be used, without changing internal implementation of CBinaryParam.

Aucun commentaire:

Enregistrer un commentaire