Libbarrett  1.2.4
include/barrett/systems/tuple_grouper.h
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_grouper.h
00026  *
00027  *  Created on: Nov 16, 2009
00028  *      Author: dc
00029  */
00030 
00031 #ifndef BARRETT_SYSTEMS_TUPLE_GROUPER_H_
00032 #define BARRETT_SYSTEMS_TUPLE_GROUPER_H_
00033 
00034 
00035 #include <boost/tuple/tuple.hpp>
00036 #include <Eigen/Core>  // For aligned operator new
00037 
00038 #include <barrett/detail/ca_macro.h>
00039 #include <barrett/systems/abstract/system.h>
00040 #include <barrett/systems/abstract/single_io.h>
00041 #include <barrett/systems/detail/tuple_grouper-helper.h>
00042 
00043 
00044 namespace barrett {
00045 namespace systems {
00046 
00047 
00048 template <
00049         typename T0 = boost::tuples::null_type,
00050         typename T1 = boost::tuples::null_type,
00051         typename T2 = boost::tuples::null_type,
00052         typename T3 = boost::tuples::null_type,
00053         typename T4 = boost::tuples::null_type,
00054         typename T5 = boost::tuples::null_type,
00055         typename T6 = boost::tuples::null_type,
00056         typename T7 = boost::tuples::null_type,
00057         typename T8 = boost::tuples::null_type,
00058         typename T9 = boost::tuples::null_type>
00059 class TupleGrouper : public System,
00060                                          public SingleOutput<
00061                                                  boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> > {
00062 public:
00063         typedef boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> tuple_type;
00064         static const size_t NUM_INPUTS = boost::tuples::length<tuple_type>::value;
00065 
00066 
00067 // IO
00068 private:        detail::InputHolder<
00069                                 NUM_INPUTS, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> inputs;
00070 
00071 
00072 public:
00073         TupleGrouper(const std::string& sysName = "TupleGrouper") :
00074                 System(sysName), SingleOutput<tuple_type>(this), inputs(this) {}
00075         virtual ~TupleGrouper() { mandatoryCleanUp(); }
00076 
00077         template<size_t N>
00078         Input<typename boost::tuples::element<N, tuple_type>::type >& getInput() {
00079                 return inputs.getInput<N>();
00080         }
00081 
00082 protected:
00083         virtual void operate() {
00084                 this->outputValue->setData( &(inputs.getValues()) );
00085         }
00086 
00087 private:
00088         DISALLOW_COPY_AND_ASSIGN(TupleGrouper);
00089 
00090 public:
00091         // To be safe, assume that at least one of the input types needs to be aligned.
00092         EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00093 };
00094 
00095 
00096 }
00097 }
00098 
00099 
00100 #endif /* BARRETT_SYSTEMS_TUPLE_GROUPER_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Defines