OpFlex Framework 1.7.0
|
A client for accessing the object store scoped to an owner. More...
#include <opflex/modb/mo-internal/StoreClient.h>
Public Types | |
typedef OF_UNORDERED_MAP< URI, class_id_t > | notif_t |
A map to store queued notifications. | |
Public Member Functions | |
const std::string & | getOwner () const |
Get the owner of this store client. | |
void | put (class_id_t class_id, const URI &uri, const OF_SHARED_PTR< const ObjectInstance > &oi) |
Set the specified URI to the provided object instance, replacing any existing value. | |
bool | putIfModified (class_id_t class_id, const URI &uri, const OF_SHARED_PTR< const ObjectInstance > &oi) |
Set the specified URI to the provided object instance if it has been modified, atomically. | |
bool | isPresent (class_id_t class_id, const URI &uri) const |
Check whether an item exists in the store. | |
OF_SHARED_PTR< const ObjectInstance > | get (class_id_t class_id, const URI &uri) const |
Get the object instance associated with the given class ID and URI. | |
bool | get (class_id_t class_id, const URI &uri, OF_SHARED_PTR< const ObjectInstance > &oi) const |
Get the object instance associated with the given class ID and URI. | |
bool | remove (class_id_t class_id, const URI &uri, bool recursive, notif_t *notifs=NULL) |
Remove the specified URI, if present. | |
bool | addChild (class_id_t parent_class, const URI &parent_uri, prop_id_t parent_prop, class_id_t child_class, const URI &child_uri) |
Add a parent/child relationship between a parent URI (from any region) to a child URI (in this region). | |
void | delChild (class_id_t parent_class, const URI &parent_uri, prop_id_t parent_prop, class_id_t child_class, const URI &child_uri) |
Remove a parent/child relationship between a parent URI and a child URI. | |
std::pair< URI, prop_id_t > | getParent (class_id_t child_class, const URI &child) |
Get the parent for the given child URI. | |
bool | getParent (class_id_t child_class, const URI &child, std::pair< URI, prop_id_t > &parent) |
Get the parent for the given child URI. | |
void | getChildren (class_id_t parent_class, const URI &parent_uri, prop_id_t parent_prop, class_id_t child_class, std::vector< URI > &output) |
Get the children of the parent URI and property and put the result into the supplied vector. | |
void | removeChildren (class_id_t class_id, const URI &uri, notif_t *notifs) |
Remove all the children of the given object, exluding the object itself. | |
void | queueNotification (class_id_t class_id, const URI &uri, notif_t ¬ifs) |
Queue notifications for dispatch to the given URI and its parents. | |
void | deliverNotifications (const notif_t ¬ifs) |
Deliver the notifications to the object store notification queue. | |
void | getObjectsForClass (class_id_t class_id, OF_UNORDERED_SET< URI > &output) |
Get a set of all objects with the given class ID. | |
Friends | |
class | opflex::modb::Region |
class | opflex::modb::ObjectStore |
A client for accessing the object store scoped to an owner.
A store client can read any data but can write only to data that is owned by the corresponding owner.
bool opflex::modb::mointernal::StoreClient::addChild | ( | class_id_t | parent_class, |
const URI & | parent_uri, | ||
prop_id_t | parent_prop, | ||
class_id_t | child_class, | ||
const URI & | child_uri ) |
Add a parent/child relationship between a parent URI (from any region) to a child URI (in this region).
Note that only the owner of the child object can change the parent/child relationship.
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 |
void opflex::modb::mointernal::StoreClient::delChild | ( | class_id_t | parent_class, |
const URI & | parent_uri, | ||
prop_id_t | parent_prop, | ||
class_id_t | child_class, | ||
const URI & | child_uri ) |
Remove a parent/child relationship between a parent URI and a child URI.
Note that only the owner of the child object can change the parent/child relationship.
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 |
std::out_of_range | If no such class ID is registered |
void opflex::modb::mointernal::StoreClient::deliverNotifications | ( | const notif_t & | notifs | ) |
Deliver the notifications to the object store notification queue.
notifs | the notifications to deliver |
OF_SHARED_PTR< const ObjectInstance > opflex::modb::mointernal::StoreClient::get | ( | class_id_t | class_id, |
const URI & | uri ) const |
Get the object instance associated with the given class ID and URI.
class_id | the class ID for the object being retrieved |
uri | the URI for the object instance |
std::out_of_range | if no such element is present or there is no such class ID registered |
bool opflex::modb::mointernal::StoreClient::get | ( | class_id_t | class_id, |
const URI & | uri, | ||
OF_SHARED_PTR< const ObjectInstance > & | oi ) const |
Get the object instance associated with the given class ID and URI.
class_id | the class ID for the object being retrieved |
uri | the URI for the object instance |
oi | if object is found, a shared ptr to an object instance that must not be modified. |
void opflex::modb::mointernal::StoreClient::getChildren | ( | class_id_t | parent_class, |
const URI & | parent_uri, | ||
prop_id_t | parent_prop, | ||
class_id_t | child_class, | ||
std::vector< URI > & | output ) |
Get the children of the parent URI and property and put the result into the supplied vector.
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 |
output | the output array that will get the output |
std::out_of_range | If no such class ID is registered |
Referenced by opflex::modb::mointernal::MO::resolveChildren().
void opflex::modb::mointernal::StoreClient::getObjectsForClass | ( | class_id_t | class_id, |
OF_UNORDERED_SET< URI > & | output ) |
Get a set of all objects with the given class ID.
class_id | the class_id to look up |
output | An unordered set that will get the output |
std::out_of_range | if the class is not found |
const std::string & opflex::modb::mointernal::StoreClient::getOwner | ( | ) | const |
Get the owner of this store client.
std::pair< URI, prop_id_t > opflex::modb::mointernal::StoreClient::getParent | ( | class_id_t | child_class, |
const URI & | child ) |
Get the parent for the given child URI.
child_class | the class of the child object |
child | the URI of the child object |
std::out_of_range | of the child URI is not found or has no parent |
bool opflex::modb::mointernal::StoreClient::getParent | ( | class_id_t | child_class, |
const URI & | child, | ||
std::pair< URI, prop_id_t > & | parent ) |
Get the parent for the given child URI.
child_class | the class of the child object |
child | the URI of the child object |
parent | if parent is found, a (URI, prop_id_t) pair which is the URI of the parent and the property that represents the relation. |
bool opflex::modb::mointernal::StoreClient::isPresent | ( | class_id_t | class_id, |
const URI & | uri ) const |
Check whether an item exists in the store.
Note that it could be deleted between checking for presense and calling get().
class_id | the class ID for the object being retrieved |
uri | the URI for the object instance |
std::out_of_range | if there is no such class ID registered |
void opflex::modb::mointernal::StoreClient::put | ( | class_id_t | class_id, |
const URI & | uri, | ||
const OF_SHARED_PTR< const ObjectInstance > & | oi ) |
bool opflex::modb::mointernal::StoreClient::putIfModified | ( | class_id_t | class_id, |
const URI & | uri, | ||
const OF_SHARED_PTR< const ObjectInstance > & | oi ) |
Set the specified URI to the provided object instance if it has been modified, atomically.
Return true if any change was made.
class_id | the class ID for the object being inserted |
uri | the URI for the object instance |
oi | the object instance to set |
std::out_of_range | if there is no such class ID registered |
void opflex::modb::mointernal::StoreClient::queueNotification | ( | class_id_t | class_id, |
const URI & | uri, | ||
notif_t & | notifs ) |
Queue notifications for dispatch to the given URI and its parents.
These will not be delivered until a call to deliverNotification().
bool opflex::modb::mointernal::StoreClient::remove | ( | class_id_t | class_id, |
const URI & | uri, | ||
bool | recursive, | ||
notif_t * | notifs = NULL ) |
Remove the specified URI, if present.
class_id | the class ID for the object being inserted |
uri | the URI to remove |
recursive | remove all the children of the object as well. Setting this to true is equivalent to calling remove nonrecursively followed by calling removeChildren. |
notifs | an optional notification map that will get added to for any URI that is recursively removed, though not the top-level node. |
std::out_of_range | If no such class ID is registered |
void opflex::modb::mointernal::StoreClient::removeChildren | ( | class_id_t | class_id, |
const URI & | uri, | ||
notif_t * | notifs ) |