00001 #ifndef LrmSkeleton_HPP 00002 #define LrmSkeleton_HPP 00003 00004 #include <string> 00005 00006 class ExecutionSpecs; 00007 class LrmImpl; 00008 class Config; 00009 struct lua_State; 00010 00011 using std::string; 00012 00013 //IMPORTANT: This class is not multithread-safe. Users of this class must ensure that 00014 // 'state' is safely isolated when concurrently accessed 00015 class LrmSkeleton{ 00016 00017 private: 00018 00019 //Fields-------------------------------------------------------------------------- 00020 struct lua_State * serverSideState; 00021 LrmImpl * lrmImpl_; 00022 string lrmIor_; //FIXME: Needed? 00023 static LrmSkeleton * singleInstance_; 00027 //Methods------------------------------------------------------------------------- 00028 00029 LrmSkeleton(LrmImpl * lrmImpl, const Config & config); 00030 00031 // Wrappers to servant method implementation(Required by Lua) 00032 // Needed because O2 must call a LrmImpl method when a remote call 00033 // arrives. The problem is that we MUST register a function pointer 00034 // in Lua RT in order to lua call LrmImpl. In C++, the only way to 00035 // do that is via a class method (We cannot pass a pointer to a member 00036 // function). So, the instance (LrmImpl is a singleton) is aceesed 00037 // via this class method. 00038 00042 static void * serverSideSetup(void * ptr); 00043 00044 00051 static int setSampleIntervalWrapper(struct lua_State * state); 00052 00059 static int setKeepAliveIntervalWrapper(struct lua_State * state); 00060 00067 static int remoteExecutionRequestWrapper(struct lua_State * state); 00068 00069 //TODO: COMMENT ME 00070 static int requestOutputFilesWrapper(struct lua_State * state); 00071 00072 //TODO: COMMENT ME 00073 static int killWrapper(struct lua_State * state); 00074 00075 public: 00076 00077 static LrmSkeleton & init(LrmImpl * lrmImpl, const Config & config); 00078 static LrmSkeleton & singleInstance(){ return *LrmSkeleton::singleInstance_; } 00079 00080 const string & lrmIor() const{ return lrmIor_; } 00081 00082 00083 }; 00084 00085 #endif//LrmSkeleton_HPP 00086