Homepage Demos Overview Downloads Tutorials Reference
Credits

OutputCmd.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_OutputCmd_h
00003 #define INCLUDED_OutputCmd_h
00004 
00005 //! This object holds all the information needed to control a single output
00006 class OutputCmd {
00007 public:
00008 
00009   OutputCmd() : value(0), weight(0) {} //!< Constructor
00010   OutputCmd(float v) : value(v), weight(1) {} //!< Constructor
00011   OutputCmd(float v, float w) : value(v), weight(w) {} //!< Constructor
00012   OutputCmd(const OutputCmd& a, const OutputCmd& b, float w) : value(a.value*w+b.value*(1-w)), weight(a.weight*w+b.value*(1-w)) {} //!< Constructor, see set(a,b,w)
00013 
00014   inline void set(float v, float w=1) { value=v; weight=w; } //!< sets the value to @a v and weight to @a w
00015   inline void set(const OutputCmd& a, const OutputCmd& b, float w) { value=a.value*w+b.value*(1-w); weight=a.weight*w+b.weight*(1-w); } //!< sets the value to a weighted average of @a a and @a b (higher @a w, more @a a)
00016   inline void unset() { value=weight=0; } //!< sets value and weight to 0
00017   bool operator==(const OutputCmd& c) const { return value==c.value && weight==c.weight; } //!< tests for equality of weight and value
00018   bool operator!=(const OutputCmd& c) const { return value!=c.value || weight!=c.weight; } //!< tests for inequality of weight and value
00019 
00020   float value; //!< value of the output
00021   float weight; //!< weight to be used in averaging, 0 to "fall through"
00022   static OutputCmd unused; //!< handy sometimes for returning a reference to a 0,0 cmd
00023 };
00024 
00025 /*! @file
00026  * @brief Describes OutputCmd, holds information needed to control a single output
00027  * @author ejt (Creator)
00028  *
00029  * $Author: ejt $
00030  * $Name: tekkotsu-2_2_1 $
00031  * $Revision: 1.3 $
00032  * $State: Rel $
00033  * $Date: 2003/09/07 22:14:01 $
00034  */
00035 
00036 #endif

Tekkotsu v2.2.1
Generated Tue Nov 23 16:36:39 2004 by Doxygen 1.3.9.1