--- PamCut/Collections/SmartCollection/SmartCollection.h 2009/06/05 13:14:35 1.3 +++ PamCut/Collections/SmartCollection/SmartCollection.h 2011/09/05 13:00:41 1.8 @@ -46,17 +46,18 @@ /*! @brief Constructor. * * @param collectionName The collection's name. + * @param owns If true, the collection will own the cuts and the actions, ie., it will + * destroy them in its destructor. */ - SmartCollection(const char* collectionName) : - PamCutCollection(collectionName), _actions(0) { + SmartCollection(const char* collectionName, bool owns = true) : + PamCutCollection(collectionName, owns), _actions(0) { } /*! @brief Destructor. */ - ~SmartCollection() { - } + ~SmartCollection(); /*! @brief Adds an action to the SmartCollection */ - virtual void AddAction(CollectionAction& action); + virtual void AddAction(CollectionAction *action); /*! @brief Returns the iAction-th action. * @@ -66,6 +67,35 @@ */ CollectionAction *GetAction(unsigned int iAction); + /*! @brief Searches for an action by name. + * + * @param actionName The name of the action to search for. + * @return pointer to the desired action; NULL if the specified action cannot be found or if no actions are present. + */ + CollectionAction *GetAction(const char *actionName); + + /*! @brief The number of actions in the collection. + * + * @return The number of actions currently in the collection. + */ + unsigned int GetActionsSize() { + return _actions.size(); + } + + /*! @brief The position of specified action. + * + * This method returns the position of the iAction-th action. For every action + * placed before the first cut this will return -1. Otherwise it will return the index + * of the cut preceding the action (eg., if action number 3 is after cut number 2, GetActionPosition(3) + * will return 2) + * + * @param iAction The index of the action (0 = first action) + * @return The position of the specified action + */ + int GetActionPosition(unsigned int iAction) { + return _actionsPositions[iAction]; + } + /*! @brief The pre-analysis task definition. * * This override of the Setup() method calls Setup() for the base class PamCutCollection, and subsequently for each @@ -93,8 +123,16 @@ protected: + /*! @brief The vector containing the actions */ std::vector _actions; - std::vector _actionsPositions; + + /*! The vector of actions' positions + * + * An action is placed after N cuts, so that the SmartCollection, after applying N cuts, has to + * perform the action. The numbers N for each action are stored here: the element i is N for the + * i-th action in #_actions. + */ + std::vector _actionsPositions; };