14 #ifndef OPFLEX_CORE_MO_H
15 #define OPFLEX_CORE_MO_H
19 #include <boost/ref.hpp>
20 #include <boost/optional.hpp>
21 #include <boost/noncopyable.hpp>
26 #include "opflex/ofcore/OFTypes.h"
30 namespace mointernal {
48 class MO :
private boost::noncopyable {
83 const OF_SHARED_PTR<const ObjectInstance>& oi);
96 const OF_SHARED_PTR<const ObjectInstance>& oi);
123 static OF_SHARED_PTR<const ObjectInstance>
164 template <
class T>
static
165 boost::optional<OF_SHARED_PTR<T> >
170 return OF_MAKE_SHARED<T>(framework, uri,
172 }
catch (std::out_of_range e) {
181 template <
class T>
static
184 const URI& parent_uri,
187 std::vector<OF_SHARED_PTR<T> >& out) {
188 std::vector<URI> childURIs;
190 .
getChildren(parent_class, parent_uri, parent_prop,
191 child_class, childURIs);
192 std::vector<URI>::const_iterator it;
193 for (it = childURIs.begin(); it != childURIs.end(); ++it) {
194 boost::optional<OF_SHARED_PTR<T> > child =
195 resolve<T>(framework, child_class, *it);
196 if (child) out.push_back(child.get());
206 const URI& parent_uri,
209 const URI& child_uri) {
223 static OF_SHARED_PTR<T>
226 return OF_MAKE_SHARED<T>(boost::ref(framework),
228 framework.getTLMutator()
229 .
modify(class_id, URI::ROOT));
238 framework.getTLMutator().
remove(class_id, uri);
253 bool operator==(
const MO& lhs,
const MO& rhs);
257 bool operator!=(
const MO& lhs,
const MO& rhs);
A client for accessing the object store scoped to an owner.
Definition: StoreClient.h:37
bool operator==(const MAC &lhs, const MAC &rhs)
Check for MAC equality.
This is the base class for all managed objects, which are the primary point of interface with data st...
Definition: MO.h:48
static StoreClient & getStoreClient(ofcore::OFFramework &framework)
Get a read-only store client for the framework instance.
static OF_SHARED_PTR< const ObjectInstance > resolveOI(ofcore::OFFramework &framework, class_id_t class_id, const URI &uri)
Resolve the specified URI to the underlying object instance, if it exists.
A mutator represents a set of changes to apply to the data store.
Definition: Mutator.h:61
class_id_t getClassId() const
Get the class ID associated with this managed object.
MO(class_id_t class_id, const URI &uri, const OF_SHARED_PTR< const ObjectInstance > &oi)
Construct an MO.
Interface definition file for MODB.
const URI & getURI() const
Get the URI associated with this managed object.
Interface for an object interested in updates to objects in the data store.
Definition: ObjectListener.h:41
Main interface to the OpFlex framework.
Definition: OFFramework.h:644
static const URI ROOT
Static root URI.
Definition: URI.h:84
friend bool operator==(const MO &lhs, const MO &rhs)
Check for MO equality.
const ObjectInstance & getObjectInstance() const
Get the raw object instance associated with this managed object.
OF_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...
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...
static void registerListener(ofcore::OFFramework &framework, ObjectListener *listener, class_id_t class_id)
Register the listener for the specified class ID.
OF_SHARED_PTR< T > 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 child of the specified type to the mutator and instantiate the correct wrapper class...
Definition: MO.h:205
OF_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 specif...
ofcore::OFFramework & getFramework() const
Get the framework instance associated with this managed object.
virtual ~MO()
Destroy an MO.
static void resolveChildren(ofcore::OFFramework &framework, class_id_t parent_class, const URI &parent_uri, prop_id_t parent_prop, class_id_t child_class, std::vector< OF_SHARED_PTR< T > > &out)
Resolve any children of the specified parent object to their managed object wrapper classes...
Definition: MO.h:182
friend bool operator!=(const MO &lhs, const MO &rhs)
Check for MO inequality.
An internal instance of an object in the managed object store.
Definition: ObjectInstance.h:103
void remove(class_id_t class_id, const URI &uri)
Delete the child object specified along with its link to its parents.
Mutator & getTLMutator()
Get the currently-active mutator.
bool operator!=(const MAC &lhs, const MAC &rhs)
Check for MAC inequality.
A URI is used to identify managed objects in the MODB.
Definition: URI.h:43
Interface definition file for OFFramework.
static OF_SHARED_PTR< T > createRootElement(ofcore::OFFramework &framework, class_id_t class_id)
Add a root element of the given type to the framework.
Definition: MO.h:224
static void unregisterListener(ofcore::OFFramework &framework, ObjectListener *listener, class_id_t class_id)
Unregister the listener for the specified class ID.
static boost::optional< OF_SHARED_PTR< T > > resolve(ofcore::OFFramework &framework, class_id_t class_id, const URI &uri)
Resolve the specified URI to its managed object wrapper class, if it exists.
Definition: MO.h:166
Interface definition file for ObjectListeners.