55 #ifndef __UT_Functor_h__
56 #define __UT_Functor_h__
81 template <
typename R,
typename P1>
95 template <
typename R,
typename P1,
typename P2>
112 template <
typename ParentFunctor,
typename FunctorType>
130 {
return myFunctor(); }
133 FunctorType myFunctor;
138 template <
typename ParentFunctor,
typename FunctorType>
141 typename ParentFunctor::Parm1Type>
147 : myFunctor(functor) {}
153 {
return myFunctor(parm1); }
157 int64 mem = inclusive ?
sizeof(*this) : 0;
162 FunctorType myFunctor;
167 template <
typename ParentFunctor,
typename FunctorType>
170 typename ParentFunctor::Parm1Type,
171 typename ParentFunctor::Parm2Type>
178 : myFunctor(functor) {}
184 {
return myFunctor(parm1, parm2); }
187 FunctorType myFunctor;
193 template <
typename ParentFunctor,
typename PointerToObj,
194 typename PointerToMemFn>
202 const PointerToMemFn pointer_to_mem_fn)
203 : myPointerToObj(pointer_to_obj), myPointerToMemFn(pointer_to_mem_fn)
208 PointerToMemFn>(*this); }
211 {
return ((*myPointerToObj).*myPointerToMemFn)(); }
214 PointerToObj myPointerToObj;
215 PointerToMemFn myPointerToMemFn;
220 template <
typename ParentFunctor,
typename PointerToObj,
221 typename PointerToMemFn>
224 typename ParentFunctor::Parm1Type>
231 const PointerToMemFn pointer_to_mem_fn)
232 : myPointerToObj(pointer_to_obj), myPointerToMemFn(pointer_to_mem_fn)
237 PointerToMemFn>(*this); }
240 {
return ((*myPointerToObj).*myPointerToMemFn)(parm1); }
244 int64 mem = inclusive ?
sizeof(*this) : 0;
249 PointerToObj myPointerToObj;
250 PointerToMemFn myPointerToMemFn;
255 template <
typename ParentFunctor,
typename PointerToObj,
256 typename PointerToMemFn>
259 typename ParentFunctor::Parm1Type,
260 typename ParentFunctor::Parm2Type>
268 const PointerToMemFn pointer_to_mem_fn)
269 : myPointerToObj(pointer_to_obj), myPointerToMemFn(pointer_to_mem_fn)
274 PointerToMemFn>(*this); }
277 {
return ((*myPointerToObj).*myPointerToMemFn)(parm1, parm2); }
280 PointerToObj myPointerToObj;
281 PointerToMemFn myPointerToMemFn;
287 template <
typename R>
298 : myFunctorImpl(functor_implementation)
303 myFunctorImpl.myFunctorImpl = src.myFunctorImpl.myFunctorImpl
304 ? src.myFunctorImpl.myFunctorImpl->clone() :
nullptr;
313 template <
typename FunctorType>
321 template <
typename Po
interToObj,
typename Po
interToMemFn>
324 PointerToMemFn>(pointer, method))
330 delete myFunctorImpl.myFunctorImpl;
331 myFunctorImpl.myFunctorImpl = 0;
337 if (&functor !=
this)
339 delete myFunctorImpl.myFunctorImpl;
340 myFunctorImpl.myFunctorImpl = functor.myFunctorImpl.myFunctorImpl
341 ? functor.myFunctorImpl.myFunctorImpl->clone() : 0;
353 return (*myFunctorImpl.myFunctorImpl)();
360 {
return myFunctorImpl.myFunctorImpl != 0; }
369 Helper() : myFunctorImpl(0) {}
372 Helper(
const Helper &helper)
373 { myFunctorImpl = helper.myFunctorImpl
374 ? helper.myFunctorImpl->clone() : 0; }
377 : myFunctorImpl(functor_implementation) {}
380 explicit Helper(U *
ptr) : myFunctorImpl(ptr) {}
385 Helper myFunctorImpl;
390 template <
typename R,
typename P1>
402 : myFunctorImpl(functor_implementation)
405 template <
typename FunctorType>
410 template <
typename Po
interToObj,
typename Po
interToMemFn>
413 PointerToMemFn>(pointer, method))
418 myFunctorImpl.myFunctorImpl = src.myFunctorImpl.myFunctorImpl
419 ? src.myFunctorImpl.myFunctorImpl->clone() :
nullptr;
424 delete myFunctorImpl.myFunctorImpl;
425 myFunctorImpl.myFunctorImpl = 0;
430 if (&functor !=
this)
432 delete myFunctorImpl.myFunctorImpl;
433 myFunctorImpl.myFunctorImpl = functor.myFunctorImpl.myFunctorImpl
434 ? functor.myFunctorImpl.myFunctorImpl->clone() : 0;
442 return (*myFunctorImpl.myFunctorImpl)(parm1);
448 {
return myFunctorImpl.myFunctorImpl != 0; }
452 int64 mem = inclusive ?
sizeof(*this) : 0;
453 if (myFunctorImpl.myFunctorImpl)
454 mem += myFunctorImpl.myFunctorImpl->getMemoryUsage(
true);
462 Helper() : myFunctorImpl(0) {}
465 Helper(
const Helper &helper)
466 { myFunctorImpl = helper.myFunctorImpl
467 ? helper.myFunctorImpl->clone() : 0; }
471 : myFunctorImpl(functor_implementation) {}
474 explicit Helper(U *
ptr) : myFunctorImpl(ptr) {}
479 Helper myFunctorImpl;
484 template <
typename R,
typename P1,
typename P2>
496 : myFunctorImpl(functor_impl)
499 template <
typename FunctorType>
504 template <
typename Po
interToObj,
typename Po
interToMemFn>
507 PointerToMemFn>(pointer, method))
512 delete myFunctorImpl.myFunctorImpl;
513 myFunctorImpl.myFunctorImpl = 0;
518 if (&functor !=
this)
520 delete myFunctorImpl.myFunctorImpl;
521 myFunctorImpl.myFunctorImpl = functor.myFunctorImpl.myFunctorImpl
522 ? functor.myFunctorImpl.myFunctorImpl->clone() : 0;
530 return (*myFunctorImpl.myFunctorImpl)(parm1, parm2);
536 {
return myFunctorImpl.myFunctorImpl != 0; }
542 Helper() : myFunctorImpl(0) {}
545 Helper(
const Helper &helper)
546 { myFunctorImpl = helper.myFunctorImpl
547 ? helper.myFunctorImpl->clone() : 0; }
551 : myFunctorImpl(functor_impl) {}
554 explicit Helper(U *
ptr) : myFunctorImpl(ptr) {}
559 Helper myFunctorImpl;
566 template <
typename Incoming>
574 : myFunctor(functor), myBoundArgument(bound_argument)
581 {
return myFunctor(myBoundArgument); }
590 template <
typename Functor>
592 UT_BindFirst(
const Functor &functor,
typename Functor::Parm1Type bound_argument)
603 template <
typename Incoming>
605 typename Incoming::Parm2Type>
613 : myFunctor(functor), myBoundArgument(bound_argument)
620 {
return myFunctor(myBoundArgument, parm1); }
624 int64 mem = inclusive ?
sizeof(*this) : 0;
633 template <
typename Functor>
636 typename Functor::Parm1Type bound_argument)
638 typedef typename Functor::ReturnType ReturnType;
639 typedef typename Functor::Parm2Type Parm1Type;
650 #if defined(WIN32) || defined(LINUX) || defined(MBSD)
Incoming::Parm1Type BoundType
UT_MemFunHandler1(const PointerToObj &pointer_to_obj, const PointerToMemFn pointer_to_mem_fn)
ParentFunctor::Parm2Type Parm2Type
UT_Functor< typename Functor::ReturnType > UT_BindFirst(const Functor &functor, typename Functor::Parm1Type bound_argument)
virtual ReturnType operator()(Parm1Type parm1) const =0
UT_FunctorHandler(const FunctorType &functor)
virtual ReturnType operator()() const =0
ParentFunctor::ReturnType ReturnType
UT_Functor(const this_type &src)
UT_FunctorImpl< ReturnType > * clone() const override
ParentFunctor::Parm1Type Parm1Type
UT_Functor(FunctorType functor)
UT_FunctorHandler1(const FunctorType &functor)
ParentFunctor::Parm1Type Parm1Type
UT_Functor(UT_FunctorImpl< ReturnType > *functor_implementation)
UT_FunctorHandler2(const FunctorType &functor)
UT_Functor(const PointerToObj &pointer, PointerToMemFn method)
Incoming::Parm1Type BoundType
int64 getMemoryUsage(bool inclusive) const override
Incoming::ReturnType ReturnType
ReturnType operator()(Parm1Type parm1) const override
UT_Functor1(FunctorType functor)
virtual ~UT_FunctorImpl1()
UT_FunctorImpl< ReturnType > * clone() const override
virtual ReturnType operator()(Parm1Type parm1, Parm2Type parm2) const =0
UT_Functor1< typename Functor::ReturnType, typename Functor::Parm2Type > UT_BindFirst1(const Functor &functor, typename Functor::Parm1Type bound_argument)
ParentFunctor::ReturnType ReturnType
UT_FunctorImpl1< ReturnType, Parm1Type > * clone() const override
ReturnType operator()(Parm1Type parm1, Parm2Type parm2) const
UT_Functor1(UT_FunctorImpl1< ReturnType, Parm1Type > *functor_implementation)
ReturnType operator()(Parm1Type parm1) const override
int64 getMemoryUsage(bool inclusive) const override
int64 getMemoryUsage(bool inclusive) const
UT_FunctorImpl2< ReturnType, Parm1Type, Parm2Type > * clone() const override
UT_MemFunHandler(const PointerToObj &pointer_to_obj, const PointerToMemFn pointer_to_mem_fn)
ReturnType operator()() const override
UT_Functor1(const this_type &src)
ReturnType operator()(Parm1Type parm1) const override
UT_FunctorImpl2< ReturnType, Parm1Type, Parm2Type > * clone() const override
UT_Functor2(UT_FunctorImpl2< ReturnType, Parm1Type, Parm2Type > *functor_impl)
ReturnType operator()(Parm1Type parm1, Parm2Type parm2) const override
virtual int64 getMemoryUsage(bool inclusive) const =0
Generic interface for reading and writing image files. This class handles the reading and writing of ...
Incoming::ReturnType ReturnType
ReturnType operator()(Parm1Type parm1) const
UT_FunctorImpl1< ReturnType, Parm1Type > * clone() const override
ParentFunctor::Parm1Type Parm1Type
UT_Functor1(const PointerToObj &pointer, PointerToMemFn method)
Incoming::Parm2Type Parm1Type
virtual UT_FunctorImpl2< ReturnType, Parm1Type, Parm2Type > * clone() const =0
ParentFunctor::Parm2Type Parm2Type
UT_BindFirstImpl1(const Incoming &functor, BoundType bound_argument)
ParentFunctor::ReturnType ReturnType
UT_Functor2(FunctorType functor)
virtual UT_FunctorImpl1< ReturnType, Parm1Type > * clone() const =0
GLsizei const void * pointer
ParentFunctor::ReturnType ReturnType
int64 getMemoryUsage(bool inclusive) const override
ReturnType operator()(Parm1Type parm1, Parm2Type parm2) const override
UT_Functor2 & operator=(const UT_Functor2 &functor)
virtual ~UT_FunctorImpl()
UT_MemFunHandler2(const PointerToObj &pointer_to_obj, const PointerToMemFn pointer_to_mem_fn)
UT_Functor & operator=(const UT_Functor &functor)
ParentFunctor::ReturnType ReturnType
UT_FunctorImpl< ReturnType > * clone() const override
UT_Functor2(const PointerToObj &pointer, PointerToMemFn method)
virtual ~UT_FunctorImpl2()
UT_BindFirstImpl(const Incoming &functor, BoundType bound_argument)
ReturnType operator()() const override
virtual UT_FunctorImpl< ReturnType > * clone() const =0
ParentFunctor::ReturnType ReturnType
ReturnType operator()() const override
ReturnType operator()() const
UT_Functor1 & operator=(const UT_Functor1 &functor)
ParentFunctor::Parm1Type Parm1Type
UT_FunctorImpl1< ReturnType, Parm1Type > * clone() const override