Hi Vasek, Hi all, although your technical proposition is funny, I am not sure it makes a serious difference and a big advantage compared to simple getter/setter function calling. Moreover, I am not sure that this code will be really used widely. So the user can call methods instead of using variable assignation.
Regards, Emilien PS: Sure your example/way is very interesting for C++ theory and exercises ;) 2012/12/4 <[email protected]> > Hello fellow developers, > > yesterday, I was thinking about how to implement specific config. > attributes accessors in section-based nut config. files so that > it's nice to use and consistent with NutConfiguration, UpsmonConfiguration > and UpsdConfiguration config. classes (where it's done via Settable > attributes). > > The GenericConfiguration class provides generic access to name/value > items of config. sections. The specialised classes (like e.g. > UpsConfiguration) > shall inherit the mechanism from GenericConfiguration and are supposed to > provide specialised (and typed) access to the config. attributes. > Now, the obvious choice is to write getters/setters for them; however, > this way, the access will be different than access to section-less config. > files attributes. > What I came with is a template class (see "redirect" in the sample code > attached) > that overloads the cast operator and the assignment operator (and possibly > others) > and therefore gives the user the possibility to execute code (the > getters/setters) > while the code looks just like r/w access to a variable (with certain > restrictions, though). > > Now, the mechanism looks kind of cool, but is also a bit technically > complex, > not to mention that it's disputable whether such masking of code execution > is a good idea. I can imagine that it can be quite confusing for an > outsider... > So, do you think that it's worth it or should I better keep the code less > "smart" > but more simple (now, when I'm writing that, it seems to answer itself...)? > > Thanks for the consult, > > Regards, > > -- > Václav Krpec > Network UPS Tools project > Eaton Opensource Team > >
_______________________________________________ Nut-upsdev mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsdev
