Regina Calculation Engine
|
Provides a mechanism to resolve dangling packet references after a complete packet tree has been read from an XML data file. More...
#include <packet/xmltreeresolver.h>
Public Types | |
typedef std::map< std::string, Packet * > | IDMap |
A type that maps internal IDs from the data file to the corresponding packets. More... | |
Public Member Functions | |
XMLTreeResolver () | |
Constructs a resolver with no tasks queued. More... | |
~XMLTreeResolver () | |
Destroys any tasks that were queued but not performed. More... | |
void | queueTask (XMLTreeResolutionTask *task) |
Queues a task for processing. More... | |
void | storeID (const std::string &id, Packet *packet) |
Stores the fact that the given packet is stored in the data file using the given internal ID. More... | |
const IDMap & | ids () const |
Returns the map from internal IDs to packets, as stored in the data file. More... | |
void | resolve () |
Calls XMLTreeResolutionTask::resolve() for all queued tasks. More... | |
Provides a mechanism to resolve dangling packet references after a complete packet tree has been read from an XML data file.
There are situations in which, when reading an XML data file, the data stored in an individual packet cannot be fully constructed until after the entire data file has been read. For instance, a packet might need to store pointers or references to other packets that could appear later in the packet tree (e.g., a script storing pointers to its variables).
This problem is solved by the XMLTreeResolver class. The complete process of reading an XML data file works as follows:
Each task should be an instance of a subclass of XMLTreeResolutionTask, whose virtual resolve() function is overridden to perform whatever "fleshing out" work is required for the type of packet under consideration.