Jump to page: 1 2
Thread overview
scoped_handle but for functions?
Feb 07, 2007
Matthew Wilson
Feb 07, 2007
Matthew Wilson
Feb 07, 2007
Matthew Wilson
Feb 07, 2007
Matthew Wilson
Mar 09, 2007
Matthew Wilson
February 07, 2007
Hi Mathew,



I've been browsing the STLSoft documentation looking for something like scoped_handle but that applies the same principle but to two functions. Unfortunately did not find it, and instead of rushing into the implementation, a chosen a wiser path and decided that asking you would hurt. So STLSoft already has something like applying the RAII idea but to functions?



Thanks

Cláudio Albuquerque


February 07, 2007
Not sure what you mean. Can you give me an illustration of what you mean?

Matthew


"Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqc6nd$2815$1@digitaldaemon.com...
> Hi Mathew,
>
>
>
> I've been browsing the STLSoft documentation looking for something like scoped_handle but that applies the same principle but to two functions. Unfortunately did not find it, and instead of rushing into the implementation, a chosen a wiser path and decided that asking you would hurt. So STLSoft already has something like applying the RAII idea but to functions?
>
>
>
> Thanks
>
> Cláudio Albuquerque
>
>


February 07, 2007
Sure,

void MyFunc()
{
 ...
    scoped_functions<InitializeFunc,FinalizeFunc> OpInitializeFinalize;
...
}

When I declare the scoped_functions object, it will call the InitializeFunc() function, when the object goes out of scope it will call the FinalizeFun().

Hope this explanation helps.

Regards
Cláudio Albuquerque


"Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqcc8u$2fni$1@digitaldaemon.com...
> Not sure what you mean. Can you give me an illustration of what you mean?
>
> Matthew
>
>
> "Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqc6nd$2815$1@digitaldaemon.com...
>> Hi Mathew,
>>
>>
>>
>> I've been browsing the STLSoft documentation looking for something like scoped_handle but that applies the same principle but to two functions. Unfortunately did not find it, and instead of rushing into the implementation, a chosen a wiser path and decided that asking you would hurt. So STLSoft already has something like applying the RAII idea but to functions?
>>
>>
>>
>> Thanks
>>
>> Cláudio Albuquerque
>>
>>
>
> 


February 07, 2007
I see.

No, scoped_handle does not support that syntax. However, it does support that functionality, as in:

void MyFunc()
{
    ...
    InitializeFunc();
    scoped_functions<void> OpInitializeFinalize(FinalizeFunc);
    ...
}

:-)

Cheers

Matthew


"Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqd624$in5$1@digitaldaemon.com...
>
> Sure,
>
> void MyFunc()
> {
>  ...
>     scoped_functions<InitializeFunc,FinalizeFunc> OpInitializeFinalize;
> ...
> }
>
> When I declare the scoped_functions object, it will call the
> InitializeFunc() function, when the object goes out of scope it will call
> the FinalizeFun().
>
> Hope this explanation helps.
>
> Regards
> Cláudio Albuquerque
>
>
> "Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqcc8u$2fni$1@digitaldaemon.com...
> > Not sure what you mean. Can you give me an illustration of what you
mean?
> >
> > Matthew
> >
> >
> > "Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqc6nd$2815$1@digitaldaemon.com...
> >> Hi Mathew,
> >>
> >>
> >>
> >> I've been browsing the STLSoft documentation looking for something like scoped_handle but that applies the same principle but to two functions. Unfortunately did not find it, and instead of rushing into the implementation, a chosen a wiser path and decided that asking you would hurt. So STLSoft already has something like applying the RAII idea but
to
> >> functions?
> >>
> >>
> >>
> >> Thanks
> >>
> >> Cláudio Albuquerque
> >>
> >>
> >
> >
>
>


February 07, 2007
I mean:

void MyFunc()
{
    ...
    InitializeFunc();
    scoped_handle<void> OpInitializeFinalize(FinalizeFunc);
    ...
}


February 07, 2007
Humm I see

Ok, although I would like the "other" syntax better, I can see also some advantages to this.

Thanks Mathew!


"Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqd9t0$nv0$1@digitaldaemon.com...
>
> I mean:
>
> void MyFunc()
> {
>    ...
>    InitializeFunc();
>    scoped_handle<void> OpInitializeFinalize(FinalizeFunc);
>    ...
> }
>
> 


February 07, 2007
"Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqdc5a$r9r$1@digitaldaemon.com...
>
> Humm I see
>
> Ok, although I would like the "other" syntax better, I can see also some advantages to this.
>
> Thanks Mathew!

You're welcome. ;-)

>
>
> "Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqd9t0$nv0$1@digitaldaemon.com...
> >
> > I mean:
> >
> > void MyFunc()
> > {
> >    ...
> >    InitializeFunc();
> >    scoped_handle<void> OpInitializeFinalize(FinalizeFunc);
> >    ...
> > }
> >
> >
>
>


March 09, 2007
Hi Mathew,

I'm trying to use the implementation that you recomended [scoped_handle<void> OpInitializeFinalize(FinalizeFunc);], but with member functions and I got a couple of errors. Could you help is it possible for you to help me on this? [I am using beta-44.]

Thanks In Advance
Cláudio Albuquerque

stlsoft::scoped_handle<void> scopedEndOperation ( &baseClass::EndOperation );

Error 4 error C2664: 'stlsoft::scoped_handle<void>::scoped_handle(void (__cdecl *)(void))' : cannot convert parameter 1 from 'bool (__thiscall teste::* )(void)' to 'void (__cdecl *)(void)'

scoped_handle<void> scopedFinalize( baseClass::OpFinalize() );

Error 5 error C2664: 'stlsoft::scoped_handle<void>::scoped_handle(void (__cdecl *)(void))' : cannot convert parameter 1 from 'bool' to 'void (__cdecl *)(void)'



"Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqdfu3$10ap$1@digitaldaemon.com...
>
> "Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqdc5a$r9r$1@digitaldaemon.com...
>>
>> Humm I see
>>
>> Ok, although I would like the "other" syntax better, I can see also some advantages to this.
>>
>> Thanks Mathew!
>
> You're welcome. ;-)
>
>>
>>
>> "Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqd9t0$nv0$1@digitaldaemon.com...
>> >
>> > I mean:
>> >
>> > void MyFunc()
>> > {
>> >    ...
>> >    InitializeFunc();
>> >    scoped_handle<void> OpInitializeFinalize(FinalizeFunc);
>> >    ...
>> > }
>> >
>> >
>>
>>
>
> 


March 09, 2007
Hi Mathew,

I'm trying to use the implementation that you recomended [scoped_handle<void> OpInitializeFinalize(FinalizeFunc);], but with member functions and I got a couple of errors. Could you help is it possible for you to help me on this? [I am using beta-44.]

Thanks In Advance
Cláudio Albuquerque

stlsoft::scoped_handle<void> scopedEndOperation (
&baseClass::EndOperation );

Error 4 error C2664: 'stlsoft::scoped_handle<void>::scoped_handle(void
(__cdecl *)(void))' : cannot convert parameter 1 from 'bool (__thiscall
teste::* )(void)' to 'void (__cdecl *)(void)'

scoped_handle<void> scopedFinalize( baseClass::OpFinalize() );

Error 5 error C2664: 'stlsoft::scoped_handle<void>::scoped_handle(void
(__cdecl *)(void))' : cannot convert parameter 1 from 'bool' to 'void
(__cdecl *)(void)'



"Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqdfu3$10ap$1@digitaldaemon.com...
>
> "Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqdc5a$r9r$1@digitaldaemon.com...
>>
>> Humm I see
>>
>> Ok, although I would like the "other" syntax better, I can see also some advantages to this.
>>
>> Thanks Mathew!
>
> You're welcome. ;-)
>
>>
>>
>> "Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqd9t0$nv0$1@digitaldaemon.com...
>> >
>> > I mean:
>> >
>> > void MyFunc()
>> > {
>> >    ...
>> >    InitializeFunc();
>> >    scoped_handle<void> OpInitializeFinalize(FinalizeFunc);
>> >    ...
>> > }
>> >
>> >
>>
>>
>
>



March 09, 2007
Ah, the problem there is that it's not designed to do that for member functions.

I wouldn't want to alter scoped_handle to do that, but I would be open to implementing an RAII class template - e.g. scoped_method - to do that.

Anyone got any ideas on this one, to give me a kick start?


"Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:esraio$12d3$2@digitalmars.com...
>
> Hi Mathew,
>
> I'm trying to use the implementation that you recomended [scoped_handle<void> OpInitializeFinalize(FinalizeFunc);], but with member functions and I got a couple of errors. Could you help is it possible for you to help me on this? [I am using beta-44.]
>
> Thanks In Advance
> Cláudio Albuquerque
>
> stlsoft::scoped_handle<void> scopedEndOperation (
> &baseClass::EndOperation );
>
> Error 4 error C2664: 'stlsoft::scoped_handle<void>::scoped_handle(void
> (__cdecl *)(void))' : cannot convert parameter 1 from 'bool (__thiscall
> teste::* )(void)' to 'void (__cdecl *)(void)'
>
> scoped_handle<void> scopedFinalize( baseClass::OpFinalize() );
>
> Error 5 error C2664: 'stlsoft::scoped_handle<void>::scoped_handle(void
> (__cdecl *)(void))' : cannot convert parameter 1 from 'bool' to 'void
> (__cdecl *)(void)'
>
>
>
> "Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqdfu3$10ap$1@digitaldaemon.com...
> >
> > "Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqdc5a$r9r$1@digitaldaemon.com...
> >>
> >> Humm I see
> >>
> >> Ok, although I would like the "other" syntax better, I can see also
some
> >> advantages to this.
> >>
> >> Thanks Mathew!
> >
> > You're welcome. ;-)
> >
> >>
> >>
> >> "Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqd9t0$nv0$1@digitaldaemon.com...
> >> >
> >> > I mean:
> >> >
> >> > void MyFunc()
> >> > {
> >> >    ...
> >> >    InitializeFunc();
> >> >    scoped_handle<void> OpInitializeFinalize(FinalizeFunc);
> >> >    ...
> >> > }
> >> >
> >> >
> >>
> >>
> >
> >
>
>
>


« First   ‹ Prev
1 2