00001 # ifndef __dependency_h
00002 # define __dependency_h
00003
00004
00005
00006
00007
00008
00009
00010
00011 class DependencyUnit {
00012 protected:
00013 struct Node {
00014 DependencyUnit ** dependency ;
00015 Node * next ;
00016
00017 Node( DependencyUnit ** u, Node * n = 0 ) : dependency(u), next(n) {}
00018 ~Node() { delete next ; }
00019 } *head, **tail ;
00020
00021
00022
00023 protected:
00024
00025
00026
00027
00028
00029
00030 virtual DependencyUnit * duplicate(void) const = 0 ;
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 virtual void setDependency(void) {}
00041
00042 private:
00043
00044 DependencyUnit * replica ;
00045 bool copying ;
00046
00047 void precopy(void);
00048 void docopy(void);
00049 void postcopy(void);
00050
00051 public:
00052
00053
00054
00055
00056 virtual DependencyUnit * copy(void);
00057
00058 public:
00059
00060 DependencyUnit() :
00061 head(0), tail(&head), replica(0), copying(false) { setDependency(); }
00062 DependencyUnit(const DependencyUnit& u ) :
00063 head(0), tail(&head), replica(0), copying(false) { setDependency(); }
00064
00065 void addDependency( DependencyUnit ** u )
00066 { *tail = new Node(u,0); tail = &((*tail)->next); }
00067 void removeDependency( DependencyUnit ** u );
00068 void removeAllDependency(void) { delete head ; head = 0 ; tail = &head ; }
00069 virtual ~DependencyUnit() { removeAllDependency(); }
00070 };
00071
00072
00073 # endif //__dependency_h