The Gnome Chemistry Utils 0.13.3
Public Member Functions | Protected Member Functions | Protected Attributes
gcp::Operation Class Reference

#include <gcp/operation.h>

Inheritance diagram for gcp::Operation:
gcp::AddOperation gcp::DeleteOperation gcp::ModifyOperation

List of all members.

Public Member Functions

 Operation (Document *pDoc, unsigned long ID)
virtual void Undo ()=0
virtual void Redo ()=0
virtual void AddObject (gcu::Object *pObject, unsigned type=0)
virtual void AddNode (xmlNodePtr node, unsigned type=0)

Protected Member Functions

void Add (unsigned type=0)
void Delete (unsigned type=0)

Protected Attributes

xmlNodePtr * m_Nodes

Detailed Description

Base operation class for the Undo/Redo framework. This class is virtual since some methods are pure virtual.

Definition at line 61 of file operation.h.


Constructor & Destructor Documentation

gcp::Operation::Operation ( Document pDoc,
unsigned long  ID 
)
Parameters:
pDoca document.
IDa unique operation ID for the document and the session.

Creates a new operation. Operations should always created by calls to Document::GetNewOperation().


Member Function Documentation

void gcp::Operation::Add ( unsigned  type = 0) [protected]
Parameters:
typea number indicationg the role of the stored objects.

The type argument is only significant for the gcp::ModifyOperation class where 0 represent the state of the objects before the operation, and 1 the state of the objects after the operation.

Adds the stored objects to the document owning the operation.

virtual void gcp::Operation::AddNode ( xmlNodePtr  node,
unsigned  type = 0 
) [virtual]
Parameters:
nodean xml node related to the changes.
typea number indicationg the role of the stored objects.

The type argument is only significant for the gcp::ModifyOperation class where 0 represent the state of the objects before the operation, and 1 the state of the objects after the operation.

Adds the node to the document owning the operation. This might be used when Objects are not available such as when editing text.

virtual void gcp::Operation::AddObject ( gcu::Object pObject,
unsigned  type = 0 
) [virtual]
Parameters:
pObjectan Object affected by the changes.
typea number indicationg the role of the stored objects.

The type argument is only significant for the gcp::ModifyOperation class where 0 represent the state of the objects before the operation, and 1 the state of the objects after the operation.

Adds an object to the operation. Typically, modifying an object whould need code like:

        Object *obj;
        // Initialize the object pointer so that it points to a valid object
                ...
        Document *doc = obj->GetDocument ();
        Operation *op = doc->GetNewOperation (GCP_MODIFY_OPERATION);
        op->AddObject (obj, 0);
        // Modify the object
                ...
        op->AddObject (obj, 1);
        doc->FinishOperation ();
void gcp::Operation::Delete ( unsigned  type = 0) [protected]
Parameters:
typea number indicationg the role of the stored objects.

The type argument is only significant for the gcp::ModifyOperation class where 0 represent the state of the objects before the operation, and 1 the state of the objects after the operation.

Deletes the stored objects to the document owning the operation.

virtual void gcp::Operation::Redo ( ) [pure virtual]

Redo the changes represented by this operation.

Implemented in gcp::AddOperation, gcp::DeleteOperation, and gcp::ModifyOperation.

virtual void gcp::Operation::Undo ( ) [pure virtual]

Undo the changes represented by this operation.

Implemented in gcp::AddOperation, gcp::DeleteOperation, and gcp::ModifyOperation.


Member Data Documentation

xmlNodePtr* gcp::Operation::m_Nodes [protected]

The xml nodes storing the changes.

Definition at line 145 of file operation.h.


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