Original Post
Here''s the situation:
- A C++ program embeds a Python interpreter.
- At any point user/programmer/player can bring up a console window and type in commands that will be passed on to Python interpreter to execute. Since many C++ classes will be exposed to python, it is a very flexible realtime debugging/tweaking solution.
- A pyton (.py) module is used to define configuration variables.
- A C++ class Config is used to load and execute the .py file with configuration symbols in a python interpreter. It is later used to get (and set) these symbols from C++ code. Note, at any time the user/programmer/player can bring up a console and change the values of these symbols.
- C++ Config class exposes a simple callback mechanism. Different classes interested in different configuration values sign up for a callback when configuration values are changed (either by the user via a console or by other C++ code).
I am running into the following problems:
- What is the best way to represent configuration values as python files? I am interested in nested scopes (i.e. Graphics.Terrain.LodBias = 5) and I am unsure how to do this in python. One way is to create a class for each scope. Perhaps someone could suggest a better idea.
- Since the user can change the value of any symbol through the console, I am not sure how to implement the callback mechanism provided by C++ Config class. If the user will simply type in LodBias = 5 in the console and will update the value of LodBias in the python interpreter, how can I let the Config class know about the update? Is there a way to overload the assignment operator in python for one module (in this case the module containing the configuration values).
P.S. Sorry for the weird post format, listing the prereqs and the problems seemed like the easiest way to describe everything.
P.P.S. I am new to python, so some of the questions may seem irrelevant. Please forgive my ignorance.