ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/CallbackFunctor.hpp
Revision: 1284
Committed: Mon Jun 21 18:52:21 2004 UTC (20 years ago) by tim
File size: 1540 byte(s)
Log Message:
roll in progress

File Contents

# User Rev Content
1 tim 1232 #ifndef _CALLBACK_FUNCTOR_H_
2     #define _CALLBACK_FUNCTOR_H_
3     #include <map>
4     #include <utility>
5     #include "TypeInfo.hpp"
6     using namespace std;
7    
8     class ConstraintPair;
9     class ConstraintElement;
10     class SimInfo;
11     class ConstraintAtom;
12     class ConstraintRigidBody;
13    
14     class CallbackFunctor{
15 gezelter 1252 public:
16     typedef pair<TypeInfo, TypeInfo> KeyType;
17     typedef int (CallbackFunctor::*MappedType)(ConstraintElement*, ConstraintElement*);
18     typedef map<KeyType, MappedType> DoubleDispatchMap;
19    
20     virtual ~CallbackFunctor(){}
21    
22 tim 1284 //operator() is responsible for double dispatching
23 gezelter 1252 int operator()(ConstraintPair* consPair);
24    
25     //double dispatch map can not store virtual function
26     //below functions are just wrapping functions which will be forwarded to virtual function
27     int constrainAtomAtom(ConstraintElement* ce1, ConstraintElement* ce2);
28     int constrainAtomRigidBody(ConstraintElement* ce1, ConstraintElement* ce2);
29     int constrainRigidBodyAtom(ConstraintElement* ce1, ConstraintElement* ce2);
30     int constrainRigidBodyRigidBody(ConstraintElement* ce1, ConstraintElement* ce2);
31    
32     protected:
33     CallbackFunctor(SimInfo* rhs);
34    
35     void registerFunction(const KeyType& key, MappedType f);
36    
37     //
38     virtual int operator()(ConstraintAtom*, ConstraintAtom*) = 0;
39     virtual int operator()(ConstraintAtom*, ConstraintRigidBody*) = 0;
40     virtual int operator()(ConstraintRigidBody*, ConstraintRigidBody*) = 0;
41    
42     SimInfo* info;
43     ConstraintPair* curPair;
44    
45     DoubleDispatchMap ddMap;
46    
47     const double consTolerance;
48 tim 1232 };
49    
50     #endif //end ifndef _CALLBACK_FUNCTOR_H_

Properties

Name Value
svn:executable *