|
|
@ -37,33 +37,106 @@ namespace DFHack
|
|
|
|
class Context;
|
|
|
|
class Context;
|
|
|
|
class BadContexts;
|
|
|
|
class BadContexts;
|
|
|
|
class Process;
|
|
|
|
class Process;
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Used to enumerate, create and destroy Contexts. The very base of DFHack.
|
|
|
|
|
|
|
|
* @see DFHack::Context
|
|
|
|
|
|
|
|
*/
|
|
|
|
class DFHACK_EXPORT ContextManager
|
|
|
|
class DFHACK_EXPORT ContextManager
|
|
|
|
{
|
|
|
|
{
|
|
|
|
class Private;
|
|
|
|
class Private;
|
|
|
|
Private * const d;
|
|
|
|
Private * const d;
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Constructs the ContextManager.
|
|
|
|
|
|
|
|
* @param path_to_xml the path to the file that defines memory offsets. (Memory.xml)
|
|
|
|
|
|
|
|
*/
|
|
|
|
ContextManager(const std::string path_to_xml);
|
|
|
|
ContextManager(const std::string path_to_xml);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Destroys the ContextManager.
|
|
|
|
|
|
|
|
*/
|
|
|
|
~ContextManager();
|
|
|
|
~ContextManager();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Refresh the internal list of valid Context objects.
|
|
|
|
|
|
|
|
* @param bad_contexts pointer to a BadContexts object. Not required. All contexts are automatically destroyed if the object is not provided.
|
|
|
|
|
|
|
|
* @see DFHack::BadContexts
|
|
|
|
|
|
|
|
* @return Number of tracked contexts
|
|
|
|
|
|
|
|
*/
|
|
|
|
uint32_t Refresh(BadContexts* bad_contexts = 0);
|
|
|
|
uint32_t Refresh(BadContexts* bad_contexts = 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Get the number of tracked contexts.
|
|
|
|
|
|
|
|
* @return Number of tracked contexts
|
|
|
|
|
|
|
|
*/
|
|
|
|
uint32_t size();
|
|
|
|
uint32_t size();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Get a context by index
|
|
|
|
|
|
|
|
* @param index index of the context to be returned
|
|
|
|
|
|
|
|
* @return pointer to a Context
|
|
|
|
|
|
|
|
*/
|
|
|
|
Context * operator[](uint32_t index);
|
|
|
|
Context * operator[](uint32_t index);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Convenience method to return a single valid Context
|
|
|
|
|
|
|
|
* @return pointer to a Context
|
|
|
|
|
|
|
|
*/
|
|
|
|
Context * getSingleContext();
|
|
|
|
Context * getSingleContext();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Destroy all tracked Context objects
|
|
|
|
|
|
|
|
* Normally called during object destruction. Calling this from outside ContextManager is nasty.
|
|
|
|
|
|
|
|
*/
|
|
|
|
void purge(void);
|
|
|
|
void purge(void);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Class used for holding a set of invalidated Context AND Process objects temporarily and destroy them safely.
|
|
|
|
|
|
|
|
* @see DFHack::Context
|
|
|
|
|
|
|
|
* @see DFHack::Process
|
|
|
|
|
|
|
|
*/
|
|
|
|
class DFHACK_EXPORT BadContexts
|
|
|
|
class DFHACK_EXPORT BadContexts
|
|
|
|
{
|
|
|
|
{
|
|
|
|
class Private;
|
|
|
|
class Private;
|
|
|
|
Private * const d;
|
|
|
|
Private * const d;
|
|
|
|
void push_back(Context * c);
|
|
|
|
void push_back(Context * c);
|
|
|
|
friend class ContextManager;
|
|
|
|
friend class ContextManager;
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
BadContexts();
|
|
|
|
BadContexts();
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Destructor.
|
|
|
|
|
|
|
|
* All Processes and Contexts tracked by the BadContexts object will be destroyed also.
|
|
|
|
|
|
|
|
*/
|
|
|
|
~BadContexts();
|
|
|
|
~BadContexts();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Test if a Context is among the invalidated Contexts
|
|
|
|
|
|
|
|
* @param c pointer to a Context to be checked
|
|
|
|
|
|
|
|
* @return true if the Context is among the invalidated. false otherwise.
|
|
|
|
|
|
|
|
*/
|
|
|
|
bool Contains(Context* c);
|
|
|
|
bool Contains(Context* c);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Test if a Process is among the invalidated Processes/Contexts
|
|
|
|
|
|
|
|
* @param p pointer to a Process to be checked
|
|
|
|
|
|
|
|
* @see DFHack::Process
|
|
|
|
|
|
|
|
* @return true if the Process is among the invalidated. false otherwise.
|
|
|
|
|
|
|
|
*/
|
|
|
|
bool Contains(Process* p);
|
|
|
|
bool Contains(Process* p);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Get the number of tracked invalid contexts.
|
|
|
|
|
|
|
|
* @return Number of tracked invalid contexts
|
|
|
|
|
|
|
|
*/
|
|
|
|
uint32_t size();
|
|
|
|
uint32_t size();
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Get an invalid Context by index
|
|
|
|
|
|
|
|
* @param index index of the invalid Context to be returned
|
|
|
|
|
|
|
|
* @return pointer to an invalid Context
|
|
|
|
|
|
|
|
*/
|
|
|
|
Context * operator[](uint32_t index);
|
|
|
|
Context * operator[](uint32_t index);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} // namespace DFHack
|
|
|
|
} // namespace DFHack
|
|
|
|