Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

DeviceConstructor.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-2003 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: DeviceConstructor.h,v $
00027  * Date modified: $Date: 2003/07/10 23:59:00 $
00028  * Version:       $Revision: 1.4 $
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
00032 
00033 #ifndef _GADGET_DEVICE_CONSTRUCTOR_H_
00034 #define _GADGET_DEVICE_CONSTRUCTOR_H_
00035 
00036 #include <gadget/gadgetConfig.h>
00037 
00038 #include <string>
00039 #include <vpr/Util/Assert.h>
00040 #include <jccl/Config/ConfigElement.h>
00041 
00042 #include <gadget/InputManager.h>
00043 #include <gadget/Type/DeviceFactory.h>
00044 #include <gadget/Type/DeviceConstructorBase.h>
00045 
00046 
00047 namespace gadget
00048 {
00049 
00050 template <class DEV>
00051 class DeviceConstructor : public DeviceConstructorBase
00052 {
00053 public:
00054    DeviceConstructor(gadget::InputManager* inputMgr)
00055    {
00056       vprASSERT(DeviceFactory::instance() != NULL);
00057       vprASSERT(inputMgr != NULL);
00058       inputMgr->getDeviceFactory()->registerDevice(this);
00059    }
00060 
00061    Input* createDevice(jccl::ConfigElementPtr element)
00062    {
00063       DEV* new_dev = new DEV;
00064       bool success = new_dev->config(element);
00065       if(success)
00066       {
00067          return new_dev;
00068       }
00069       else
00070       {
00071          delete new_dev;
00072          return NULL;
00073       }
00074    }
00075 
00076    virtual std::string getElementType()
00077    {
00078       return DEV::getElementType();
00079    }
00080 };
00081 
00082 } // End of gadget namespace
00083 
00084 
00085 #endif

Generated on Sun May 2 14:25:14 2004 for Gadgeteer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002