torcs - 1.2.2

src/modules/simu/simuv2.sav/SOLID-2.0/src/RespTable.h

Go to the documentation of this file.
00001 /*
00002   SOLID - Software Library for Interference Detection
00003   Copyright (C) 1997-1998  Gino van den Bergen
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Library General Public
00007   License as published by the Free Software Foundation; either
00008   version 2 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Library General Public License for more details.
00014 
00015   You should have received a copy of the GNU Library General Public
00016   License along with this library; if not, write to the Free
00017   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019   Please send remarks, questions and bug reports to gino@win.tue.nl,
00020   or write to:
00021                   Gino van den Bergen
00022                   Department of Mathematics and Computing Science
00023                   Eindhoven University of Technology
00024                   P.O. Box 513, 5600 MB Eindhoven, The Netherlands
00025 */
00026 
00027 #ifndef _RESPTABLE_H_
00028 #define _RESPTABLE_H_
00029 
00030 #include "Response.h"
00031 
00032 #include <SOLID/solid.h>
00033 #include <map>
00034 
00035 typedef map<DtObjectRef, Response, less<DtObjectRef> > SingleList;
00036 typedef pair<DtObjectRef, DtObjectRef> ObjPair;
00037 typedef map<ObjPair, Response, less<ObjPair> > PairList;
00038 
00039 inline ObjPair make_ObjPair(DtObjectRef x, DtObjectRef y) {
00040   return y < x ? make_pair(y, x) : make_pair(x, y);
00041 }
00042 
00043 class RespTable {
00044 public:
00045   const Response& find(DtObjectRef obj1, DtObjectRef obj2) const;
00046   void cleanObject(DtObjectRef obj);
00047 
00048   void setDefault(const Response& resp) { defaultResp = resp; }
00049   
00050   void setSingle(DtObjectRef obj, const Response& resp) { 
00051     singleList[obj] = resp; 
00052   }
00053 
00054   void resetSingle(DtObjectRef obj) { singleList.erase(obj); }
00055   
00056   void setPair(DtObjectRef obj1, DtObjectRef obj2, const Response& resp) {
00057     pairList[make_ObjPair(obj1, obj2)] = resp;
00058   }
00059 
00060   void resetPair(DtObjectRef obj1, DtObjectRef obj2) { 
00061     pairList.erase(make_ObjPair(obj1, obj2)); 
00062   }
00063 
00064     
00065   
00066 private:
00067   Response defaultResp;
00068   SingleList singleList;
00069   PairList pairList;
00070 };
00071 
00072 #endif

Generated at Thu Feb 26 21:52:31 2004 for torcs by doxygen 1.3.3 written by Dimitri van Heesch, © 1997-1999
TORCS © Eric Espié 1999, 2002.