From 412bbb6fbf4b059f49608f382e5634055b3fda05 Mon Sep 17 00:00:00 2001 From: Stephen Roderick Date: Wed, 10 Feb 2010 13:48:58 -0500 Subject: [PATCH] method: Add functions to set the method from member functions or function objects --- src/Method.hpp | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/src/Method.hpp b/src/Method.hpp index 15f3b0e..c98dd59 100644 --- a/src/Method.hpp +++ b/src/Method.hpp @@ -222,6 +222,36 @@ namespace RTT void setMethodImpl( MethodBasePtr new_impl) const { this->impl = new_impl; } + + /** + * Assign a class member pointer and an object of that class to + * the Method. Does not change the Method's name. + * + * Use getMethodImpl() to retrieve the resulting implementation. + * + * @param meth A pointer to a class member function + * @param object An object of the class which has \a meth as member function. + */ + template + void setMethod(M meth, ObjectType object) + { + this->impl = MethodBasePtr(new detail::LocalMethod(meth, object) ); + } + + /** + * Assign a function pointer or function object to + * the Method. Does not change the Method's name. + * + * Use getMethodImpl() to retrieve the resulting implementation. + * + * @param meth A pointer to a class member function + * @param object An object of the class which has \a meth as member function. + */ + template + void setMethod(M meth) + { + this->impl = MethodBasePtr(new detail::LocalMethod(meth) ); + } }; /** -- 1.6.4.1