OpFlex Framework 1.7.0
StoreClient.h
Go to the documentation of this file.
1/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */
6/*
7 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
8 *
9 * This program and the accompanying materials are made available under the
10 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
11 * and is available at http://www.eclipse.org/legal/epl-v10.html
12 */
13
14#ifndef MODB_STORECLIENT_H
15#define MODB_STORECLIENT_H
16
17#include <boost/noncopyable.hpp>
18
19#include "opflex/modb/URI.h"
21#include "opflex/ofcore/OFTypes.h"
22
23namespace opflex {
24namespace modb {
25
26class Region;
27class ObjectStore;
28
29namespace mointernal {
30
37class StoreClient : private boost::noncopyable {
38public:
44 const std::string& getOwner() const;
45
56 void put(class_id_t class_id,
57 const URI& uri,
58 const OF_SHARED_PTR<const ObjectInstance>& oi);
59
73 const URI& uri,
74 const OF_SHARED_PTR<const ObjectInstance>& oi);
75
86 bool isPresent(class_id_t class_id, const URI& uri) const;
87
99 OF_SHARED_PTR<const ObjectInstance> get(class_id_t class_id,
100 const URI& uri) const;
101
112 bool get(class_id_t class_id, const URI& uri,
113 /*out*/ OF_SHARED_PTR<const ObjectInstance>& oi) const;
114
118 typedef OF_UNORDERED_MAP<URI, class_id_t> notif_t;
119
135 bool remove(class_id_t class_id, const URI& uri,
136 bool recursive,
137 /* out */ notif_t* notifs = NULL);
138
155 bool addChild(class_id_t parent_class,
156 const URI& parent_uri,
157 prop_id_t parent_prop,
158 class_id_t child_class,
159 const URI& child_uri);
160
173 void delChild(class_id_t parent_class,
174 const URI& parent_uri,
175 prop_id_t parent_prop,
176 class_id_t child_class,
177 const URI& child_uri);
178
189 std::pair<URI, prop_id_t> getParent(class_id_t child_class,
190 const URI& child);
191
202 bool getParent(class_id_t child_class, const URI& child,
203 /* out */ std::pair<URI, prop_id_t>& parent);
204
216 void getChildren(class_id_t parent_class,
217 const URI& parent_uri,
218 prop_id_t parent_prop,
219 class_id_t child_class,
220 /* out */ std::vector<URI>& output);
221
233 const URI& uri,
234 notif_t* notifs);
235
241 void queueNotification(class_id_t class_id, const URI& uri,
242 /* out */ notif_t& notifs);
243
250 void deliverNotifications(const notif_t& notifs);
251
260 /* out */ OF_UNORDERED_SET<URI>& output);
261
262private:
263
264 friend class opflex::modb::Region;
265 friend class opflex::modb::ObjectStore;
266
267 StoreClient(ObjectStore* store, Region* region,
268 bool readOnly = false);
269
270 ObjectStore* store;
271 Region* region;
272 bool readOnly;
273};
274
275} /* namespace mointernal */
276} /* namespace modb */
277} /* namespace opflex */
278
279#endif /* MODB_STORECLIENT_H */
Interface definition file for ObjectInstance.
Interface definition file for URIs.
A URI is used to identify managed objects in the MODB.
Definition URI.h:43
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.
std::pair< URI, prop_id_t > getParent(class_id_t child_class, const URI &child)
Get the parent for the given child 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.
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 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 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.
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.
void getObjectsForClass(class_id_t class_id, OF_UNORDERED_SET< URI > &output)
Get a set of all objects with the given class ID.
void queueNotification(class_id_t class_id, const URI &uri, notif_t &notifs)
Queue notifications for dispatch to the given URI and its parents.
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 remove(class_id_t class_id, const URI &uri, bool recursive, notif_t *notifs=NULL)
Remove the specified URI, if present.
void deliverNotifications(const notif_t &notifs)
Deliver the notifications to the object store notification queue.
bool isPresent(class_id_t class_id, const URI &uri) const
Check whether an item exists in the store.
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...
const std::string & getOwner() const
Get the owner of this store client.
OF_UNORDERED_MAP< URI, class_id_t > notif_t
A map to store queued notifications.
Definition StoreClient.h:118
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.
uint64_t prop_id_t
A unique property ID.
Definition PropertyInfo.h:39
uint64_t class_id_t
A unique class ID.
Definition PropertyInfo.h:34