libs/ck-libs/pose/rep.h

Go to the documentation of this file.
00001 
00002 
00005 #ifndef REP_H
00006 #define REP_H
00007 #include "sim.decl.h"
00008 
00009 extern CProxy_sim POSE_Objects_RO;
00010 
00011 // our configuration bundle
00012 extern POSE_Config pose_config;
00013 
00015 class rep 
00016 {
00017  protected:
00019   strat *myStrat;          
00020  public:
00021 #if POSE_COMM_ON
00022   CProxy_sim POSE_Objects;
00023 #endif
00025   sim *parent;             
00027 
00028   int myHandle;            
00030   POSE_TimeType ovt;
00032   double ort;
00034   unsigned int prand_seed;
00036   unsigned short int prand48_seed[3];
00038   int anti_methods;
00039 #ifdef MEM_TEMPORAL
00040   TimePool *localTimePool;
00041 #endif
00043   rep() { 
00044     ovt = 0; ort = 0.0; parent = NULL; myStrat = NULL; 
00045     anti_methods = 0;
00046   #ifndef SEQUENTIAL_POSE
00047   #ifdef POSE_COMM_ON    
00048     POSE_Objects = POSE_Objects_RO;
00049     ComlibDelegateProxy(&POSE_Objects);
00050   #endif
00051   #endif
00052 #ifdef MEM_TEMPORAL    
00053     localTimePool = (TimePool *)CkLocalBranch(TempMemID);
00054 #endif
00055   }
00057   rep(POSE_TimeType init_ovt) { 
00058     ovt = init_ovt; ort = 0.0; anti_methods = 0;
00059       }
00061   virtual ~rep() {
00062      }
00064   void init(eventMsg *m);
00066   POSE_TimeType OVT() { return ovt; }
00068   void SetOVT(POSE_TimeType t) { ovt = t; }
00070   void useAntimethods() { anti_methods = 1; }
00072   void turnOffAntimethods() { anti_methods = 0; }
00074   int usesAntimethods() { return anti_methods; }
00076   void elapse(POSE_TimeType dt) { ovt += dt; }
00078 
00080   void update(POSE_TimeType t, double rt);
00082   virtual void terminus() { 
00083     //CkPrintf("Object %d terminus at time %d\n", myHandle, ovt);
00084   }
00086   virtual void registerTimestamp(int idx, eventMsg *m, POSE_TimeType offset);
00088 
00089   virtual rep& operator=(const rep& obj) { 
00090     ovt = obj.ovt; 
00091     ort = obj.ort;
00092     myHandle = obj.myHandle;
00093     anti_methods = obj.anti_methods;
00094     prand_seed = obj.prand_seed;
00095     prand48_seed[0]=obj.prand48_seed[0];
00096     prand48_seed[1]=obj.prand48_seed[1];
00097     prand48_seed[2]=obj.prand48_seed[2];
00098     return *this;
00099   }
00101 #if USE_LONG_TIMESTAMPS
00102   virtual void dump() { CkPrintf("[REP: ovt=%lld]\n", ovt); }
00103 #else
00104   virtual void dump() { CkPrintf("[REP: ovt=%d]\n", ovt); }
00105 #endif
00107 
00108   virtual void pup(PUP::er &p) { 
00109     p(ovt); p(ort); p(myHandle); p(anti_methods); p(prand48_seed,3);
00110   }
00111 #ifdef SEQUENTIAL_POSE
00112   void checkpoint(rep *) { }
00113   void restore(rep *) { }
00114 #endif  
00115   void POSE_srand(unsigned int pseed) { prand_seed = pseed; }
00116   int POSE_rand() { 
00117     int rnum; 
00118     srand(prand_seed); 
00119     rnum = rand(); 
00120     prand_seed = rnum+INT_MAX; 
00121     return rnum; 
00122   }
00123   unsigned int POSE_urand() { 
00124     int rnum; 
00125     srand(prand_seed); 
00126     rnum = rand(); 
00127     prand_seed = rnum+INT_MAX; 
00128     return prand_seed;
00129   }
00130   inline long int POSE_Linear_rand() { return nrand48(prand48_seed); }
00131   inline double POSE_Uniform_rand() { return erand48(prand48_seed); }
00132 
00133 };
00134 
00135 #endif

Generated on Sun Jun 29 13:29:25 2008 for Charm++ by  doxygen 1.5.1