1 /* 2 * dependcy.h 3 * Dependency class 4 * AYM 2000-04-09 5 */ 6 7 8 /* This class, along with the Serial_num class, allow one to 9 express a relationship of dependency (think makefiles) 10 between two objects. For the sake of discussion, let's assume 11 that class Target depends on class Source. 12 13 Make Source use a Serial_num object and make it call 14 Serial_num::bump() whenever it changes. Make Target use a 15 Dependency object. The Dependency object should be 16 constructed with a pointer to the Serial_num member of Source. 17 18 In all public methods of Target, start by checking whether 19 Source has been modified while we were out by calling 20 Dependency::outdated(). If the latter returns true, Target 21 shall update itself based on the new state of Source and then 22 call Dependency::update(). */ 23 24 25 #ifndef YH_DEPENDCY /* DO NOT INSERT ANYTHING BEFORE THIS LINE */ 26 #define YH_DEPENDCY 27 28 29 class Serial_num; // Defined in serialnum.h 30 typedef unsigned long serial_num_t; // Copied from serialnum.h 31 32 33 class Dependency 34 { 35 public : 36 Dependency (Serial_num *sn); 37 bool outdated (); 38 void update (); 39 40 private : 41 Serial_num *serial_num; 42 serial_num_t token; 43 bool token_valid; 44 }; 45 46 47 #endif /* DO NOT ADD ANYTHING AFTER THIS LINE */ 48