|
| Script () |
| Initialises to a script with no text and no variables. More...
|
|
const std::string & | text () const |
| Returns the complete text of this script. More...
|
|
void | setText (const std::string &newText) |
| Replaces the complete text of this script with the given string. More...
|
|
void | append (const std::string &extraText) |
| Adds the given text to the end of this script. More...
|
|
size_t | countVariables () const |
| Returns the number of variables associated with this script. More...
|
|
const std::string & | variableName (size_t index) const |
| Returns the name of the requested variable associated with this script. More...
|
|
long | variableIndex (const std::string &name) const |
| Returns the index of the variable stored with the given name. More...
|
|
Packet * | variableValue (size_t index) const |
| Returns the value of the requested variable associated with this script. More...
|
|
Packet * | variableValue (const std::string &name) const |
| Returns the value of the variable stored with the given name. More...
|
|
void | setVariableName (size_t index, const std::string &name) |
| Changes the name of an existing variable associated with this script. More...
|
|
void | setVariableValue (size_t index, Packet *value) |
| Changes the value of an existing variable associated with this script. More...
|
|
bool | addVariable (const std::string &name, Packet *value) |
| Attempts to add a new variable to be associated with this script. More...
|
|
const std::string & | addVariableName (const std::string &name, Packet *value) |
| Adds a new variable to be associated with this script, changing its name if necessary. More...
|
|
void | removeVariable (const std::string &name) |
| Removes the variable stored with the given name. More...
|
|
void | removeVariable (size_t index) |
| Removes the variable stored at the given index. More...
|
|
void | removeAllVariables () |
| Removes all variables associated with this script. More...
|
|
virtual void | writeTextShort (std::ostream &out) const override |
| Writes a short text representation of this object to the given output stream. More...
|
|
virtual void | writeTextLong (std::ostream &out) const override |
| Writes a detailed text representation of this object to the given output stream. More...
|
|
virtual bool | dependsOnParent () const override |
| Determines if this packet depends upon its parent. More...
|
|
virtual void | packetWasRenamed (Packet *packet) override |
| Called after the packet label or tags have been changed. More...
|
|
virtual void | packetToBeDestroyed (PacketShell packet) override |
| Called before the packet is about to be destroyed. More...
|
|
std::string | str () const |
| Returns a short text representation of this object. More...
|
|
std::string | utf8 () const |
| Returns a short text representation of this object using unicode characters. More...
|
|
std::string | detail () const |
| Returns a detailed text representation of this object. More...
|
|
bool | hasSafePtr () const |
| Is there one or more SafePtr currently pointing to this object? More...
|
|
|
bool | save (const char *filename, bool compressed=true) const |
| Saves the subtree rooted at this packet to the given Regina data file, using Regina's native XML file format. More...
|
|
bool | save (std::ostream &s, bool compressed=true) const |
| Writes the subtree rooted at this packet to the given output stream, in the format of a Regina XML data file. More...
|
|
void | writeXMLFile (std::ostream &out) const |
| Writes the subtree rooted at this packet to the given output stream in Regina's native XML file format. More...
|
|
std::string | internalID () const |
| Returns a unique string ID that identifies this packet. More...
|
|
bool | hasOwner () const |
| Indicates whether some other object in the calculation engine is responsible for ultimately destroying this object. More...
|
|
void | writeXMLPacketTree (std::ostream &out) const |
| Writes a chunk of XML containing the subtree with this packet as matriarch. More...
|
|
A packet representing a Python script that can be run.
A script consists of two parts: (i) the text, which contains the Python code; and (ii) a set of variables, which refer to packets in your packet tree. When running a script, the variables should be instantiated in the default namespace before the script is run.
The values of variables are given by pointers to packets (not packet labels, as in some old versions of Regina). This affects how variables react to changes in the packets that they point to. In particular, if a variable V points to some packet P, then:
- if P is renamed then V will still point to it and the script will notify listeners that the script has changed;
- if P is deleted then V will take the value
None
, and the script will likewise notify listeners of the change.