root/juggler/branches/2.2/modules/gadgeteer/gadget/Type/GestureProxy.h

Revision 19729, 3.9 kB (checked in by patrick, 2 years ago)

Copyright update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
2  *
3  * VR Juggler is (C) Copyright 1998-2007 by Iowa State University
4  *
5  * Original Authors:
6  *   Allen Bierbaum, Christopher Just,
7  *   Patrick Hartling, Kevin Meinert,
8  *   Carolina Cruz-Neira, Albert Baker
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  *
25  *************** <auto-copyright.pl END do not edit this line> ***************/
26
27 #ifndef _GADGET_GESTURE_PROXY_H_
28 #define _GADGET_GESTURE_PROXY_H_
29
30 #include <gadget/gadgetConfig.h>
31 #include <math.h>
32
33 #include <gadget/Type/Gesture.h>
34 #include <gadget/Type/Proxy.h>
35
36 namespace gadget
37 {
38
39 /** \class GestureProxy GestureProxy.h gadget/Type/GestureProxy.h
40  *
41  * Proxy to Gesture object.
42  *
43  * A proxy is used by the user to actually acces the gesture data.
44  * The proxy allows the user to query the current gesture information.
45  * Clients call the get* routines to get the current gesture (id or string)
46  * Once the client has the current gesture, they should test it
47  * against the gestures they want to respond to.
48  *
49  * @see gadget::Gesture
50  */
51 class GADGET_CLASS_API GestureProxy : public TypedProxy<Gesture>
52 {
53 public:
54    /** Constructs the proxy to point to the given gesture device. */
55    GestureProxy(const std::string& deviceName = "UnknownGesture")
56       : TypedProxy<Gesture>(deviceName)
57    {;}
58
59    virtual ~GestureProxy()
60    {;}
61
62    /**
63     * Gets the current gesture.
64     * @return id of current gesture.
65     */
66    int getGesture()
67    {
68       const int defaultGesture(-1);
69
70       if(isStupefied())
71          return defaultGesture;
72       else
73          return mTypedDevice->getGesture();
74    }
75
76    /**
77     * Returns the identifier of the string gesture.
78     * @param name The string name of a gesture.
79     * @return -1 if not found
80     */
81    int getGestureIndex(std::string name)
82    {
83       const int defaultGestureIndex(-1);
84       if(isStupefied())
85          return defaultGestureIndex;
86       else
87          return mTypedDevice->getGestureIndex(name);
88    }
89
90    /**
91     * Gets a gesture name.
92     * @return Name of gesture with the given id (gestureId).
93     * @note if gestureId = -1, returns name of current gesture.
94     */
95    std::string getGestureString(int gestureId = -1)
96    {
97       if(isStupefied())
98          return std::string("");
99       else
100          return mTypedDevice->getGestureString(gestureId);
101    }
102
103    /** Returns time of last update. */
104    vpr::Interval getTimeStamp() const
105    {
106       // XXX: Broken for now, this is a case similar to the KeyboardMouse type in that
107       //      it does not point to one data element like digital, analog, and position.
108       return vpr::Interval();
109    }
110
111    /** Returns a pointer to the device held by this proxy. */
112    Gesture* getGesturePtr()
113    {
114       if(isStupefied())
115          return NULL;
116       else
117          return mTypedDevice;
118    }
119
120    static std::string getElementType();
121
122    bool config(jccl::ConfigElementPtr element);
123
124    virtual Input* getProxiedInputDevice()
125    {
126       if((NULL == mTypedDevice) || (isStupefied)())
127          return NULL;
128
129       Input* ret_val = dynamic_cast<Input*>(mTypedDevice);
130       vprASSERT((ret_val != NULL) && "Cross-cast in GestureProxy failed");
131       return ret_val;
132    }
133 };
134
135 } // End of gadget namespace
136
137 #endif
Note: See TracBrowser for help on using the browser.