00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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