I have a 3rd party working on a system for me and they've delivered a working vxWorks image with binaries that run their software. They've also provided me with source code describing the specific models, but haven't provided me the entire development environment yet. I'm trying to fill in some of the dependencies so I can emulate their models in my own software for when the vxWorks machines fail and I can only emulate real-time in Windows. I have everything working except for the configuration loading.
In the following code, I am writing
GenericBase and
ParameterSet from scratch as those were not provided.
CReadOnlyModule is read-only since I expect to get updates and can't maintain configuration control if I change this class.
Header
1 2 3 4 5 6 7 8 9 10 11 12 13
|
#include "GenericBase.h"
#include <string>
class ParameterSet;
class CReadOnlyModule : public GenericBase
{
public:
CReadOnlyModule(const std::string& inName);
private:
float mMyParameter1;
ParameterSet* m_pParameterSet;
};
|
Source
1 2 3 4 5 6 7 8 9 10 11
|
#include "CReadOnlyModule.h"
#include "ParameterSet.h"
// I think inName is "ReadOnlyModule"
CReadOnlyModule::CReadOnlyModule(const std::string& inName)
: GenericBase(inName)
{
m_pParameterSet = new ParameterSet("default", false);
m_pParameterSet->CreateFloat(&mMyParameter1, "MyParameter1");
}
|
I also have a configuration file which sets the value of mMyParameter1. It looks like this (but it contains several Modules and parameters per module.
MODULE ReadOnlyModule
FLOAT MyParameter1 200
ENDDEF MODULE ReadOnlyModule |
Question:
How can I set
mMyParameter1 to the value in the config file within the framework above?
I believe the parsing needs to be done in the constructors of GenericBase or ParameterSet and the driving needs to be in CreateFloat. The inName is important here because it defines the name to lookup when reading the cfg. Therefore I can only assume that the file is opened and parsed in GenericBase. But if that's the case, how can I get the information into the
CreateFloat() function?
MyParameter1 is not an exclusive name and it's set to different values for different modules in this cfg.
Edit: F5 F5 F5 F5 F5 F5 F5