ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ConstraintAlgorithm.hpp
Revision: 1268
Committed: Fri Jun 11 17:16:21 2004 UTC (20 years ago) by tim
File size: 2550 byte(s)
Log Message:
roll in progress

File Contents

# Content
1 #ifndef _CONSTRAINTALGORITHM_H_
2 #define _CONSTRAINTALGORITHM_H_
3
4 #include <iostream>
5 #include <map>
6 #include "CallbackFunctor.hpp"
7 #include "TypeInfo.hpp"
8 #include "ConstraintIterator.hpp"
9 using namespace std;
10
11 class ConstraintManager;
12 class ConstraintPair;
13 class JointConstraintPair;
14 class DistanceConstraintPair;
15 class SimInfo;
16
17 enum ConsAlgoStatus{
18 consExceedMaxIter = -4, //can not constrain the bond within maximum iteration
19 consPairHandlerFail = -3, //can not found call back functor for constraint pair
20 consElemHandlerFail = -2, //can not found callback functor for constraint element
21 consFail = -1, //Constraint Fail
22 consSuccess = 0, //constrain the pair by moving two elements
23 consAlready = 1}; //current pair is already constrained, do not need to move the elements
24
25 ////////////////////////////////////////////////////////////////////////////////
26 //Declaration of ConstraintAlgorithm
27 ////////////////////////////////////////////////////////////////////////////////
28 //base class of constraint algorithm
29 //Actuallly we encount a triple dispatch problem here, something like
30 //ConstrainPair(ConsPairType*, ConsElementType1*, ConsElementType2*)
31 //To solve this problem, we apply visitor pattern and standard double dispatch technique
32 class ConstraintAlgorithm{
33
34 public:
35 virtual ~ConstraintAlgorithm();
36 virtual void doConstrain();
37
38 //using RTTI (Run Time Type Information) to dispatch
39 int doConstrainPair(ConstraintPair* consPair);
40 void registerCallback(const TypeInfo& ti, CallbackFunctor* functor);
41 void unRegister(TypeInfo& ti);
42 bool haveError() { return error;}
43 protected:
44 ConstraintAlgorithm(SimInfo* rhs);
45
46 SimInfo* info;
47 ConstraintPairIterator* cpIter;
48 ConstraintElementIterator* ceIter;
49
50 map<TypeInfo, CallbackFunctor*> callbackMap;
51
52 bool error;
53 };
54
55 ////////////////////////////////////////////////////////////////////////////////
56 //Declaration of ConsAlgoFramework
57 ////////////////////////////////////////////////////////////////////////////////
58 class ConsAlgoFramework{
59 public:
60 ~ConsAlgoFramework();
61
62 void doPreConstraint();
63
64 protected:
65 ConsAlgoFramework(SimInfo* rhs);
66
67 private:
68 ConstraintElementIterator* ceIter;
69
70 };
71
72 //Velocity Verlet constraint algorithm frame work
73 class VelVerletConsFramework : public ConsAlgoFramework{
74 public:
75 virtual int doConstrainA() = 0;
76 virtual int doConstrainB() = 0;
77 protected:
78 VelVerletConsFramework(SimInfo* rhs) : ConsAlgoFramework(rhs){}
79 };
80
81 #endif //endif _CONSTRAINTALGORITHM_H_

Properties

Name Value
svn:executable *