hasselmm / hasselmm/PropertyExperiment

Allow custom property methods

Open
#8 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
4
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Defacto this only implements member properties so far:

``` C++
Q_PROPERTY(int name MEMBER name NOTIFY nameChanged)
```

This is convenient and useful for 60%, maybe 80% of all cases. Still it's neccessary to also allow custom property methods for a full replacement of moc. Maybe with a syntax like this:

``` C++
N_PROPERTY(int, customReader) = {&NObjectMacro::customInt};
N_PROPERTY(double, customWriter) = {reset = &NObjectMacro::resetCustomDouble
writer = &NObjectMacro::setCustomDouble,
reader = &NObjectMacro::customDuble,
initial = 42};
```

Maybe better maybe even this is possible, as this would avoid storing the custom methods in instance variables:

``` C++
N_PROPERTY(int, customReader, &NObjectMacro::customInt) = 100;
N_PROPERTY(double, customWriter, reset = &NObjectMacro::resetCustomDouble
writer = &NObjectMacro::setCustomDouble,
reader = &NObjectMacro::customDuble) = 4.2;
```

The mechanism for named arguments would be something like this:

``` C++
inline constexpr PropertyArgument reset;
template
class Property { ... };
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.