Public Member Functions | Protected Member Functions | Protected Attributes | Friends

PD_DocumentRDFMutation Class Reference

Changes to the document RDF are handled with this class. More...

#include <pd_DocumentRDF.h>

Inheritance diagram for PD_DocumentRDFMutation:
PD_RDFMutation_XMLIDLimited

List of all members.

Public Member Functions

virtual ~PD_DocumentRDFMutation ()
virtual void handleCollabEvent (const gchar **szAtts, const gchar **szProps)
virtual bool add (const PD_URI &s, const PD_URI &p, const PD_Object &o)
virtual bool add (const PD_URI &s, const PD_URI &p, const PD_Object &o, const PD_URI &context)
virtual void remove (const PD_URI &s, const PD_URI &p, const PD_Object &o)
void remove (const PD_URI &s, const PD_URI &p, const PD_URI &o)
bool add (const PD_RDFStatement &st)
void remove (const PD_RDFStatement &st)
int add (PD_RDFModelHandle model)
void remove (const std::list< PD_RDFStatement > &sl)
void remove (const PD_URI &s, const PD_URI &p)
PD_URI createBNode ()
virtual UT_Error commit ()
 Commit the add() and remove() changes to the main document RDF.
virtual void rollback ()
 Forget the changes and do not automatically try to commit() them when the PD_DocumentRDFMutation goes out of scope.

Protected Member Functions

bool apAdd (PP_AttrProp *AP, const PD_URI &s, const PD_URI &p, const PD_Object &o)
void apRemove (PP_AttrProp *&AP, const PD_URI &s, const PD_URI &p, const PD_Object &o)
UT_Error handleAddAndRemove (PP_AttrProp *add, PP_AttrProp *remove)
 This is where the triples in and will actually modify the DocumentRDF.
 PD_DocumentRDFMutation (PD_DocumentRDF *rdf)

Protected Attributes

PD_DocumentRDFm_rdf
 DocumentRDF we are changing.
bool m_rolledback
 Should we rollback.
bool m_committed
 Only commit() once.
bool m_handlingAbiCollabNotification
 If we are handling a remote CR.
PP_AttrPropm_pAP
 AP that is changed incrementally (deprecated).
PP_AttrPropm_crRemoveAP
 Triples to remove during commit().
PP_AttrPropm_crAddAP
 Triples to add during commit().

Friends

class PD_DocumentRDF
class RDFModel_XMLIDLimited

Detailed Description

Changes to the document RDF are handled with this class.

Changes made to the mutation are not reflected in the document RDF right away but must be committed first. You can only have a single commit or rollback for any instance of PD_DocumentRDFMutation. If you commit and want to make another change to the document RDF, create another PD_DocumentRDFMutation object.

Because changing the document RDF uses the piece table and AttrProp values, it is (relatively) expensive to mutate RDF. Using this class a collection of changes can be built up and performed in a single operation.

By default the object will commit() when it is destroyed. Thus the normal usage pattern is to get a PD_DocumentRDFMutationHandle smart pointer from the DocumentRDF, call add() and/or remove() and then let the PD_DocumentRDFMutationHandle run out of scope to commit your changes. Of course, use rollback() if you want to abandon your mutations.

This class also handles notifying the local AbiCollab of updates and any RDF change requests that come in from other abiword instances.

On an implementation note: the public API add() and remove() maintain two internal AttrProp tables; the add and remove collections. These internal AttrProp tables are modified using apAdd() and apRemove(). A single add() will use apAdd() to add the change to the add collection and apRemove() to remove it from the remove collection. Thus having the ap prefixed methods is very useful for implementing the public API.

When commit() is called, the add/remove changes are made permanent using handleAddAndRemove(). The add/remove are then combined into a single AttrProp and sent via a Change Record CR. AbiCollab will propergate the CR to other abiword instances and the collab code knows to send that AttrProp back to the RDF code through handleCollabEvent(). Inside of handleCollabEvent() a speical flag is set so that we commit the changes but do not propergate them again via a CR (thus avoiding a never ending loop).


Constructor & Destructor Documentation

PD_DocumentRDFMutation::PD_DocumentRDFMutation ( PD_DocumentRDF rdf  )  [protected]
PD_DocumentRDFMutation::~PD_DocumentRDFMutation (  )  [virtual]

Member Function Documentation

bool PD_DocumentRDFMutation::add ( const PD_URI s,
const PD_URI p,
const PD_Object o 
) [virtual]
Returns:
false of the triple could not be added.

Reimplemented in PD_RDFMutation_XMLIDLimited.

References apAdd(), PD_DocumentRDF::apContains(), PD_DocumentRDF::contains(), m_crAddAP, m_crRemoveAP, m_pAP, and m_rdf.

Referenced by add().

bool PD_DocumentRDFMutation::add ( const PD_RDFStatement st  ) 
int PD_DocumentRDFMutation::add ( PD_RDFModelHandle  model  ) 

References add().

bool PD_DocumentRDFMutation::add ( const PD_URI s,
const PD_URI p,
const PD_Object o,
const PD_URI context 
) [virtual]

References add().

bool PD_DocumentRDFMutation::apAdd ( PP_AttrProp AP,
const PD_URI s,
const PD_URI p,
const PD_Object o 
) [protected]
void PD_DocumentRDFMutation::apRemove ( PP_AttrProp *&  AP,
const PD_URI s,
const PD_URI p,
const PD_Object o 
) [protected]
UT_Error PD_DocumentRDFMutation::commit (  )  [virtual]

Commit the add() and remove() changes to the main document RDF.

This method also emits a change record detailing the update.

Implementation: Note that at this stage we have m_crRemoveAP and m_crAddAP which are the tripes to remove and add respectively. These are also the triples that will be sent via abicollab to other instances to add/remove so we might as well try to use the same code to handle the mutation in both this and other abiword instances.

Note that you can only commit() once per PD_DocumentRDFMutation object. So you should throw it away after a commit to avoid the temptation of trying to add() more to it.

Reimplemented in PD_RDFMutation_XMLIDLimited.

References pt_VarSet::addIfUniqueAP(), PD_DocumentRDF::getDocument(), PD_DocumentRDF::getPieceTable(), PP_AttrProp::getProperties(), pt_PieceTable::getVarSet(), handleAddAndRemove(), PP_AttrProp::hasProperties(), PD_DocumentRDF::isStandAlone(), m_committed, m_crAddAP, m_crRemoveAP, m_handlingAbiCollabNotification, m_pAP, m_rdf, m_rolledback, PP_AttrProp::markReadOnly(), PD_DocumentRDF::maybeSetDocumentDirty(), PD_Document::notifyListeners(), PP_AttrProp::prune(), PX_ChangeRecord::PXT_ChangeDocRDF, PP_AttrProp::setAttributes(), PP_AttrProp::setProperties(), PD_DocumentRDF::updateHaveSemItemsCache(), UT_DEBUGMSG, and UT_OK.

Referenced by ~PD_DocumentRDFMutation().

PD_URI PD_DocumentRDFMutation::createBNode (  ) 
UT_Error PD_DocumentRDFMutation::handleAddAndRemove ( PP_AttrProp add_,
PP_AttrProp remove_ 
) [protected]

This is where the triples in and will actually modify the DocumentRDF.

This method is called by commit() locally and by handleCollabEvent to handle remote change notificatioans during collaborative sessions.

First the current AttrProp is copied from the DocumentRDF, filtering out the triples from the remove table as the copy is performed. Then the new triples are added and the piecetable/documentRDF is updated to use the new RDF APIndex.

References apAdd(), decodePOCol(), encodePOCol(), gchar, PD_DocumentRDF::getAP(), PP_AttrProp::getNthProperty(), PP_AttrProp::getProperty(), PP_AttrProp::getPropertyCount(), m_rdf, s, PD_DocumentRDF::setAP(), PP_AttrProp::setProperty(), szName, UT_DEBUGMSG, and UT_OK.

Referenced by commit(), and handleCollabEvent().

void PD_DocumentRDFMutation::handleCollabEvent ( const gchar **  szAtts,
const gchar **  szProps 
) [virtual]
void PD_DocumentRDFMutation::remove ( const PD_URI s,
const PD_URI p,
const PD_Object o 
) [virtual]
void PD_DocumentRDFMutation::remove ( const PD_URI s,
const PD_URI p,
const PD_URI o 
)

References PD_URI::toString().

void PD_DocumentRDFMutation::remove ( const PD_URI s,
const PD_URI p 
)
void PD_DocumentRDFMutation::remove ( const PD_RDFStatement st  ) 
void PD_DocumentRDFMutation::remove ( const std::list< PD_RDFStatement > &  sl  ) 
void PD_DocumentRDFMutation::rollback (  )  [virtual]

Forget the changes and do not automatically try to commit() them when the PD_DocumentRDFMutation goes out of scope.

Reimplemented in PD_RDFMutation_XMLIDLimited.

References m_rolledback.


Friends And Related Function Documentation

friend class PD_DocumentRDF [friend]
friend class RDFModel_XMLIDLimited [friend]

Member Data Documentation

Only commit() once.

Referenced by commit(), and ~PD_DocumentRDFMutation().

If we are handling a remote CR.

Referenced by commit(), and handleCollabEvent().

AP that is changed incrementally (deprecated).

Referenced by add(), commit(), PD_DocumentRDFMutation(), remove(), and ~PD_DocumentRDFMutation().

Should we rollback.

Referenced by commit(), and rollback().


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