Commit c1f41dae authored by saubatn's avatar saubatn
Browse files

FIXED : HistoryItem is now detailed with design pattern (singleton, instanciated in first used).

FIXED : getHistory is now private. History can not be modified outside the class
FIXED : history may be modified using the addHistoryItem and removeLastHistoryItem() methods.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@460 ec899d31-69d1-42ba-9299-647d76f65fb3
parent e727b4a6
......@@ -46,8 +46,11 @@ namespace camitk {
* - its input components
* - its output components
* History item are mainly useful for getting back to a previous state, undoing an action or for scripting, storing in a file a pipeline of actions.
*
**/
*
* The history is stored in the @class{Application} class and uses the "construct on first use" idiom/design-pattern (with singletons).
* It therefore avoids the infamous "static initialization order fiasco",
* see http://www.parashift.com/c++-faq/ctors.html
*/
class CAMITK_API HistoryItem
{
private:
......
......@@ -316,7 +316,7 @@ void Action::postProcess()
item->setOutputComponents(this->outputComponents);
// add the item to the history
Application::getHistory().push(*item);
Application::addHistoryItem(*item);
}
......
......@@ -645,6 +645,21 @@ QStack<HistoryItem> & Application::getHistory()
// static singleton declaration
static QStack<HistoryItem> history;
return history;
}
// -------------------- addHistory ------------------------------
void Application::addHistoryItem(HistoryItem item)
{
getHistory().push(item);
}
// -------------------- removeLastHistoryItem --------------------
HistoryItem Application::removeLastHistoryItem()
{
return getHistory().pop();
}
}
......@@ -281,8 +281,16 @@ public:
///@name actions pipeline history
///@{
/// get the history of actions stored.
static QStack<HistoryItem> & getHistory();
/// Add the history item to the application history
/// The item is added to the history stack of actions used in a pipeline
/// To pop back an action from the history use @see removeHistoryItem
/// @param item the item to add to the history
static void addHistoryItem(HistoryItem item);
/// Remove the last pushed actions in the history of the current pipeline
/// To push back the item use @see addHistoryItem
static HistoryItem removeLastHistoryItem();
///@}
......@@ -379,6 +387,22 @@ private:
static void removeComponent(Component *);
///@}
///@name actions pipeline history
///@{
/// get the history of actions stored.
/// * This method follows the "construct on first use" idiom/design-pattern.
/** get the singleton stack of actions stored in a pipeline
* This is the private (intern) method.
* This history is updated (push(), pop()) by addHistoryItem() and removeHistoryItem()
* This method follows the "construct on first use" idiom/design-pattern.
* It therefore avoids the infamous "static initialization order fiasco",
* see http://www.parashift.com/c++-faq/ctors.html
*/
static QStack<HistoryItem> & getHistory();
/// @}
/// @name Actions management
///@{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment