00001 #ifndef AsctSkeleton_HPP 00002 #define AsctSkeleton_HPP 00003 00004 #include <string> 00005 #include <map> 00006 00007 class ExecutionSpecs; 00008 class AsctImpl; 00009 class Config; 00010 struct lua_State; 00011 00012 using std::string; 00013 using std::map; 00014 00015 //IMPORTANT: This class is not multithread-safe. Users of this class must ensure that 00016 // 'state' is safely isolated when concurrently accessed 00017 class AsctSkeleton{ 00018 00019 private: 00020 00021 //Fields-------------------------------------------------------------------------- 00022 struct lua_State * serverSideState; 00023 AsctImpl * asctImpl_; 00024 string asctIor_; //FIXME: Needed? 00025 static AsctSkeleton * singleInstance_; 00026 map<string, string> bspZerosIors_; 00027 00028 00029 00030 //Methods------------------------------------------------------------------------- 00031 00032 AsctSkeleton(AsctImpl * asctImpl, const Config & config); 00033 00034 // Wrappers to servant method implementation(Required by Lua) 00035 // Needed because O2 must call a AsctImpl method when a remote call 00036 // arrives. The problem is that we MUST register a function pointer 00037 // in Lua RT in order to lua call AsctImpl. In C++, the only way to 00038 // do that is via a class method (We cannot pass a pointer to a member 00039 // function). So, the instance (AsctImpl is a singleton) is aceesed 00040 // via this class method. 00041 00042 00046 static int requestInputFilesWrapper(struct lua_State * state); 00047 00054 static int acceptedExecutionRequestWrapper(struct lua_State * state); 00055 00062 static int refusedExecutionRequestWrapper(struct lua_State * state); 00063 00064 00071 static int appFinishedWrapper(struct lua_State * state); 00072 00073 00074 00078 static void * serverSideSetup(void * ptr); 00079 00080 //FIXME: COMMENT ME 00081 //Dummy impl. Present only to conform with ASCT interface 00082 static int registerBspNodeWrapper(struct lua_State * state); 00083 00084 public: 00085 00086 static AsctSkeleton & init(AsctImpl * asctImpl, const Config & config); 00087 static AsctSkeleton & singleInstance(){ return *AsctSkeleton::singleInstance_; } 00088 00089 const string & asctIor() const{ return asctIor_; } 00090 00091 00092 }; 00093 00094 #endif//AsctSkeleton_HPP 00095