PROPERTY macro for applicationdomain types
Closed, ResolvedPublic

Description

To provide a little more type-safety and documentation than setPropert(QByteArray, QVariant) we should define properties in the applicationdomaintype instance with macros like this:
PROPERTY(QString, "subject")
EXTRACTED_PROPERTY(QString, "subject")
BLOB_PROPERTY("mimeMessage")

All properties generate:

static QByteArray $NameProperty();

A regular property will generate:

$type get$Name() const;
void set$Name(const $type &);

An extracted property will generate (to make clear that these properties should not be set by clients)

$type get$Name() const;
void setExtracted$Name(const $type &);

A blob property will generate:

QByteArray get$Name() const;
QString get$NamePath() const;
void set$NamePath(const QString &path);
void set$Name(const QByteArray &path);

Details

Ticket Type
Task
mollekopf updated the task description. (Show Details)
mollekopf updated the task description. (Show Details)
mollekopf moved this task from Backlog to Doing on the Sprint 201619 board.May 9 2016, 2:55 PM
mollekopf added a comment.EditedMay 9 2016, 4:26 PM

Alternatively we could define properties with classes and use template wrappers like this:

struct SubjectProperty {
  static constexpr char name[] = "summary";
  typedef QString Type;
}
QString subject;
set<SubjectProperty>(subject);
subject = get<SubjectProperty>();

That ends up being more verbose (without additional macro magic), but the property definitions can be reused in other places, such as the property mapping.

Another alternative would be

Propert<QString> summary {"summary", this};

Mail mail;
mail.summary.set("foobar");
auto result = mail.summary.get();
mollekopf moved this task from Doing to Review on the Sprint 201619 board.May 10 2016, 4:11 PM
petersen moved this task from Backlog to Review on the Sprint 201620 board.May 16 2016, 8:54 AM
mollekopf moved this task from Review to Done on the Sprint 201620 board.May 17 2016, 10:42 AM
mollekopf closed this task as Resolved.Mar 3 2017, 2:31 PM
mollekopf claimed this task.

Most likely candidate is: