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;
388 bool before(
const TypeInfo& rhs)
const;
389 const char*
name()
const;
392 const std::type_info* pInfo_;
397 inline TypeInfo::TypeInfo()
400 pInfo_ = &
typeid(Nil);
404 inline TypeInfo::TypeInfo(
const std::type_info& ti)
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 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)
ResultType operator()(Parm1 &p1, Parm2 &p2) override
~FunctorHandler() override
static U * Clone(U *pObj)
ResultType operator()(BaseLhs &lhs)
const std::type_info & Get() const
FunctorDoubleDispatcherHelper(Fun fun)
~FunctorHandler() override
bool operator>(const TypeInfo &lhs, const TypeInfo &rhs)
Base::ResultType ResultType
FunctorRefDispatcherHelper(Fun &fun)
bool operator>=(const TypeInfo &lhs, const TypeInfo &rhs)
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)
FunctorHandler * DoClone() const override
FunctorImpl(const FunctorImpl &)
Functor & operator=(const Functor &rhs)
ResultType operator()(BaseLhs &lhs)
static To & Cast(From &obj)
FunctorHandler * DoClone() const override
Functor(const Functor &rhs)
Base::ResultType ResultType
ResultType operator()(Parm1 &p1) override
FunctorRefDispatcherHelper(Fun &f)
ResultType operator()(Parm1 &p1)
static To & Cast(From &obj)
ResultType operator()(BaseLhs &lhs, BaseRhs &rhs)
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)
bool operator<=(const TypeInfo &lhs, const TypeInfo &rhs)
ResultType operator()(Parm1 &p1, Parm2 &p2)
FunctorImpl< R, Parm1 > Impl
FunctorDispatcherHelper(const FunctorDispatcherHelper &rhs)