OpFlex Framework
1.3.0
|
A mutator represents a set of changes to apply to the data store. More...
#include <opflex/modb/Mutator.h>
Public Member Functions | |
Mutator (const std::string &owner) | |
Create a mutator that will work with the default framework instance and owner. More... | |
Mutator (ofcore::OFFramework &framework, const std::string &owner) | |
Create a mutator that will work with the provided framework instance and owner. More... | |
~Mutator () | |
Destroy the Mutator. More... | |
void | commit () |
Commit the changes stored in the mutator to the object store. More... | |
boost::shared_ptr < mointernal::ObjectInstance > & | modify (class_id_t class_id, const URI &uri) |
Create a new mutable object with the given URI which is a copy of any existing object with the specified URI. More... | |
void | remove (class_id_t class_id, const URI &uri) |
Delete the child object specified along with its link to its parents. More... | |
boost::shared_ptr < mointernal::ObjectInstance > & | addChild (class_id_t parent_class, const URI &parent_uri, prop_id_t parent_prop, class_id_t child_class, const URI &child_uri) |
Create a new child object with the specified class and URI, and make it a child of the given parent. More... | |
Friends | |
class | MutatorImpl |
A mutator represents a set of changes to apply to the data store.
When modifying data through the managed object accessor classes, changes are not actually written into the store, but rather are written into the Mutator registered using the framework in a thread-local variable. These changes will not become visible until the mutator is committed by calling commit()
The changes are applied to the data store all at once but not necessarily guaranteed to be atomic. That is, a read in another thread could see some objects updated but not others. Each individual object update is applied atomically, however, so the fields within that object will either all be modified or none.
This is most similar to a database transaction with an isolation level set to read uncommitted.
opflex::modb::Mutator::Mutator | ( | const std::string & | owner | ) |
Create a mutator that will work with the default framework instance and owner.
owner | the owner string that will control which fields can be modified. |
opflex::modb::Mutator::Mutator | ( | ofcore::OFFramework & | framework, |
const std::string & | owner | ||
) |
Create a mutator that will work with the provided framework instance and owner.
framework | the framework instance that will be modified |
owner | the owner string that will control which fields can be modified. |
opflex::modb::Mutator::~Mutator | ( | ) |
Destroy the Mutator.
Any uncommitted changes will be lost.
boost::shared_ptr<mointernal ::ObjectInstance>& opflex::modb::Mutator::addChild | ( | class_id_t | parent_class, |
const URI & | parent_uri, | ||
prop_id_t | parent_prop, | ||
class_id_t | child_class, | ||
const URI & | child_uri | ||
) |
Create a new child object with the specified class and URI, and make it a child of the given parent.
If the object already exists, get a mutable copy of that object.
parent_class | the class ID of the parent |
parent_uri | the URI of the parent object |
parent_prop | the property ID in the parent object |
child_class | the class ID of the child |
child_uri | the URI of the child |
Referenced by opflex::modb::mointernal::MO::addChild().
void opflex::modb::Mutator::commit | ( | ) |
Commit the changes stored in the mutator to the object store.
If this method is not called, these changes will simply be lost. After you call commit(), you can continue to make changes using the same mutator which will be effectively a new "transaction".
boost::shared_ptr<mointernal::ObjectInstance>& opflex::modb::Mutator::modify | ( | class_id_t | class_id, |
const URI & | uri | ||
) |
Create a new mutable object with the given URI which is a copy of any existing object with the specified URI.
class_id | the class ID for the object |
uri | The URI for the object |
Referenced by opflex::modb::mointernal::MO::createRootElement().
void opflex::modb::Mutator::remove | ( | class_id_t | class_id, |
const URI & | uri | ||
) |
Delete the child object specified along with its link to its parents.
If the child object has any children that are not removed, then they will be garbage-collected at some later time.
class_id | the class ID for the object |
uri | the URI to remove |
Referenced by opflex::modb::mointernal::MO::remove().