trick/trick_source/sim_services/JITInputFile/include/JITEvent.hh
Alex Lin 24fe5adaec JITEvents are not checkpointable
Changed the way JITEvents are created and handled. Instead of taking a function pointer directly we save a name of a function to the JITEvent class.  The class will dynamically look up a function that matches the name both during event creation and during checkpoint restart.

Fixes #53
2015-05-14 13:41:17 -05:00

62 lines
1.2 KiB
C++

/**
PURPOSE:
(blah.)
LIBRARY DEPENDENCY:
((../src/JITEvent.cpp))
*/
#ifndef JITEVENT_HH
#define JITEVENT_HH
#include <functional>
#include <iostream>
#include <string>
#include "sim_services/include/mm_macros.hh"
#include "sim_services/EventManager/include/Event.hh"
namespace Trick {
/**
* This is a cyclic event class. It holds a cycle time, and the function to call.
*
* @author Alexander S. Lin
*
* @date April 2014
*
*/
class JITEvent : public Trick::Event {
TRICK_MM_FRIENDS(Trick__JITEvent)
public:
JITEvent() ;
JITEvent(std::string func_name, std::string in_name = "JIT_no_name" , double in_cycle = 1.0) ;
/** calls the function_ptr job */
virtual int process( long long curr_time ) ;
/** called when the event is added to the event manager */
virtual void add() {} ;
/** called when the event is removed from the event manager */
virtual void remove() {} ;
virtual void restart() ;
std::string func_name ;
protected:
void get_func_ptr_from_name() ;
/** pointer to funtion to run when event fires */
int (*func_ptr)(void) ; // trick_io(**)
} ;
}
#endif