Parameter interface.
Parameter category
Because there may be many parameters, it is necessary to classify them by parameter category. Each category can derive a separate class from this class. Each category is then used as a member variable in the derived classes of this class.
For example:
Connection parameters include the following categories:
- Video
Basic network parameters.
CParameter(QObject *parent, const QString &szPrefix=QString())
- Audio
It contains user and password It only valid in plugin.
Then the connection parameters can be a combination of the above categories:
{
public:
explicit CParameterConnect(
CParameter *parent =
nullptr);
};
CParameterConnect::CParameterConnect(
CParameter *parent =
nullptr)
m_Net(this),
m_User(this)
{}
- Note
- When a member is instantiated, the constructor must set the parent to this
CParameter Interface functions
- Load and save parameters from storage
- If you need to automatically nest calls the OnXXX(ag: OnLoad) functions of CParameter type member, When a CParameter type member is instantiated, the constructor sets the parent to a CParameter (usually this) type instance.
- If you're going to control the OnXXX(ag: OnLoad) functions of CParameter type member, When a CParameter type member is instantiated, the constructor parent is set nullptr or non-CParameter type instance.
- When the derived class sets parameters, it needs to call SetModified(), to flag changed.
- Check whether the parameter is valid, call CheckValidity()
Definition at line 219 of file Parameter.h.
| bool CParameter::CheckValidity |
( |
| ) |
|
|
virtual |
Check whether the parameter is valid to decide whether to use or save the parameter.
Derived classes typically simply overload OnCheckValidity() to check the parameters.
For example, when setting the parameters in the dialog, you need to check whether the parameters are complete or valid before you can save them.
- See also
- CParameterUI::CheckValidity
Definition at line 103 of file Parameter.cpp.