August 17, 2014 Handle attributes changes | ||||
---|---|---|---|---|
| ||||
Hi! I'm trying to handle the fact that an attribute has change since I've set it for the first time (by desialising a bson), to abstract the only-modified fields update with vibe.d and mongodb, without storing two times the values. The idea is to have something like that : class Base { ... // The code to handle the fact that an attribute has been modified void update() { // Update only the fields that have been modified since loading } ... } class A : Base { ... int field1; ... } void main() { ... A test = deserializeBson!A(bson); test.update(); // Does not updates anything test.field1 = 12; test.update(); // Now updates the 'field1' field ... } I've search a way to modify my methods source code at compile time, but it seems to be impossible. So I thought that it should be possible to rewrite the @property working, but I can't find anything about this. Is it possible ? And if it's not, is there a way to do what I want to do ? Thanks! |
August 17, 2014 Re: Handle attributes changes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthieu | I found this, which excactly is what I want to do : http://dlang.org/phobos/std_signals.html So in other terms, I want to abstract that, maybe with an UDA ? But can I do this without compile time code changes ? Thanks again! |
Copyright © 1999-2021 by the D Language Foundation