Kinetic::Simulator::Event

Definition

The concept Kinetic::Simulator::Event represents a single event. Models of Kinetic::Simulator::Event should be passed to the Kinetic::Simulator when scheduling events which will in turn pass them to the EventQueue.

Operations

void a.process () This method is called when the event occurs. This method will only be called once per time this event is scheduled and the event will be removed from the queue immediately afterwards.

void* a.kds () Return a void * which represents the KDS which this event belongs to. The pointer is used solely to tell if two events come from the same KDS for the purposes of handling degeneracy.

CGAL::Comparison_result a.compare_concurrent ( Key a, Key b) const
The two events a and b occur at the same time (this has key a). This method returns a CGAL::Comparison_result which is used to order the two equal events. If CGAL::EQUAL is returned then merge will be called.

bool a.merge_concurrent ( Key a, Key b)
The two events a and b occur at the same time (this has key a) and cannot be perturbed to be unequal. This event allows the KDS to merge event b with a. If it returns true then b is dropped from the event queue.

void a.audit ( Key this_key) Audit that this is a valid event. To use this, kinetic data structure can check that this event is indeed pointed to by the correct part of the combinatorial structure.

std::ostream& a.write ( std::ostream&) const Write the event to a stream.

Has Models

All over the place. Kinetic::Event_base.

See Also

Kinetic::EventQueue

Example

All of the kinetic data structures provided have models of Kinetic::Simulator::Event. Here is the code implementing a swap event from the sorting kinetic data structure. Events occuring at equal times are perturbed so that the one that occurs first in the list is processed first (just to illustrate the idea).

template <class Certificate, class Id, class Root_enumerator> 
class Swap_event {
  typedef Swap_event<class Certificate, class Id, class Root_enumerator> This;
public:
  Swap_event(Id o, Sort* sorter, 
	     const Certificate &s): left_object_(o), 
                                    sorter_(sorter), 
                                    s_(s){}
  void process(){
    sorter_->swap(left_object_, s_);
  }
  void *kds() const {return sorter_;}
  CGAL::Comparison_result perturb_comparison(typename Sort::Event_key a, typename Sort::Event_key b) const {
    return CGAL::compare(std::distance(sorter_->objects_begin(), left_object_),
                         std::distance(sorter_->objects_begin(),
			               sorter_->simulator_handle()->get_event<This>(b).left_object_));
  }
  bool merge(typename Sort::Event_key a, typename Sort::Event_key b) {
    return false;
  }
  Id left_object_; 
  Sort* sorter_; 
  Certificate s_;
};