
//**************************************************************************/
// Copyright (c) 2008 Autodesk, Inc.
// All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
//
//**************************************************************************/
// DESCRIPTION:
// CREATED: October 2008
//**************************************************************************/

namespace mudbox {

/// \brief The base class of all operations
///
/// The main purpose of this class is that it makes it possible for plugins to execute undoable operations.
/// When a plugin want undoable operations, it has to derive its own class from Operation, and implement the 
/// Serialize and ExecuteAndInvert functions. In this case, when one want to execute the operation, it not makes
/// the changes directly, but creates an instance of the operation class, fills the necessary data members, and
/// then calls Kernel::DoOperation(). That function will later call the ExecuteAndInvert function of the operation 
/// object, which will do the changes at that time. The Serialize function must properly store/restore the state of
/// the operation object, otherwise the undo/redo will not work properly.
class MBDLL_DECL Operation : public Node
{
	DECLARE_CLASS;
	Operation( void );
	virtual ~Operation( void );

	/// \brief Executes and then inverts the operation.
	///
	/// This function must do two things, it has to execute the current operation, and then invert the effect of the
	/// object, so that the next time if this function is called, it should execute the inverse of the previous effect.
	/// Calling this function twice in a row should result both the state of the scene and the object to be the same
	/// as it was before the first call. Some examples of a typical implementation of this function:
	/// 
	/// \li If the task of the operation is to create an object, this function should change the type of the operation
	/// into delete an object, and should remember the ID of the newly created object.
	///
	/// \li If the task of the operation is to delete something, it should first scan the object for all the data which is
	/// needed to properly recreate a the object later, and change the type of the operation to 'create'.
	///
	/// \li If the task of the operation is to select something, the operation type should not change during this function,
	/// but the target of the operation should change to the object which was selected at the time of this call. This 
	/// way the next time when this function is called, the selection will be restored into the original object.
	virtual bool ExecuteAndInvert( void );
};

}; // end of namespace mudbox

