Back to index

supertuxkart  0.5+dfsg1
user_pointer.hpp
Go to the documentation of this file.
00001 //  $Id: user_pointer.hpp 839 2006-10-24 00:01:56Z hiker $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2007 Joerg Henrichs
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  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
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_USER_POINTER_H
00021 #define HEADER_USER_POINTER_H
00022 
00026 class TriangleMesh;
00027 class Moveable;
00028 class Flyable;
00029 class Kart;
00030 class MovingPhysics;
00031 
00032 class UserPointer
00033 {
00034 public:
00035     enum   UserPointerType {UP_UNDEF, UP_KART, UP_FLYABLE, UP_TRACK,
00036                             UP_MOVING_PHYSICS};
00037 private:
00038     void*  m_pointer;
00039     UserPointerType m_user_pointer_type;
00040 public:
00041     bool            is(UserPointerType t)     const {return m_user_pointer_type==t;    }
00042     TriangleMesh*   getPointerTriangleMesh()  const {return (TriangleMesh*)m_pointer;  }
00043     Moveable*       getPointerMoveable()      const {return (Moveable*)m_pointer;      }
00044     Flyable*        getPointerFlyable()       const {return (Flyable*)m_pointer;       }
00045     Kart*           getPointerKart()          const {return (Kart*)m_pointer;          }
00046     MovingPhysics*  getPointerMovingPhysics() const {return (MovingPhysics*)m_pointer; }
00047     void            set(MovingPhysics* p) { m_user_pointer_type=UP_MOVING_PHYSICS;
00048                                             m_pointer          =p;           }
00049     void            set(Kart* p)          { m_user_pointer_type=UP_KART;
00050                                             m_pointer          =p;           }
00051     void            set(Flyable* p)       { m_user_pointer_type=UP_FLYABLE;
00052                                             m_pointer          =p;           }
00053     void            set(TriangleMesh* p)  { m_user_pointer_type=UP_TRACK;
00054                                             m_pointer          =p;           }
00055                     UserPointer()         { zero();                          }
00056     void            zero()                { m_user_pointer_type=UP_UNDEF;
00057                                             m_pointer          = NULL;       }
00058 };
00059 #endif
00060 /* EOF */
00061