DFHack::Core modification: added a way to share void* between plugins and/or plugin unloads.

develop
Warmist 2011-08-04 22:00:21 +03:00
parent 89c1dba637
commit 9985b5de0f
2 changed files with 20 additions and 0 deletions

@ -469,6 +469,19 @@ std::string Core::getHotkeyCmd( void )
return returner; return returner;
} }
void Core::RegisterData(void *p,std::string key)
{
misc_data_map[key]=p;
}
void *Core::GetData(std::string key)
{
std::map<std::string,void*>::iterator it=misc_data_map.find(key);
if (it!=misc_data_map.end())
return misc_data_map[key];
else
return 0;// or throw an error.
}
void Core::Suspend() void Core::Suspend()
{ {

@ -126,6 +126,11 @@ namespace DFHack
/// removes the hotkey command and gives it to the caller thread /// removes the hotkey command and gives it to the caller thread
std::string getHotkeyCmd( void ); std::string getHotkeyCmd( void );
/// adds a named pointer (for later or between plugins)
void RegisterData(void *p,std::string key);
/// returns a named pointer.
void *GetData(std::string key);
DFHack::Process * p; DFHack::Process * p;
DFHack::VersionInfo * vinfo; DFHack::VersionInfo * vinfo;
DFHack::Console con; DFHack::Console con;
@ -174,5 +179,7 @@ namespace DFHack
tthread::condition_variable * HotkeyCond; tthread::condition_variable * HotkeyCond;
// Very important! // Very important!
bool started; bool started;
std::map<std::string,void*> misc_data_map;
}; };
} }