#ifndef ReactiveEngine_H
#define ReactiveEngine_H

/*
 *
 * nucleo/core/ReactiveEngine.H --
 *
 * Copyright (C) Nicolas Roussel
 *
 * See the file LICENSE for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 */

#include <nucleo/core/ReactiveObject.H>

namespace nucleo {

  // ----------------------------------------------------------

  class ReactiveEngineImplementation {

  public:

    virtual ~ReactiveEngineImplementation() {}

    virtual void notify(ReactiveObject *notified, Observable *notifier) = 0 ;

    // -1 means "wait for something to happen"
    // returns 0 if timedout
    virtual int step(long milliseconds=-1) = 0 ;

    virtual void run(void) = 0 ;
    virtual void stop(void) = 0 ;

  } ;

  // ----------------------------------------------------------

  class ReactiveEngine {

  private:

    static ReactiveEngineImplementation *engine ;
    static bool _useNativeEngine ;
    static void createEngine(void) ;

  public:

    static bool useNativeEngine(bool) ; // set and get
    static bool useNativeEngine(void) ; // get

    static void notify(ReactiveObject *notified, Observable *notifier) ;

    static int step(long milliseconds=-1) ; 

    static void run(void) ;
    static void stop(void) ;

  } ;

  // ----------------------------------------------------------

}

#endif
