AnalogProxy.h

Go to the documentation of this file.
00001 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00002  *
00003  * VR Juggler is (C) Copyright 1998-2005 by Iowa State University
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Christopher Just,
00007  *   Patrick Hartling, Kevin Meinert,
00008  *   Carolina Cruz-Neira, Albert Baker
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Library General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Library General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Library General Public
00021  * License along with this library; if not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023  * Boston, MA 02111-1307, USA.
00024  *
00025  * -----------------------------------------------------------------
00026  * File:          $RCSfile$
00027  * Date modified: $Date: 2006-12-09 13:42:12 -0600 (Sat, 09 Dec 2006) $
00028  * Version:       $Revision: 19596 $
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
00032 
00034 //
00035 // positional proxy class
00036 //
00038 
00039 #ifndef _GADGET_ANALOGPROXY_H_
00040 #define _GADGET_ANALOGPROXY_H_
00041 
00042 #include <gadget/gadgetConfig.h>
00043 #include <gadget/Type/Analog.h>
00044 #include <gadget/Type/Proxy.h>
00045 #include <gadget/Type/AnalogData.h>
00046 
00047 namespace gadget
00048 {
00049 
00061 class GADGET_CLASS_API AnalogProxy : public TypedProxy<Analog>
00062 {
00063 
00064 public:
00066    AnalogProxy()
00067       : mUnitNum(-1)
00068       , mData(-1.0f)
00069    {;}
00070 
00071    virtual ~AnalogProxy()
00072    {;}
00073 
00075    virtual void updateData()
00076    {
00077       if(!isStupefied())
00078       {
00079          // Make sure dependencies are updated.
00080          getProxiedInputDevice()->updateDataIfNeeded();
00081          mData = mTypedDevice->getAnalogData(mUnitNum);
00082       }
00083    }
00084 
00086    virtual vpr::Interval getTimeStamp() const
00087    {
00088       return mData.getTime();
00089    }
00090 
00095    float getData() const
00096    {
00097       const float analogDefault(0.0f);
00098       if(isStupefied())
00099       {
00100          return analogDefault;
00101       }
00102       else
00103       {
00104          return mData.getAnalog();
00105       }
00106    }
00107 
00109    Analog* getAnalogPtr()
00110    {
00111       if(isStupefied())
00112       {
00113          return NULL;
00114       }
00115       else
00116       {
00117          return mTypedDevice;
00118       }
00119    }
00120 
00125    int getUnit() const
00126    {
00127       return mUnitNum;
00128    }
00129 
00130    static std::string getElementType();
00131 
00132    bool config(jccl::ConfigElementPtr element);
00133 
00134    virtual Input* getProxiedInputDevice()
00135    {
00136       if((NULL == mTypedDevice) || (mStupefied))
00137       {
00138          return NULL;
00139       }
00140 
00141       Input* ret_val = dynamic_cast<Input*>(mTypedDevice);
00142       vprASSERT((ret_val != NULL) && "Cross-cast in AnalogProxy failed");
00143       return ret_val;
00144    }
00145 
00146 private:
00147    int         mUnitNum;
00148    AnalogData  mData;
00149 };
00150 
00151 } // End of gadget namespace
00152 
00153 #endif

Generated on Thu Jan 4 10:41:54 2007 for Gadgeteer by  doxygen 1.5.1