00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef ORO_DATASOURCE_ARGS_EVENT_HPP
00040 #define ORO_DATASOURCE_ARGS_EVENT_HPP
00041
00042 #include "DataSource.hpp"
00043 #include "LocalEvent.hpp"
00044 #include "FunctorDataSource.hpp"
00045
00046 namespace RTT
00047 {
00048 namespace detail
00049 {
00054 template<class SignatureT, class FunctorT = detail::FunctorDataSource<boost::function<SignatureT> > >
00055 class DataSourceArgsEvent
00056 : public ActionInterface
00057 {
00058 typename FunctorT::shared_ptr mmeth;
00059 public:
00060 typedef boost::function_traits<SignatureT> traits;
00061 typedef SignatureT Signature;
00062
00063 typedef typename boost::function_traits<Signature>::result_type result_type;
00064 typedef ActionInterface Base;
00065
00066 DataSourceArgsEvent(boost::function<Signature> meth)
00067 : mmeth( new FunctorT(meth) )
00068 {
00069 }
00070
00071 DataSourceArgsEvent( typename FunctorT::shared_ptr ds)
00072 : mmeth( ds )
00073 {
00074 }
00075
00076 DataSourceArgsEvent<Signature,FunctorT>* create() const
00077 {
00078 return clone();
00079 }
00080
00081 template<class Arg1T>
00082 DataSourceArgsEvent<Signature,FunctorT>* create(DataSource<Arg1T>* a1) const
00083 {
00084 DataSourceArgsEvent<Signature,FunctorT>* r = this->clone();
00085 r->mmeth->setArguments(a1);
00086 return r;
00087 }
00088
00089 template<class Arg1T, class Arg2T>
00090 DataSourceArgsEvent<Signature,FunctorT>* create(DataSource<Arg1T>* a1, DataSource<Arg2T>* a2) const
00091 {
00092 DataSourceArgsEvent<Signature,FunctorT>* r = this->clone();
00093 r->mmeth->setArguments(a1, a2);
00094 return r;
00095 }
00096
00097 template<class Arg1T, class Arg2T, class Arg3T>
00098 DataSourceArgsEvent<Signature,FunctorT>* create(DataSource<Arg1T>* a1, DataSource<Arg2T>* a2, DataSource<Arg3T>* a3) const
00099 {
00100 DataSourceArgsEvent<Signature,FunctorT>* r = this->clone();
00101 r->mmeth->setArguments(a1, a2, a3);
00102 return r;
00103 }
00104
00105 template<class Arg1T, class Arg2T, class Arg3T, class Arg4T>
00106 DataSourceArgsEvent<Signature,FunctorT>* create(DataSource<Arg1T>* a1, DataSource<Arg2T>* a2, DataSource<Arg3T>* a3, DataSource<Arg4T>* a4) const
00107 {
00108 DataSourceArgsEvent<Signature,FunctorT>* r = this->clone();
00109 r->mmeth->setArguments(a1, a2, a3, a4);
00110 return r;
00111 }
00112
00113 template<class Arg1T, class Arg2T, class Arg3T, class Arg4T, class Arg5T>
00114 DataSourceArgsEvent<Signature,FunctorT>* create(DataSource<Arg1T>* a1, DataSource<Arg2T>* a2, DataSource<Arg3T>* a3, DataSource<Arg4T>* a4, DataSource<Arg5T>* a5) const
00115 {
00116 DataSourceArgsEvent<Signature,FunctorT>* r = this->clone();
00117 r->mmeth->setArguments(a1, a2, a3, a4, a5);
00118 return r;
00119 }
00120
00121 template<class Arg1T, class Arg2T, class Arg3T, class Arg4T, class Arg5T, class Arg6T>
00122 DataSourceArgsEvent<Signature,FunctorT>* create(DataSource<Arg1T>* a1, DataSource<Arg2T>* a2, DataSource<Arg3T>* a3, DataSource<Arg4T>* a4, DataSource<Arg5T>* a5, DataSource<Arg6T>* a6) const
00123 {
00124 DataSourceArgsEvent<Signature,FunctorT>* r = this->clone();
00125 r->mmeth->setArguments(a1, a2, a3, a4, a5, a6);
00126 return r;
00127 }
00128
00129
00130 bool execute() {
00131 mmeth->get();
00132 return true;
00133 }
00134
00135 void readArguments() {
00136
00137 }
00138
00139 virtual DataSourceArgsEvent<Signature,FunctorT>* clone() const {
00140 return new DataSourceArgsEvent( typename FunctorT::shared_ptr(mmeth->clone()) );
00141 }
00142
00143 virtual ActionInterface* copy( std::map<const DataSourceBase*, DataSourceBase*>& alreadyCloned ) const
00144 {
00145 return new DataSourceArgsEvent<Signature,FunctorT>( typename FunctorT::shared_ptr(mmeth->copy(alreadyCloned)) );
00146 }
00147
00148 boost::function<Signature> getEventFunction() const {
00149 return mmeth.ff.gen;
00150 }
00151 };
00152 }
00153 }
00154
00155
00156 #endif