Boost logo

Boost :

From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2005-12-22 05:04:18


Hi Sebastian,

--- Sebastian Redl <sebastian.redl_at_[hidden]> wrote:
> Christopher Kohlhoff wrote:
> >Doesn't such an approach force a particular internal
> >implementation on the timer?
> >
> Actually, no. It's pretty easy to write a proxy object to do
> this stuff. A minimal object, just for the above example:
>
> class expiry_date_proxy
> {
> deadline_timer &timer;
>
> public:
> expiry_date_proxy(deadline_timer &t) : timer(t) {}
>
> expiry_date_proxy & operator +=(timespan ts) {
> timer.expires_at(timer.expires_at() + ts);
> }
> };
>
> class deadline_timer
> {
> ...
> expiry_date_proxy expiry_date() { return expiry_date_proxy(*this);
> }
> };
>
> I'm not saying that this necessarily should be done (in particular,
> where do you stop making properties?), but it's possible.

Oh yeah, fair enough. Such a proxy approach could also be done
external to the object, e.g:

  expiry(timer) += seconds(5);

The proxy/property approach doesn't seem idiomatic C++ to me,
but that's probably just my background. If resetting the expiry
relative to the current expiry is a common use case perhaps it
is deserving of its own member function, e.g.:

  timer.expires_from_current(seconds(5));

However when reworking the interface into its current form I
chose a more minimalist approach.

Cheers,
Chris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk