Go to the documentation of this file.
30 #ifndef vtkDispatcher_Private_h
31 #define vtkDispatcher_Private_h
43 template <
class BaseLhs,
59 return fun_(CastLhs::Cast(lhs));
68 template <
class BaseLhs,
84 return fun_(CastLhs::Cast(lhs));
92 template <
typename R,
typename P1>
105 if (!pObj)
return nullptr;
106 U* pClone = static_cast<U*>(pObj->DoClone());
107 assert(
typeid(*pClone) ==
typeid(*pObj));
120 template <
class ParentFunctor,
typename Fun>
123 typedef typename ParentFunctor::Impl Base;
145 template <
typename R,
typename Parm1>
152 #if defined(VTK_HAS_STD_UNIQUE_PTR)
162 template <
typename Fun>
170 #if defined(VTK_HAS_STD_UNIQUE_PTR)
171 spImpl_.swap(copy.spImpl_);
174 Impl* p = spImpl_.release();
175 spImpl_.reset(copy.spImpl_.release());
176 copy.spImpl_.reset(p);
183 {
return (*spImpl_)(p1); }
185 #if defined(VTK_HAS_STD_UNIQUE_PTR)
186 std::unique_ptr<Impl> spImpl_;
188 std::auto_ptr<Impl> spImpl_;
202 template <
class BaseLhs,
class BaseRhs,
203 class SomeLhs,
class SomeRhs,
205 class CastLhs,
class CastRhs,
217 return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs));
223 template <
class BaseLhs,
class BaseRhs,
224 class SomeLhs,
class SomeRhs,
226 class CastLhs,
class CastRhs,
238 return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs));
246 template <
typename R,
typename P1,
typename P2>
260 if (!pObj)
return nullptr;
261 U* pClone = static_cast<U*>(pObj->DoClone());
262 assert(
typeid(*pClone) ==
typeid(*pObj));
275 template <
class ParentFunctor,
typename Fun>
278 typedef typename ParentFunctor::Impl Base;
288 {
return f_(p1,p2); }
301 template <
typename R,
typename Parm1,
typename Parm2>
308 #if defined(VTK_HAS_STD_UNIQUE_PTR)
318 template <
typename Fun>
326 #if defined(VTK_HAS_STD_UNIQUE_PTR)
327 spImpl_.swap(copy.spImpl_);
328 #else // swap auto_ptrs by hand
329 Impl* p = spImpl_.release();
330 spImpl_.reset(copy.spImpl_.release());
331 copy.spImpl_.reset(p);
337 {
return (*spImpl_)(p1,p2); }
339 #if defined(VTK_HAS_STD_UNIQUE_PTR)
340 std::unique_ptr<Impl> spImpl_;
342 std::auto_ptr<Impl> spImpl_;
350 template <
class To,
class From>
355 return dynamic_cast<To&>(obj);
360 return dynamic_cast<To*>(obj);
364 template <
class To,
class From>
369 return *(To::SafeDownCast(&obj));
374 return To::SafeDownCast(obj);
386 const std::type_info&
Get()
const;
389 const char*
name()
const;
392 const std::type_info* pInfo_;
400 pInfo_ = &
typeid(Nil);
412 return pInfo_->before(*rhs.pInfo_) != 0;
424 return pInfo_->name();
431 {
return (lhs.
Get() == rhs.
Get()) != 0; }
434 {
return lhs.
before(rhs); }
437 {
return !(lhs == rhs); }
440 {
return rhs < lhs; }
443 {
return !(lhs > rhs); }
446 {
return !(lhs < rhs); }
451 #endif // vtkDispatcherPrivate_h
ResultType operator()(BaseLhs &lhs)
Functor & operator=(const Functor &rhs)
FunctorDispatcherHelper(const FunctorDispatcherHelper &rhs)
static To * Cast(From *obj)
bool operator>(const TypeInfo &lhs, const TypeInfo &rhs)
ResultType operator()(Parm1 &p1) override
ResultType operator()(BaseLhs &lhs)
FunctorHandler(const Fun &fun)
static To & Cast(From &obj)
ResultType operator()(Parm1 &p1, Parm2 &p2) override
FunctorImpl< R, Parm1, Parm2 > Impl
bool operator<(const TypeInfo &lhs, const TypeInfo &rhs)
static To * Cast(From *obj)
FunctorHandler * DoClone() const override
bool operator==(const TypeInfo &lhs, const TypeInfo &rhs)
~FunctorHandler() override
FunctorDoubleDispatcherHelper(const FunctorDoubleDispatcherHelper &rhs)
ResultType operator()(BaseLhs &lhs, BaseRhs &rhs)
static U * Clone(U *pObj)
FunctorRefDispatcherHelper(Fun &f)
virtual R operator()(P1 &, P2 &)=0
FunctorDoubleDispatcherHelper(Fun fun)
const std::type_info & Get() const
FunctorRefDispatcherHelper(const FunctorRefDispatcherHelper &rhs)
~FunctorHandler() override
Functor(const Functor &rhs)
double get(vtkDataArray *const &arr, vtkIdType key)
FunctorImpl(const FunctorImpl &)
bool operator>=(const TypeInfo &lhs, const TypeInfo &rhs)
FunctorImpl(const FunctorImpl &)
virtual R operator()(P1 &)=0
static To & Cast(From &obj)
FunctorHandler * DoClone() const override
FunctorRefDispatcherHelper(const FunctorRefDispatcherHelper &rhs)
FunctorImpl< R, Parm1 > Impl
const char * name() const
ResultType operator()(Parm1 &p1)
bool operator<=(const TypeInfo &lhs, const TypeInfo &rhs)
static U * Clone(U *pObj)
Base::ResultType ResultType
Functor(const Functor &rhs)
virtual FunctorImpl * DoClone() const =0
ResultType operator()(Parm1 &p1, Parm2 &p2)
bool operator!=(const TypeInfo &lhs, const TypeInfo &rhs)
bool before(const TypeInfo &rhs) const
Base::ResultType ResultType
virtual FunctorImpl * DoClone() const =0
FunctorDispatcherHelper(Fun fun)
FunctorRefDispatcherHelper(Fun &fun)
ResultType operator()(BaseLhs &lhs, BaseRhs &rhs)
Functor & operator=(const Functor &rhs)