Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

Lease_Impl.h

Go to the documentation of this file.
00001 
00002 #include "LeasingS.h"
00003 
00017 class Lease_Impl : public POA_Lease
00018 {
00019 public:
00020 
00032   Lease_Impl (TimeBase::TimeT expiration_time,
00033               LookupService_ptr lookup_service,
00034               const CosNaming::Name &name,
00035               LeaseHolder_ptr lease_holder)
00036     : lookup_service_ ( LookupService::_duplicate (lookup_service)), 
00037       lease_holder_ (LeaseHolder::_duplicate (lease_holder)),
00038       expiration_time_ (expiration_time), 
00039       name_ (name), 
00040       valid_lease_ (TRUE)
00041   {
00042   }
00043   
00050   void renew (TimeBase::TimeT duration)
00051     throw (InvalidDuration)
00052   {
00053     TimeBase::TimeT accepted_duration = 
00054       lookup_service_->prolong_lease (this->_this (), duration);
00055     
00056     if (accepted_duration != 0)
00057       {
00058         expiration_time_ = current_time () + accepted_duration;
00059         valid_lease_ = TRUE;
00060       }
00061   }
00062 
00068   TimeBase::TimeT get_remaining_time ()
00069   {
00070     if (valid_lease_)
00071       return expiration_time_-current_time ();
00072     else
00073       return 0;
00074   }
00075 
00079   void expired () 
00080   {
00081     valid_lease_ = FALSE;
00082   }
00083   
00089   LeaseHolder_ptr get_lease_holder ()
00090   {
00091     return LeaseHolder::_duplicate (lease_holder_);
00092   }
00093   
00099   CosNaming::Name *get_name ()
00100   {
00101     return &name_;
00102   }
00103   
00104 private:
00105   
00106   TimeBase::TimeT current_time ()
00107   {
00108     
00109   }
00110   
00111   LookupService_var lookup_service_;
00112   LeaseHolder_var lease_holder_;
00113   TimeBase::TimeT expiration_time_;
00114   CosNaming::Name name_;
00115   bool valid_lease_;
00116 };

These pages document the source code of the patterns Lookup, Eager Acquisition, and Leasing.

Copyright 2004 John Wiley and Sons. All Rights Reserved.