Libbarrett  1.2.4
include/barrett/systems/abstract/single_io.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  * single_io.h
00026  *
00027  *  Created on: Sep 12, 2009
00028  *      Author: dc
00029  */
00030 
00031 #ifndef BARRETT_SYSTEMS_ABSTRACT_SINGLE_IO_H_
00032 #define BARRETT_SYSTEMS_ABSTRACT_SINGLE_IO_H_
00033 
00034 
00035 #include <barrett/detail/ca_macro.h>
00036 #include <barrett/systems/abstract/system.h>
00037 #include <barrett/systems/abstract/conversion.h>
00038 
00039 
00040 namespace barrett {
00041 namespace systems {
00042 
00043 
00044 template<typename InputType>
00045 class SingleInput {  // not a System in order to avoid diamond inheritance
00046 // IO
00047 public: System::Input<InputType> input;
00048 
00049 
00050 public:
00051         explicit SingleInput(System* parentSys) :
00052                 input(parentSys) {}
00053 
00054 private:
00055         DISALLOW_COPY_AND_ASSIGN(SingleInput);
00056 };
00057 
00058 
00059 template<typename OutputType>
00060 class SingleOutput {  // not a System in order to avoid diamond inheritance
00061 // IO
00062 public:         System::Output<OutputType> output;
00063 protected:      typename System::Output<OutputType>::Value* outputValue;
00064 
00065 
00066 public:
00067         explicit SingleOutput(System* parentSys) :
00068                 output(parentSys, &outputValue) {}
00069 
00070 private:
00071         DISALLOW_COPY_AND_ASSIGN(SingleOutput);
00072 };
00073 
00074 
00075 template<typename InputType, typename OutputType>
00076 class SingleIO :        public System, public SingleInput<InputType>,
00077                                         public SingleOutput<OutputType>,
00078                                         public Conversion<OutputType> {
00079 public:
00080         explicit SingleIO(const std::string& sysName = "SingleIO") :
00081                 System(sysName),
00082                 SingleInput<InputType>(this), SingleOutput<OutputType>(this) {}
00083         virtual ~SingleIO() { mandatoryCleanUp(); }
00084 
00085         virtual System::Input<InputType>* getConversionInput() {
00086                 return &(this->input);
00087         }
00088         virtual System::Output<OutputType>& getConversionOutput() {
00089                 return this->output;
00090         }
00091 
00092 private:
00093         DISALLOW_COPY_AND_ASSIGN(SingleIO);
00094 };
00095 
00096 
00097 }
00098 }
00099 
00100 
00101 #endif /* BARRETT_SYSTEMS_ABSTRACT_SINGLE_IO_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Defines