30 #ifndef vtkDispatcher_Private_h
31 #define vtkDispatcher_Private_h
42 template <
class BaseLhs,
58 return fun_(CastLhs::Cast(lhs));
67 template <
class BaseLhs,
83 return fun_(CastLhs::Cast(lhs));
91 template <
typename R,
typename P1>
105 U* pClone =
static_cast<U*
>(pObj->DoClone());
106 assert(
typeid(*pClone) ==
typeid(*pObj));
120 template <
class ParentFunctor,
typename Fun>
123 typedef typename ParentFunctor::Impl Base;
146 template <
typename R,
typename Parm1>
159 template <
typename Fun>
168 Impl* p = spImpl_.release();
169 spImpl_.reset(copy.spImpl_.release());
170 copy.spImpl_.reset(p);
176 {
return (*spImpl_)(p1); }
178 std::auto_ptr<Impl> spImpl_;
190 template <
class BaseLhs,
class BaseRhs,
191 class SomeLhs,
class SomeRhs,
193 class CastLhs,
class CastRhs,
205 return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs));
211 template <
class BaseLhs,
class BaseRhs,
212 class SomeLhs,
class SomeRhs,
214 class CastLhs,
class CastRhs,
226 return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs));
234 template <
typename R,
typename P1,
typename P2>
249 U* pClone =
static_cast<U*
>(pObj->DoClone());
250 assert(
typeid(*pClone) ==
typeid(*pObj));
264 template <
class ParentFunctor,
typename Fun>
267 typedef typename ParentFunctor::Impl Base;
277 {
return f_(p1,p2); }
291 template <
typename R,
typename Parm1,
typename Parm2>
304 template <
typename Fun>
313 Impl* p = spImpl_.release();
314 spImpl_.reset(copy.spImpl_.release());
315 copy.spImpl_.reset(p);
320 {
return (*spImpl_)(p1,p2); }
322 std::auto_ptr<Impl> spImpl_;
329 template <
class To,
class From>
334 return dynamic_cast<To&
>(obj);
339 return dynamic_cast<To*
>(obj);
343 template <
class To,
class From>
348 return *(To::SafeDownCast(&obj));
353 return To::SafeDownCast(obj);
365 const std::type_info&
Get()
const;
368 const char*
name()
const;
371 const std::type_info* pInfo_;
379 pInfo_ = &
typeid(Nil);
391 return pInfo_->before(*rhs.pInfo_) != 0;
403 return pInfo_->name();
410 {
return (lhs.
Get() == rhs.
Get()) != 0; }
413 {
return lhs.
before(rhs); }
416 {
return !(lhs == rhs); }
419 {
return rhs < lhs; }
422 {
return !(lhs > rhs); }
425 {
return !(lhs < rhs); }
429 #endif // vtkDispatcherPrivate_h
FunctorHandler(const Fun &fun)
FunctorRefDispatcherHelper(const FunctorRefDispatcherHelper &rhs)
ResultType operator()(BaseLhs &lhs, BaseRhs &rhs)
bool before(const TypeInfo &rhs) const
bool operator<(const TypeInfo &lhs, const TypeInfo &rhs)
bool operator==(const TypeInfo &lhs, const TypeInfo &rhs)
FunctorRefDispatcherHelper(const FunctorRefDispatcherHelper &rhs)
double get(vtkDataArray *const &arr, vtkIdType key)
static U * Clone(U *pObj)
ResultType operator()(BaseLhs &lhs)
const std::type_info & Get() const
FunctorDoubleDispatcherHelper(Fun fun)
virtual FunctorHandler * DoClone() const
bool operator>(const TypeInfo &lhs, const TypeInfo &rhs)
Base::ResultType ResultType
FunctorRefDispatcherHelper(Fun &fun)
bool operator>=(const TypeInfo &lhs, const TypeInfo &rhs)
virtual R operator()(P1 &, P2 &)=0
FunctorImpl< R, Parm1, Parm2 > Impl
FunctorDoubleDispatcherHelper(const FunctorDoubleDispatcherHelper &rhs)
const char * name() const
FunctorImpl(const FunctorImpl &)
Functor(const Functor &rhs)
static To * Cast(From *obj)
FunctorImpl(const FunctorImpl &)
virtual FunctorImpl * DoClone() const =0
Functor & operator=(const Functor &rhs)
ResultType operator()(BaseLhs &lhs)
static To & Cast(From &obj)
virtual ~FunctorHandler()
virtual ~FunctorHandler()
virtual R operator()(P1 &)=0
Functor(const Functor &rhs)
Base::ResultType ResultType
ResultType operator()(Parm1 &p1)
FunctorRefDispatcherHelper(Fun &f)
ResultType operator()(Parm1 &p1)
ResultType operator()(Parm1 &p1, Parm2 &p2)
static To & Cast(From &obj)
ResultType operator()(BaseLhs &lhs, BaseRhs &rhs)
virtual FunctorHandler * DoClone() const
static U * Clone(U *pObj)
static To * Cast(From *obj)
FunctorDispatcherHelper(Fun fun)
Functor & operator=(const Functor &rhs)
bool operator!=(const TypeInfo &lhs, const TypeInfo &rhs)
virtual FunctorImpl * DoClone() const =0
bool operator<=(const TypeInfo &lhs, const TypeInfo &rhs)
ResultType operator()(Parm1 &p1, Parm2 &p2)
FunctorImpl< R, Parm1 > Impl
FunctorDispatcherHelper(const FunctorDispatcherHelper &rhs)