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));
119 template <class ParentFunctor,typename Fun>
122 typedef typename ParentFunctor::Impl Base;
137 FunctorHandler& operator =(
const FunctorHandler& b) VTK_DELETE_FUNCTION;
144 template <
typename R,
typename Parm1>
151 #if defined(VTK_HAS_STD_UNIQUE_PTR)
161 template <
typename Fun>
169 #if defined(VTK_HAS_STD_UNIQUE_PTR)
170 spImpl_.swap(copy.spImpl_);
173 Impl* p = spImpl_.release();
174 spImpl_.reset(copy.spImpl_.release());
175 copy.spImpl_.reset(p);
182 {
return (*spImpl_)(p1); }
184 #if defined(VTK_HAS_STD_UNIQUE_PTR)
185 std::unique_ptr<Impl> spImpl_;
187 std::auto_ptr<Impl> spImpl_;
201 template <
class BaseLhs,
class BaseRhs,
202 class SomeLhs,
class SomeRhs,
204 class CastLhs,
class CastRhs,
216 return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs));
222 template <
class BaseLhs,
class BaseRhs,
223 class SomeLhs,
class SomeRhs,
225 class CastLhs,
class CastRhs,
237 return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs));
245 template <
typename R,
typename P1,
typename P2>
253 virtual R operator()(
P1&,
P2&) = 0;
260 U* pClone =
static_cast<U*
>(pObj->DoClone());
261 assert(
typeid(*pClone) ==
typeid(*pObj));
274 template <class ParentFunctor,typename Fun>
277 typedef typename ParentFunctor::Impl Base;
287 {
return f_(p1,p2); }
294 FunctorHandler& operator =(
const FunctorHandler& b) VTK_DELETE_FUNCTION;
300 template <
typename R,
typename Parm1,
typename Parm2>
307 #if defined(VTK_HAS_STD_UNIQUE_PTR)
317 template <
typename Fun>
325 #if defined(VTK_HAS_STD_UNIQUE_PTR)
326 spImpl_.swap(copy.spImpl_);
327 #else // swap auto_ptrs by hand
328 Impl* p = spImpl_.release();
329 spImpl_.reset(copy.spImpl_.release());
330 copy.spImpl_.reset(p);
336 {
return (*spImpl_)(p1,p2); }
338 #if defined(VTK_HAS_STD_UNIQUE_PTR)
339 std::unique_ptr<Impl> spImpl_;
341 std::auto_ptr<Impl> spImpl_;
349 template <
class To,
class From>
354 return dynamic_cast<To&
>(obj);
359 return dynamic_cast<To*
>(obj);
363 template <
class To,
class From>
368 return *(To::SafeDownCast(&obj));
373 return To::SafeDownCast(obj);
385 const std::type_info& Get()
const;
387 bool before(
const TypeInfo& rhs)
const;
388 const char*
name()
const;
391 const std::type_info* pInfo_;
396 inline TypeInfo::TypeInfo()
399 pInfo_ = &
typeid(Nil);
403 inline TypeInfo::TypeInfo(
const std::type_info& ti)
411 return pInfo_->before(*rhs.pInfo_) != 0;
423 return pInfo_->name();
430 {
return (lhs.
Get() == rhs.
Get()) != 0; }
433 {
return lhs.
before(rhs); }
436 {
return !(lhs == rhs); }
439 {
return rhs < lhs; }
442 {
return !(lhs > rhs); }
445 {
return !(lhs < rhs); }
449 #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)
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)
bool operator<=(const TypeInfo &lhs, const TypeInfo &rhs)
ResultType operator()(Parm1 &p1, Parm2 &p2)
FunctorImpl< R, Parm1 > Impl
FunctorDispatcherHelper(const FunctorDispatcherHelper &rhs)