TORCS  1.3.9
The Open Racing Car Simulator
RespTable.cpp
Go to the documentation of this file.
1 /*
2  SOLID - Software Library for Interference Detection
3  Copyright (C) 1997-1998 Gino van den Bergen
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public
16  License along with this library; if not, write to the Free
17  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 
19  Please send remarks, questions and bug reports to gino@win.tue.nl,
20  or write to:
21  Gino van den Bergen
22  Department of Mathematics and Computing Science
23  Eindhoven University of Technology
24  P.O. Box 513, 5600 MB Eindhoven, The Netherlands
25 */
26 
27 #ifdef _MSC_VER
28 #pragma warning(disable:4786) // identifier was truncated to '255'
29 #endif // _MSC_VER
30 
31 #include <vector>
32 
33 #include "RespTable.h"
34 
35 const Response& RespTable::find(DtObjectRef obj1, DtObjectRef obj2) const {
36  PairList::const_iterator i = pairList.find(make_ObjPair(obj1, obj2));
37  if (i != pairList.end()) return (*i).second;
38  SingleList::const_iterator j = singleList.find(obj1);
39  if (j != singleList.end()) return (*j).second;
40  j = singleList.find(obj2);
41  if (j != singleList.end()) return (*j).second;
42  return defaultResp;
43 }
44 
45 typedef vector<DtObjectRef> PartnerList;
47 
49  resetSingle(obj);
50  for (PairList::const_iterator i = pairList.begin();
51  i != pairList.end(); ++i) {
52  if ((*i).first.first == obj) {
53  partnerList.push_back((*i).first.second);
54  }
55  else if ((*i).first.second == obj) {
56  partnerList.push_back((*i).first.first);
57  }
58  }
59  while (!partnerList.empty()) {
60  resetPair(obj, partnerList.back());
61  partnerList.pop_back();
62  }
63 }
64 
void resetPair(DtObjectRef obj1, DtObjectRef obj2)
Definition: RespTable.h:64
void resetSingle(DtObjectRef obj)
Definition: RespTable.h:58
void cleanObject(DtObjectRef obj)
Definition: RespTable.cpp:48
PairList pairList
Definition: RespTable.h:73
vector< DtObjectRef > PartnerList
Definition: RespTable.cpp:45
PartnerList partnerList
Definition: RespTable.cpp:46
SingleList singleList
Definition: RespTable.h:72
void * DtObjectRef
Definition: solid.h:39
ObjPair make_ObjPair(DtObjectRef x, DtObjectRef y)
Definition: RespTable.h:43
Response defaultResp
Definition: RespTable.h:71
const Response & find(DtObjectRef obj1, DtObjectRef obj2) const
Definition: RespTable.cpp:35