regina::XMLTreeResolver Class Reference
Basic Packet Types

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>`

Inheritance diagram for regina::XMLTreeResolver:

## 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...

## Detailed Description

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:

- The top-level routine managing the file I/O constructs a new XMLTreeResolver. This resolver is then passed to each XMLPacketReader in turn as each individual packet is read.
- If an XMLPacketReader is not able to fully flesh out its data because it requires information that is not yet available, it should create a new XMLTreeResolutionTask and queue this task to the resolver via XMLTreeResolver::queueTask().
- Once the entire packet tree has been read, the top-level file I/O manager will call XMLTreeResolver::resolve(). This will run XMLTreeResolutionTask::resolve() for each task in turn, whereby any missing data for individual packets can be resolved.

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.

The documentation for this class was generated from the following file:

- packet/xmltreeresolver.h

Copyright © 1999-2016, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@maths.uq.edu.au).