Libbarrett
1.2.4
|
00001 /* 00002 Copyright 2009, 2010 Barrett Technology <support@barrett.com> 00003 00004 This file is part of libbarrett. 00005 00006 This version of libbarrett is free software: you can redistribute it 00007 and/or modify it under the terms of the GNU General Public License as 00008 published by the Free Software Foundation, either version 3 of the 00009 License, or (at your option) any later version. 00010 00011 This version of libbarrett is distributed in the hope that it will be 00012 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License along 00017 with this version of libbarrett. If not, see 00018 <http://www.gnu.org/licenses/>. 00019 00020 Further, non-binding information about licensing is available at: 00021 <http://wiki.barrett.com/libbarrett/wiki/LicenseNotes> 00022 */ 00023 00024 /* 00025 * tuple_splitter.h 00026 * 00027 * Created on: Feb 2, 2011 00028 * Author: dc 00029 */ 00030 00031 #ifndef BARRETT_SYSTEMS_TUPLE_SPLITTER_H_ 00032 #define BARRETT_SYSTEMS_TUPLE_SPLITTER_H_ 00033 00034 00035 #include <boost/tuple/tuple.hpp> 00036 #include <Eigen/Core> 00037 00038 #include <barrett/systems/abstract/system.h> 00039 #include <barrett/systems/abstract/single_io.h> 00040 #include <barrett/systems/detail/tuple_splitter-helper.h> 00041 00042 00043 namespace barrett { 00044 namespace systems { 00045 00046 00047 template < 00048 typename T0 = boost::tuples::null_type, 00049 typename T1 = boost::tuples::null_type, 00050 typename T2 = boost::tuples::null_type, 00051 typename T3 = boost::tuples::null_type, 00052 typename T4 = boost::tuples::null_type, 00053 typename T5 = boost::tuples::null_type, 00054 typename T6 = boost::tuples::null_type, 00055 typename T7 = boost::tuples::null_type, 00056 typename T8 = boost::tuples::null_type, 00057 typename T9 = boost::tuples::null_type> 00058 class TupleSplitter : public System, 00059 public SingleInput< 00060 boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> > { 00061 public: 00062 typedef boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> tuple_type; 00063 static const size_t NUM_OUTPUTS = boost::tuples::length<tuple_type>::value; 00064 00065 00066 // IO 00067 private: detail::OutputHolder< 00068 NUM_OUTPUTS, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> outputs; 00069 00070 00071 public: 00072 TupleSplitter(const std::string& sysName = "TupleSplitter") : 00073 System(sysName), SingleInput<tuple_type>(this), outputs(this) {} 00074 virtual ~TupleSplitter() { mandatoryCleanUp(); } 00075 00076 template<size_t N> 00077 Output<typename boost::tuples::element<N, tuple_type>::type >& getOutput() { 00078 return outputs.getOutput<N>(); 00079 } 00080 00081 protected: 00082 virtual void operate() { 00083 outputs.setData( &(this->input.getValue()) ); 00084 } 00085 00086 private: 00087 DISALLOW_COPY_AND_ASSIGN(TupleSplitter); 00088 00089 public: 00090 // To be safe, assume that at least one of the input types needs to be aligned. 00091 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00092 }; 00093 00094 00095 } 00096 } 00097 00098 00099 #endif /* BARRETT_SYSTEMS_TUPLE_SPLITTER_H_ */