OP_BundleList Class Reference

#include <OP_BundleList.h>

List of all members.

Public Member Functions

 OP_BundleList ()
 ~OP_BundleList ()
void clear ()
 Deletes all bundles (internal or non-internal).
int entries () const
 Returns the number of non-internal bundles.
OP_BundlegetBundle (int i)
 Returns the i-th non-internal bundle.
OP_BundlegetBundle (const char *name)
void getBundlesByPattern (const char *pattern, UT_PtrArray< OP_Bundle * > &bundles)
 Obtains the list of bundles whose names match the given pattern.
int internalEntries () const
 Returns the number of internal bundles.
OP_BundlegetInternalBundle (int i)
 Returns the i-th internal bundle.
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_PtrArray< 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.
void getFilters (UT_PtrArray< const OP_BundleFilter * > &list)
 Obtains a list of existing filters.
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_String &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.
void cmdAdd (CMD_Args &args)
 Implements the hscript command that adds a new bundle.
void cmdRm (CMD_Args &args)
 Implements the hscript command that removes an old bundle.
void cmdOp (CMD_Args &args)
void cmdName (CMD_Args &args)
 Implements the hscript command that renames a bundle.
int saveToHip (ostream &os)
 Saves the bundle list to the hip file.
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 (ostream &os)
 Prints out all the available bundle filters.

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.


Detailed Description

Definition at line 62 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:
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.

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 OP_BundleFilter filter 
)

A convenience method to set a filter on a bundle, within an undo block.

Returns:
The old filter.

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:
fname The name of the new filter.
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:
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_String 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 ( int  index  ) 

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:
name The name of the bundle to delete.
Returns:
True if the bundle was found and destroyed.

void OP_BundleList::dumpFilters ( 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:
bundle The bundle to duplicate.

int OP_BundleList::entries ( void   )  const [inline]

Returns the number of non-internal bundles.

Definition at line 72 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:
base The 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 ( const char *  name  ) 

Searches for the bundle by name, and returns it if found. Otherwise returns NULL.

OP_Bundle* OP_BundleList::getBundle ( int  i  )  [inline]

Returns the i-th non-internal bundle.

Definition at line 75 of file OP_BundleList.h.

void OP_BundleList::getBundlesByPattern ( const char *  pattern,
UT_PtrArray< 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 352 of file OP_BundleList.h.

void OP_BundleList::getFilters ( UT_PtrArray< 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 89 of file OP_BundleList.h.

int OP_BundleList::getMemberships ( const OP_Node node,
UT_PtrArray< 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_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.

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 217 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 86 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 ( 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:
bname The bundle name.
fname The 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:
root The 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:
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.


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

Generated on Mon Jan 28 00:48:38 2013 for HDK by  doxygen 1.5.9