HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_BundleList Class Reference

#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_BundlegetBundle (int i)
 Returns the i-th non-internal bundle. More...
 
OP_BundlegetBundle (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_BundlegetInternalBundle (int i)
 Returns the i-th internal bundle. More...
 
OP_BundlecreateBundle (const char *name, int internal=0)
 
OP_BundleduplicateBundle (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_BundleFiltersetBundleFilter (const char *bname, const char *fname)
 
const OP_BundleFilterlookupFilter (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_BundleFilterbundleSetFilter (OP_Bundle *bundle, const char *fname)
 
const OP_BundleFilterbundleSetFilter (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_BundlegetPattern (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...
 

Detailed Description

Definition at line 55 of file OP_BundleList.h.

Constructor & Destructor Documentation

OP_BundleList::OP_BundleList ( )
OP_BundleList::~OP_BundleList ( )

Member Function Documentation

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.

Parameters
menuAn output parameter that will contain new names representing the menu entries.
maxThe maximum number of entries that are allowed to be added.
filterIf 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.

int OP_BundleList::bundleAddOp ( OP_Bundle bundle,
OP_Node node 
)

A convenience method to add a node to the bundle, within an undo block, and to send out a notification.

Returns
The number of nodes added.
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.

Returns
The number of nodes added.
void OP_BundleList::bundleClear ( OP_Bundle bundle)

A convenience method to remove all nodes from the bundle, within an undo block, and to send out a notification.

int OP_BundleList::bundleRemoveOp ( OP_Bundle bundle,
OP_Node node 
)

A convenience method to remove a node from the bundle, within an undo block, and to send out a notification.

Returns
The number of nodes removed.
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.

Returns
The number of nodes removed.
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.

Parameters
fnameThe name of the new filter.
Returns
The old 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.

Returns
The old filter.
void OP_BundleList::bundleSetLock ( OP_Bundle bundle,
bool  lock 
)

A convenience method to set the lock on the member nodes of a bundle, within an undo bloc.

void OP_BundleList::bundleSetPattern ( OP_Bundle bundle,
const char *  pattern 
)

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

void OP_BundleList::cmdAdd ( CMD_Args args)

Implements the hscript command that adds a new bundle.

void OP_BundleList::cmdLs ( CMD_Args args)

Implements the hscript command that lists the bundles.

void OP_BundleList::cmdName ( CMD_Args args)

Implements the hscript command that renames a bundle.

void OP_BundleList::cmdOp ( CMD_Args args)

Implements the hscript command that manipulates bundle contents by adding, removing, or replacing the member nodes.

void OP_BundleList::cmdRm ( CMD_Args args)

Implements the hscript command that removes an old bundle.

OP_Bundle* OP_BundleList::createBundle ( const char *  name,
int  internal = 0 
)

Creates and returns a new bundle.

Parameters
nameThe name of the bundle.
internalIf 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.

Parameters
nameThe name of the bundle to delete.
Returns
True if the bundle was found and destroyed.
int OP_BundleList::destroyBundle ( int  index)
void OP_BundleList::dumpFilters ( std::ostream &  os)

Prints out all the available bundle filters.

OP_Bundle* OP_BundleList::duplicateBundle ( OP_Bundle bundle)

Creates a duplicate of a given bundle. The new bundle's name is similar to the original, but a numerical suffix is appended.

Parameters
bundleThe bundle to duplicate.
int OP_BundleList::entries ( void  ) const
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.

Parameters
baseThe desired name of the bundle. If that name is not taken, it will be returned. Otherwise, a numerical suffix will be appended.
OP_Bundle* OP_BundleList::getBundle ( int  i)
inline

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.

UT_NotifierImpl< OP_BundleListEvent& >& OP_BundleList::getEventNotifier ( )
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.

OP_Bundle* OP_BundleList::getInternalBundle ( int  i)
inline

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.

Returns
The number of bundles returned.
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.

Parameters
prev_bundleThe 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).
creatorThe 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.
relativetoThe node with respect to which the relative node paths are specified in the pattern.
patternThe node name or path pattern. Any nodes that match the patterns will be included in the bundle.
filterThe 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.
labelAn 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_inclusionIf 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.
addinterestIf 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.
int OP_BundleList::getTouchTime ( ) const
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 void OP_BundleList::installCommands ( CMD_Manager cmd)
static

Standard function that installs the bundle hscript commands.

int OP_BundleList::internalEntries ( ) const
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.

void OP_BundleList::nodeAdded ( OP_Node node)

A notifier called by OP_Network when a node has been created. Adds the node to any matching pattern bundles.

void OP_BundleList::nodeDeleted ( OP_Node node)

A notifier called by OP_Network when a node has been deleted. Removes the node from any bundles that contain it.

void OP_BundleList::nodeRenamed ( OP_Node node)

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.

void OP_BundleList::notifyOpsOfGroupChange ( OP_Group group)

Invoked when the group has changed. It dirties any bundles whose contents depends on that group.

void OP_BundleList::refilterOp ( OP_Node node)

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.

Parameters
bnameThe bundle name.
fnameThe filter name.
Returns
The previous filter.
void OP_BundleList::simplifyPattern ( const OP_Node root,
UT_String pattern 
)

Attempts to simplify the given pattern using this bundle list.

Parameters
rootThe node with respect to which relative paths are specified in the pattern.
static void OP_BundleList::simplifyPatternSafely ( const OP_Node root,
UT_String 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.

Parameters
rootThe 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.


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