OpFlex Framework 1.7.0
opflex::modb::mointernal::StoreClient Class Reference

A client for accessing the object store scoped to an owner. More...

#include <opflex/modb/mo-internal/StoreClient.h>

Inheritance diagram for opflex::modb::mointernal::StoreClient:

Public Types

typedef OF_UNORDERED_MAP< URI, class_id_tnotif_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 ObjectInstanceget (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_tgetParent (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 &notifs)
 Queue notifications for dispatch to the given URI and its parents.
 
void deliverNotifications (const notif_t &notifs)
 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
 

Detailed Description

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.

Member Function Documentation

◆ addChild()

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.

Parameters
parent_classthe class ID of the parent
parent_urithe URI of the parent object
parent_propthe property ID in the parent object
child_classthe class ID of the child
child_urithe URI of the child
Returns
true if the child relationship was not already present
Exceptions
std::out_of_rangeIf no such class ID is registered
std::invalid_argumentIf the parent URI is not a prefix of the child URI

◆ delChild()

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.

Parameters
parent_classthe class ID of the parent
parent_urithe URI of the parent object
parent_propthe property ID in the parent object
child_classthe class ID of the child
child_urithe URI of the child
Exceptions
std::out_of_rangeIf no such class ID is registered

◆ deliverNotifications()

void opflex::modb::mointernal::StoreClient::deliverNotifications ( const notif_t & notifs)

Deliver the notifications to the object store notification queue.

Parameters
notifsthe notifications to deliver

◆ get() [1/2]

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.

Parameters
class_idthe class ID for the object being retrieved
urithe URI for the object instance
Returns
a shared ptr to an object instance that must not be modified.
Exceptions
std::out_of_rangeif no such element is present or there is no such class ID registered

◆ get() [2/2]

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.

Parameters
class_idthe class ID for the object being retrieved
urithe URI for the object instance
oiif object is found, a shared ptr to an object instance that must not be modified.
Returns
true if object with specified class ID and URI is present

◆ getChildren()

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.

Parameters
parent_classthe class ID of the parent
parent_urithe URI of the parent object
parent_propthe property ID in the parent object
child_classthe class ID of the child
outputthe output array that will get the output
Exceptions
std::out_of_rangeIf no such class ID is registered

Referenced by opflex::modb::mointernal::MO::resolveChildren().

◆ getObjectsForClass()

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.

Parameters
class_idthe class_id to look up
outputAn unordered set that will get the output
Exceptions
std::out_of_rangeif the class is not found

◆ getOwner()

const std::string & opflex::modb::mointernal::StoreClient::getOwner ( ) const

Get the owner of this store client.

Returns
the string ID for the owner of this client

◆ getParent() [1/2]

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.

Parameters
child_classthe class of the child object
childthe URI of the child object
Returns
a (URI, prop_id_t) pair which is the URI of the parent and the property that represents the relation.
Exceptions
std::out_of_rangeof the child URI is not found or has no parent

◆ getParent() [2/2]

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.

Parameters
child_classthe class of the child object
childthe URI of the child object
parentif parent is found, a (URI, prop_id_t) pair which is the URI of the parent and the property that represents the relation.
Returns
true if the child object and its parent were found, false otherwise.

◆ isPresent()

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().

Parameters
class_idthe class ID for the object being retrieved
urithe URI for the object instance
Returns
true if the item is present in the store.
Exceptions
std::out_of_rangeif there is no such class ID registered

◆ put()

void opflex::modb::mointernal::StoreClient::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.

Parameters
class_idthe class ID for the object being inserted
urithe URI for the object instance
oithe object instance to set
Exceptions
std::out_of_rangeif there is no such class ID registered

◆ putIfModified()

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.

Parameters
class_idthe class ID for the object being inserted
urithe URI for the object instance
oithe object instance to set
Returns
true if the object was updated, false if the new and the old value are the same.
Exceptions
std::out_of_rangeif there is no such class ID registered

◆ queueNotification()

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().

◆ remove()

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.

Parameters
class_idthe class ID for the object being inserted
urithe URI to remove
recursiveremove all the children of the object as well. Setting this to true is equivalent to calling remove nonrecursively followed by calling removeChildren.
notifsan optional notification map that will get added to for any URI that is recursively removed, though not the top-level node.
Returns
true if an object was removed
Exceptions
std::out_of_rangeIf no such class ID is registered

◆ removeChildren()

void opflex::modb::mointernal::StoreClient::removeChildren ( class_id_t class_id,
const URI & uri,
notif_t * notifs )

Remove all the children of the given object, exluding the object itself.

Parameters
class_idthe class ID for the object being inserted
urithe URI to remove
notifsan optional notification map that will get added to for any URI that is recursively removed, though not the top-level node.

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