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

This is the base class for all managed objects, which are the primary point of interface with data stored in the managedb object store. More...

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

Inheritance diagram for opflex::modb::mointernal::MO:

Public Member Functions

virtual ~MO ()
 Destroy an MO.
 
class_id_t getClassId () const
 Get the class ID associated with this managed object.
 
const URIgetURI () const
 Get the URI associated with this managed object.
 

Protected Member Functions

 MO (class_id_t class_id, const URI &uri, const OF_SHARED_PTR< const ObjectInstance > &oi)
 Construct an MO.
 
 MO (ofcore::OFFramework &framework, class_id_t class_id, const URI &uri, const OF_SHARED_PTR< const ObjectInstance > &oi)
 Construct an MO associated with a non-default framework instance.
 
ofcore::OFFrameworkgetFramework () const
 Get the framework instance associated with this managed object.
 
const ObjectInstancegetObjectInstance () const
 Get the raw object instance associated with this managed object.
 
MutatorgetTLMutator ()
 Get the currently-active mutator.
 
template<class T>
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.
 

Static Protected Member Functions

static OF_SHARED_PTR< const ObjectInstanceresolveOI (ofcore::OFFramework &framework, class_id_t class_id, const URI &uri)
 Resolve the specified URI to the underlying object instance, if it exists.
 
static StoreClientgetStoreClient (ofcore::OFFramework &framework)
 Get a read-only store client for the framework instance.
 
static void registerListener (ofcore::OFFramework &framework, ObjectListener *listener, class_id_t class_id)
 Register the listener for the specified class ID.
 
static void unregisterListener (ofcore::OFFramework &framework, ObjectListener *listener, class_id_t class_id)
 Unregister the listener for the specified class ID.
 
template<class T>
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.
 
template<class T>
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.
 
template<class T>
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.
 
static void remove (ofcore::OFFramework &framework, class_id_t class_id, const modb::URI &uri)
 Remove the specified node.
 

Friends

class MOImpl
 
bool operator== (const MO &lhs, const MO &rhs)
 Check for MO equality.
 
bool operator!= (const MO &lhs, const MO &rhs)
 Check for MO inequality.
 

Detailed Description

This is the base class for all managed objects, which are the primary point of interface with data stored in the managedb object store.

A managed object is an object that can be stored in the managed object store, and supports operations for serialization and deserialization for use with the OpFlex protocol. Managed objects are the primary interface point for the opflex framework.

Children of MO are temporary typed objects that reference the "real" objects stored in the MO. The properties of the MO will not change once resolved, so if the object changes in the store, you must respond to the update notification by resolving the affected MOs again.

Constructor & Destructor Documentation

◆ MO() [1/2]

opflex::modb::mointernal::MO::MO ( class_id_t class_id,
const URI & uri,
const OF_SHARED_PTR< const ObjectInstance > & oi )
protected

Construct an MO.

Parameters
class_idthe class ID for the object
urithe URI for the object
oithe object instance for this object

Referenced by operator!=, and operator==.

◆ MO() [2/2]

opflex::modb::mointernal::MO::MO ( ofcore::OFFramework & framework,
class_id_t class_id,
const URI & uri,
const OF_SHARED_PTR< const ObjectInstance > & oi )
protected

Construct an MO associated with a non-default framework instance.

Parameters
frameworkthe framework instance
class_idthe class ID for the object
urithe URI for the object
oithe object instance for this object

Member Function Documentation

◆ getClassId()

class_id_t opflex::modb::mointernal::MO::getClassId ( ) const

Get the class ID associated with this managed object.

The class ID is a unique ID for the type. This ID must be unique for a given managed object database, but need not be globally unique.

Returns
The unique class ID

◆ getFramework()

ofcore::OFFramework & opflex::modb::mointernal::MO::getFramework ( ) const
protected

Get the framework instance associated with this managed object.

Returns
the framework instance

Referenced by addChild().

◆ getObjectInstance()

const ObjectInstance & opflex::modb::mointernal::MO::getObjectInstance ( ) const
protected

Get the raw object instance associated with this managed object.

Returns
the raw object instance

◆ getTLMutator()

Mutator & opflex::modb::mointernal::MO::getTLMutator ( )
protected

Get the currently-active mutator.

Exceptions
std::logic_errorif there is no active mutator

Referenced by addChild().

◆ getURI()

const URI & opflex::modb::mointernal::MO::getURI ( ) const

Get the URI associated with this managed object.

The URI shows the location of the managed object in the tree.

Returns
the URI for the object

◆ resolve()

template<class T>
static boost::optional< OF_SHARED_PTR< T > > opflex::modb::mointernal::MO::resolve ( ofcore::OFFramework & framework,
class_id_t class_id,
const URI & uri )
inlinestaticprotected

Resolve the specified URI to its managed object wrapper class, if it exists.

Parameters
frameworkthe framework instance
class_idthe class ID for the corresponding object
urithe URI to resolve
Returns
a shared pointer to the managed object. Returns boost::none if the object does not exist

References resolveOI().

Referenced by resolveChildren().

◆ resolveOI()

static OF_SHARED_PTR< const ObjectInstance > opflex::modb::mointernal::MO::resolveOI ( ofcore::OFFramework & framework,
class_id_t class_id,
const URI & uri )
staticprotected

Resolve the specified URI to the underlying object instance, if it exists.

Parameters
frameworkthe framework instance
class_idthe class ID for the corresponding object
urithe URI to resolve
Returns
a shared pointer to the object instance
Exceptions
std::out_of_rangeif the provided URI does not exist locally

Referenced by resolve().


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