\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 4.6 - Kinetic Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Kinetic::Simulator::Event Concept Reference

Definition

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

Has Models:

All over the place.

Kinetic::Event_base

See Also
Kinetic::EventQueue

Example

All of the kinetic data structures provided have models of 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_;
};

Operations

void process ()
 This method is called when the event occurs. More...
 
void * kds ()
 Return a void * which represents the KDS which this event belongs to. More...
 
CGAL::Comparison_result compare_concurrent (Key a, Key b) const
 The two events a and b occur at the same time (this has key a). More...
 
bool 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. More...
 
void audit (Key this_key)
 Audit that this is a valid event. More...
 
std::ostream & write (std::ostream &) const
 Write the event to a stream.
 

Member Function Documentation

void Kinetic::Simulator::Event::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.

CGAL::Comparison_result Kinetic::Simulator::Event::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.

void* Kinetic::Simulator::Event::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.

bool Kinetic::Simulator::Event::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 Kinetic::Simulator::Event::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.