HDK
|
#include <OP_BundleList.h>
Public Member Functions | |
OP_BundleList () | |
~OP_BundleList () | |
void | clear () |
Deletes all bundles (internal or non-internal). More... | |
int | entries () const |
Returns the number of non-internal bundles. More... | |
OP_Bundle * | getBundle (int i) |
Returns the i-th non-internal bundle. More... | |
OP_Bundle * | getBundle (const char *name) |
void | getBundlesByPattern (const char *pattern, UT_ValArray< OP_Bundle * > &bundles) |
Obtains the list of bundles whose names match the given pattern. More... | |
int | internalEntries () const |
Returns the number of internal bundles. More... | |
OP_Bundle * | getInternalBundle (int i) |
Returns the i-th internal bundle. More... | |
OP_Bundle * | createBundle (const char *name, int internal=0) |
OP_Bundle * | duplicateBundle (OP_Bundle *bundle) |
int | destroyBundle (const char *name) |
int | destroyBundle (int index) |
char * | findUniqueBundleName (const char *base=NULL) |
int | renameBundle (const char *oldname, const char *newname) |
int | getMemberships (const OP_Node *node, UT_ValArray< OP_Bundle * > &memberships) const |
const OP_BundleFilter * | setBundleFilter (const char *bname, const char *fname) |
const OP_BundleFilter * | lookupFilter (const char *name) const |
Returns the filter by the given name, or NULL if not found. More... | |
void | getFilters (UT_ValArray< const OP_BundleFilter * > &list) |
Obtains a list of existing filters. More... | |
void | bundleSetLock (OP_Bundle *bundle, bool lock) |
const OP_BundleFilter * | bundleSetFilter (OP_Bundle *bundle, const char *fname) |
const OP_BundleFilter * | bundleSetFilter (OP_Bundle *bundle, const OP_BundleFilter *filter) |
void | bundleSetPattern (OP_Bundle *bundle, const char *pattern) |
void | bundleClear (OP_Bundle *bundle) |
int | bundleAddOp (OP_Bundle *bundle, OP_Node *node) |
int | bundleAddOps (OP_Bundle *bundle, const OP_NodeList &nodes) |
int | bundleRemoveOp (OP_Bundle *bundle, OP_Node *node) |
int | bundleRemoveOps (OP_Bundle *bundle, const OP_NodeList &nodes) |
void | nodeAdded (OP_Node *node) |
void | nodeDeleted (OP_Node *node) |
void | nodeRenamed (OP_Node *node) |
void | refilterOp (OP_Node &node) |
void | bulkAddNodes (const OP_NodeList *nodes) |
int | getTouchTime () const |
OP_Bundle * | getPattern (UT_String &prev_bundle, const OP_Network *creator, const OP_Node *relativeto, const char *pattern, const char *filter=0, const char *label=0, bool subnet_inclusion=true, bool addinterest=1) |
void | deReferenceBundle (const UT_StringRef &prev_bundle) |
void | sortBundles () |
void | simplifyPattern (const OP_Node *root, UT_String &pattern) |
void | cmdLs (CMD_Args &args) |
Implements the hscript command that lists the bundles. More... | |
void | cmdAdd (CMD_Args &args) |
Implements the hscript command that adds a new bundle. More... | |
void | cmdRm (CMD_Args &args) |
Implements the hscript command that removes an old bundle. More... | |
void | cmdOp (CMD_Args &args) |
void | cmdName (CMD_Args &args) |
Implements the hscript command that renames a bundle. More... | |
int | saveToHip (std::ostream &os) |
Saves the bundle list to the hip file. More... | |
void | buildBundleMenu (PRM_Name *menu, int max, const char *filter=0, int include_at_sign=1, int put_in_default_message=1) |
void | notifyOpsOfGroupChange (OP_Group *group) |
UT_NotifierImpl < OP_BundleListEvent & > & | getEventNotifier () |
void | dumpFilters (std::ostream &os) |
Prints out all the available bundle filters. More... | |
Static Public Member Functions | |
static void | simplifyPatternSafely (const OP_Node *root, UT_String &pattern) |
static void | installCommands (CMD_Manager *cmd) |
Standard function that installs the bundle hscript commands. More... | |
Definition at line 55 of file OP_BundleList.h.
OP_BundleList::OP_BundleList | ( | ) |
OP_BundleList::~OP_BundleList | ( | ) |
void OP_BundleList::buildBundleMenu | ( | PRM_Name * | menu, |
int | max, | ||
const char * | filter = 0 , |
||
int | include_at_sign = 1 , |
||
int | put_in_default_message = 1 |
||
) |
Generates a menu contents that consists of the names of the available bundles.
menu | An output parameter that will contain new names representing the menu entries. |
max | The maximum number of entries that are allowed to be added. |
filter | If not NULL, the name of the filter that the bundles must have, if the are to be added to the menu. |
void OP_BundleList::bulkAddNodes | ( | const OP_NodeList * | nodes | ) |
Called when director is finished loading. It adds the nodes to any matching bundles.
A convenience method to add a node to the bundle, within an undo block, and to send out a notification.
int OP_BundleList::bundleAddOps | ( | OP_Bundle * | bundle, |
const OP_NodeList & | nodes | ||
) |
A convenience method to add nodes to the bundle, within an undo block, and to send out a notification.
A convenience method to remove all nodes from the bundle, within an undo block, and to send out a notification.
A convenience method to remove a node from the bundle, within an undo block, and to send out a notification.
int OP_BundleList::bundleRemoveOps | ( | OP_Bundle * | bundle, |
const OP_NodeList & | nodes | ||
) |
A convenience method to remove nodes from the bundle, within an undo block, and to send out a notification.
const OP_BundleFilter* OP_BundleList::bundleSetFilter | ( | OP_Bundle * | bundle, |
const char * | fname | ||
) |
A convenience method to set a filter on a bundle, within an undo block.
fname | The name of the new filter. |
const OP_BundleFilter* OP_BundleList::bundleSetFilter | ( | OP_Bundle * | bundle, |
const OP_BundleFilter * | filter | ||
) |
A convenience method to set a filter on a bundle, within an undo block.
A convenience method to set the lock on the member nodes of a bundle, within an undo bloc.
A convenience method to set a pattern on a bundle, within an undo block. If a bundle was a normal bundle, it is turned into a pattern bundle.
void OP_BundleList::clear | ( | ) |
Deletes all bundles (internal or non-internal).
Implements the hscript command that adds a new bundle.
Implements the hscript command that renames a bundle.
Implements the hscript command that manipulates bundle contents by adding, removing, or replacing the member nodes.
Implements the hscript command that removes an old bundle.
Creates and returns a new bundle.
name | The name of the bundle. |
internal | If true, the created bundle is internal. Otherwise, it's non-internal. |
void OP_BundleList::deReferenceBundle | ( | const UT_StringRef & | prev_bundle | ) |
Decreases the reference count of the bundle, and deletes it when it reaches zero. Used for discarding unwanted bundles that will no longer be used.
int OP_BundleList::destroyBundle | ( | const char * | name | ) |
Deletes the bundle of a given name. Before the bundle is deleted an event is sent out.
name | The name of the bundle to delete. |
void OP_BundleList::dumpFilters | ( | std::ostream & | os | ) |
Prints out all the available bundle filters.
Creates a duplicate of a given bundle. The new bundle's name is similar to the original, but a numerical suffix is appended.
bundle | The bundle to duplicate. |
|
inline |
Returns the number of non-internal bundles.
Definition at line 65 of file OP_BundleList.h.
char* OP_BundleList::findUniqueBundleName | ( | const char * | base = NULL | ) |
Returns a potential bundle name that has no duplicate among the existing bundles.
base | The desired name of the bundle. If that name is not taken, it will be returned. Otherwise, a numerical suffix will be appended. |
Returns the i-th non-internal bundle.
Definition at line 68 of file OP_BundleList.h.
OP_Bundle* OP_BundleList::getBundle | ( | const char * | name | ) |
Searches for the bundle by name, and returns it if found. Otherwise returns NULL.
void OP_BundleList::getBundlesByPattern | ( | const char * | pattern, |
UT_ValArray< OP_Bundle * > & | bundles | ||
) |
Obtains the list of bundles whose names match the given pattern.
|
inline |
Returns an obiect that emmits events that originated from the bundle list.
Definition at line 345 of file OP_BundleList.h.
void OP_BundleList::getFilters | ( | UT_ValArray< const OP_BundleFilter * > & | list | ) |
Obtains a list of existing filters.
Returns the i-th internal bundle.
Definition at line 82 of file OP_BundleList.h.
int OP_BundleList::getMemberships | ( | const OP_Node * | node, |
UT_ValArray< OP_Bundle * > & | memberships | ||
) | const |
Obtains an array of pointers to the non-internal bundles that the given node is a member of. This will NOT return indices to internal bundles.
OP_Bundle* OP_BundleList::getPattern | ( | UT_String & | prev_bundle, |
const OP_Network * | creator, | ||
const OP_Node * | relativeto, | ||
const char * | pattern, | ||
const char * | filter = 0 , |
||
const char * | label = 0 , |
||
bool | subnet_inclusion = true , |
||
bool | addinterest = 1 |
||
) |
Returns an internal bundle that has the specified pattern. If the bundle already exists (as specified by the name parameter) and the method parameters correspond to the bundle attributes, then it is reused and returned. Otherwise, a new bundle is created, configured, and returned; in this case, if there is any old bundle matching the given name, its reference count is decreased. This is handy for streamlined requests for internal pattern bundles, where this method can be invoked with the same UT_String object and different pattern, and the old bundles are seamlessly deleted and new ones created.
This method will get a pattern style (i.e. internal bundle) based on the creator and the pattern specified. The "style" parameter should be a unique string for the type of pattern (i.e. "lightmask"). To maintain proper reference counting, the method takes a reference to a pointer. This allows the list to maintain the list of referenced patterns. The subnet_inclusion argument determines whether subnet contents are included unless explicitly excluded.
prev_bundle | The name of the bundle created before based on a pattern (perhaps the same or perhaps different) used for the same purpose as the bundle obtained by this method. If, a bundle given by this parameter exists, and it is a of a different pattern, then its reference count will be decremented (and bundle deleted if it reaches zero). Upon return of this method, this parameter will contain the name of the new bundle. If prev_bundle exists, and it exhibits the same properties as specified in the method invocation, then that bundle is reused, the prev_bundle parameter is unchanged, and no reference count is bumped or decreased (ie, just reusing the bundle). This parameter can be an empty string (eg, when called for the very first time). |
creator | The node at which the search for matching nodes begins. It's like a root node in the node parenthood hierarchy. Only nodes contained by the creator are considered for the bundle membership; that is only children, grandchildreen, etc of the root node are considered. |
relativeto | The node with respect to which the relative node paths are specified in the pattern. |
pattern | The node name or path pattern. Any nodes that match the patterns will be included in the bundle. |
filter | The name of the OP_BundleFilter filter that needs to be applied to the bundle. Only nodes passing the filter test (usually the node type test) will be included in the bundle. |
label | An arbitrary label that is included in the construction of the name for the new bundle. May be used for differentiating between bundles with the same pattern and filter. |
subnet_inclusion | If true, a node will be included in the bundle if any of its ancestors (parent, grandparent, etc) matches the patter, even if the node itself does not match the pattern. |
addinterest | If true, the relativeto node will request an interest in the bundle, so it is dirtied an recooked whenever the contents of the returned internal pattern bundle changes. This is because it is usually the relativeto nodes that invoke this method during their cook path (and parameter evaluation), to gather any other nodes (defined by the pattern), process them, and update own cooked values according to them; since the cooked values are dependent on the gathered nodes, and the gathered nodes depend on the pattern, then the cooked node needs to be marked as dirty. |
|
inline |
Returns the integer indicating the list version number. Each time the list changes (a bundle is added, removed, etc) the integer is incremented. This can be used to avoid any recomputations, if nothing has changed.
Definition at line 210 of file OP_BundleList.h.
|
static |
Standard function that installs the bundle hscript commands.
|
inline |
Returns the number of internal bundles.
Definition at line 79 of file OP_BundleList.h.
const OP_BundleFilter* OP_BundleList::lookupFilter | ( | const char * | name | ) | const |
Returns the filter by the given name, or NULL if not found.
A notifier called by OP_Network when a node has been created. Adds the node to any matching pattern bundles.
A notifier called by OP_Network when a node has been deleted. Removes the node from any bundles that contain it.
A notifier called by OP_Network when a node has been renamed. Removes the node from any pattern bundles that the node no longer matches, and adds the node to any pattern bundles that the node now matches.
Invoked when the group has changed. It dirties any bundles whose contents depends on that group.
A notifier called when the node type (or its representative type) has changed. It reapplies the filters to the bundles to see if the node now passes the type tests.
int OP_BundleList::renameBundle | ( | const char * | oldname, |
const char * | newname | ||
) |
int OP_BundleList::saveToHip | ( | std::ostream & | os | ) |
Saves the bundle list to the hip file.
const OP_BundleFilter* OP_BundleList::setBundleFilter | ( | const char * | bname, |
const char * | fname | ||
) |
Sets a new bundle filter.
bname | The bundle name. |
fname | The filter name. |
Attempts to simplify the given pattern using this bundle list.
root | The node with respect to which relative paths are specified in the pattern. |
|
static |
Attempts to simplify the given pattern in a slightly safer manner than the other method. The three main differences are: it supports groups, it doesn't care about group/bundle contents (hence a bit faster), and it ignores unrecognized tokens instead of removing them.
root | The node with respect to which relative paths are specified in the pattern. |
void OP_BundleList::sortBundles | ( | ) |
Sorts the list of bundles alphabetically. This is useful after appending, renaming, or removing any bundles, to mainatin the alphanumeric order.