SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
Gallery represents a map of tasks worklets. More...
#include <Gallery.h>
Public Member Functions | |
Gallery (Manager *manager) | |
bool | add (const Worklet::Ptr &worklet, bool makeUnique=false) |
Adds a Task Worklet to a Gallery. More... | |
bool | remove (const Worklet::Ptr &worklet) |
Remove a worklet from the gallery. More... | |
Worklet::Ptr | find (const std::string &name) const |
Find a worklet in the gallery by its name. | |
const std::unordered_map< smtk::string::Token, Worklet::Ptr > & | worklets () const |
Returns a constant map of all of the worklets in the gallery. | |
bool | rename (const Worklet::Ptr &worklet, const std::string &newName) |
Rename an existing worklet. More... | |
std::string | createUniqueName (const std::string &name) const |
Helper method to create a new name based on a provided /a name. More... | |
void | setUniqueNameSeparator (const std::string &newSep) |
Set the unique name separator for the gallery. | |
Protected Attributes | |
Manager * | m_manager |
std::unordered_map< smtk::string::Token, Worklet::Ptr > | m_worklets |
std::string | m_uniqueNameSeparator = "-" |
Gallery represents a map of tasks worklets.
It provides APIs to manage the set of worklets as well as providing the ability to change a worklet's name
bool smtk::task::Gallery::add | ( | const Worklet::Ptr & | worklet, |
bool | makeUnique = false |
||
) |
Adds a Task Worklet to a Gallery.
If makeUnique is set to false and there is already a Worklet with the same name, the Worklet will not be added and the method will return false. If makeUnique is true and there is another Worklet with the same name as the one being added, then a new unique name will be created based on the original suffixed by a number and the instance's unique name separator.
std::string smtk::task::Gallery::createUniqueName | ( | const std::string & | name | ) | const |
Helper method to create a new name based on a provided /a name.
If the provided name is not already in use in the gallery it is returned as is Else an unique name is created using the name provided followed by the gallery's unique name separator and an integer.
bool smtk::task::Gallery::remove | ( | const Worklet::Ptr & | worklet | ) |
Remove a worklet from the gallery.
Returns true if the worklet was removed and false if nothing was removed.
bool smtk::task::Gallery::rename | ( | const Worklet::Ptr & | worklet, |
const std::string & | newName | ||
) |
Rename an existing worklet.
This will fail if the worklet is not part of the gallery or if the new name is in use.