OpFlex Framework 1.7.0
Managed Objects

Types for accessing and working with managed objects. More...

Classes

class  opflex::modb::MAC
 A MAC address is used to identify devices on an ethernet network. More...
 
class  opflex::modb::Mutator
 A mutator represents a set of changes to apply to the data store. More...
 
class  opflex::modb::ObjectListener
 Interface for an object interested in updates to objects in the data store. More...
 
class  opflex::modb::URI
 A URI is used to identify managed objects in the MODB. More...
 
class  opflex::modb::URIBuilder
 Build a URI using path elements from the root of the tree. More...
 

Functions

 opflex::modb::MAC::MAC ()
 Construct a MAC consisting of all zeroes.
 
 opflex::modb::MAC::MAC (const std::string &mac)
 Construct a MAC using the given string representation.
 
 opflex::modb::MAC::MAC (uint8_t mac[6])
 Construct a MAC using an array of 6 bytes, in network byte order.
 
 opflex::modb::MAC::~MAC ()
 Destroy the MAC.
 
std::string opflex::modb::MAC::toString () const
 Get the MAC represented as a string.
 
void opflex::modb::MAC::toUIntArray (uint8_t mac[6]) const
 Get the MAC represented as an array of 6 bytes in network byte order.
 
std::ostream & opflex::modb::operator<< (std::ostream &os, const MAC &mac)
 Stream insertion operator.
 
bool opflex::modb::operator== (const MAC &lhs, const MAC &rhs)
 Check for MAC equality.
 
bool opflex::modb::operator!= (const MAC &lhs, const MAC &rhs)
 Check for MAC inequality.
 
size_t opflex::modb::hash_value (MAC const &mac)
 Compute a hash value for the MAC, making MAC suitable as a key in a boost::unordered_map.
 
 opflex::modb::Mutator::Mutator (const std::string &owner)
 Create a mutator that will work with the default framework instance and owner.
 
 opflex::modb::Mutator::Mutator (ofcore::OFFramework &framework, const std::string &owner)
 Create a mutator that will work with the provided framework instance and owner.
 
 opflex::modb::Mutator::~Mutator ()
 Destroy the Mutator.
 
void opflex::modb::Mutator::commit ()
 Commit the changes stored in the mutator to the object store.
 
OF_SHARED_PTR< mointernal::ObjectInstance > & opflex::modb::Mutator::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 specified URI.
 
void opflex::modb::Mutator::remove (class_id_t class_id, const URI &uri)
 Delete the child object specified along with its link to its parents.
 
OF_SHARED_PTR< mointernal ::ObjectInstance > & opflex::modb::Mutator::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.
 
virtual opflex::modb::ObjectListener::~ObjectListener ()
 Destroy the object listener.
 
virtual void opflex::modb::ObjectListener::objectUpdated (class_id_t class_id, const URI &uri)=0
 The specified URI has been added, updated, or deleted.
 
 opflex::modb::URI::URI (const OF_SHARED_PTR< const std::string > &uri)
 Construct a URI using the given string representation.
 
 opflex::modb::URI::URI (const std::string &uri)
 Construct a URI using the given string representation.
 
 opflex::modb::URI::URI (const URI &uri)
 Construct a deep copy of the URI using the given URI.
 
 opflex::modb::URI::~URI ()
 Destroy the URI.
 
const std::string & opflex::modb::URI::toString () const
 Get the URI represented as a string.
 
void opflex::modb::URI::getElements (std::vector< std::string > &elements) const
 Parse the URI and get the unescaped path elements from the URI.
 
URIopflex::modb::URI::operator= (const URI &rhs)
 Assignment operator.
 
std::ostream & opflex::modb::operator<< (std::ostream &os, const URI &uri)
 URI stream insertion.
 
bool opflex::modb::operator== (const URI &lhs, const URI &rhs)
 Check for URI equality.
 
bool opflex::modb::operator!= (const URI &lhs, const URI &rhs)
 Check for URI inequality.
 
bool opflex::modb::operator< (const URI &lhs, const URI &rhs)
 Comparison operator for sorting.
 
size_t opflex::modb::hash_value (URI const &uri)
 Compute a hash value for the URI, making URI suitable as a key in a boost::unordered_map.
 
 opflex::modb::URIBuilder::URIBuilder ()
 Construct an empty URI builder representing the root element.
 
 opflex::modb::URIBuilder::URIBuilder (const URI &uri)
 Construct a URI builder that will append URI elements to the specified URI.
 
 opflex::modb::URIBuilder::~URIBuilder ()
 Destroy the URI Builder.
 
URIBuilderopflex::modb::URIBuilder::addElement (const std::string &elementValue)
 Add a string-valued path element to the URI path, and URI-escape the value.
 
URIBuilderopflex::modb::URIBuilder::addElement (uint32_t elementValue)
 Add an unsigned int-valued path element to the URI path.
 
URIBuilderopflex::modb::URIBuilder::addElement (int32_t elementValue)
 Add a signed int-valued path element to the URI path.
 
URIBuilderopflex::modb::URIBuilder::addElement (uint64_t elementValue)
 Add an unsigned int-valued path element to the URI path.
 
URIBuilderopflex::modb::URIBuilder::addElement (int64_t elementValue)
 Add a signed int-valued path element to the URI path.
 
URIBuilderopflex::modb::URIBuilder::addElement (const MAC &elementValue)
 Add a mac-address-valued path element to the URI path.
 
URIBuilderopflex::modb::URIBuilder::addElement (const URI &elementValue)
 Add a URI path element to the URI path.
 
URI opflex::modb::URIBuilder::build ()
 Build the URI from the path elements and return it.
 

Variables

static const URI opflex::modb::URI::ROOT
 Static root URI.
 

Friends

class opflex::modb::Mutator::MutatorImpl
 
class opflex::modb::URIBuilder::URIBuilderImpl
 
bool opflex::modb::MAC::operator== (const MAC &lhs, const MAC &rhs)
 Check for MAC equality.
 
bool opflex::modb::MAC::operator!= (const MAC &lhs, const MAC &rhs)
 Check for MAC inequality.
 
size_t opflex::modb::MAC::hash_value (MAC const &mac)
 Compute a hash value for the MAC, making MAC suitable as a key in a boost::unordered_map.
 
bool opflex::modb::URI::operator== (const URI &lhs, const URI &rhs)
 Check for URI equality.
 
bool opflex::modb::URI::operator!= (const URI &lhs, const URI &rhs)
 Check for URI inequality.
 
bool opflex::modb::URI::operator< (const URI &lhs, const URI &rhs)
 Comparison operator for sorting.
 
size_t opflex::modb::URI::hash_value (URI const &uri)
 Compute a hash value for the URI, making URI suitable as a key in a boost::unordered_map.
 

Detailed Description

Types for accessing and working with managed objects.

Function Documentation

◆ addChild()

OF_SHARED_PTR< mointernal ::ObjectInstance > & opflex::modb::Mutator::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.

If the object already exists, get a mutable copy of that object.

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

◆ addElement() [1/7]

URIBuilder & opflex::modb::URIBuilder::addElement ( const MAC & elementValue)

Add a mac-address-valued path element to the URI path.

Parameters
elementValuethe value of the element

References URIBuilder().

◆ addElement() [2/7]

URIBuilder & opflex::modb::URIBuilder::addElement ( const std::string & elementValue)

Add a string-valued path element to the URI path, and URI-escape the value.

Parameters
elementValuethe value of the element

References URIBuilder().

◆ addElement() [3/7]

URIBuilder & opflex::modb::URIBuilder::addElement ( const URI & elementValue)

Add a URI path element to the URI path.

Note that this does not append the URI; this is actually a path element whose value is the URI.

Parameters
elementValuethe value of the element

References URIBuilder().

◆ addElement() [4/7]

URIBuilder & opflex::modb::URIBuilder::addElement ( int32_t elementValue)

Add a signed int-valued path element to the URI path.

Parameters
elementValuethe value of the element

References URIBuilder().

◆ addElement() [5/7]

URIBuilder & opflex::modb::URIBuilder::addElement ( int64_t elementValue)

Add a signed int-valued path element to the URI path.

Parameters
elementValuethe value of the element

References URIBuilder().

◆ addElement() [6/7]

URIBuilder & opflex::modb::URIBuilder::addElement ( uint32_t elementValue)

Add an unsigned int-valued path element to the URI path.

Parameters
elementValuethe value of the element

References URIBuilder().

◆ addElement() [7/7]

URIBuilder & opflex::modb::URIBuilder::addElement ( uint64_t elementValue)

Add an unsigned int-valued path element to the URI path.

Parameters
elementValuethe value of the element

References URIBuilder().

◆ commit()

void opflex::modb::Mutator::commit ( )

Commit the changes stored in the mutator to the object store.

If this method is not called, these changes will simply be lost. After you call commit(), you can continue to make changes using the same mutator which will be effectively a new "transaction".

◆ getElements()

void opflex::modb::URI::getElements ( std::vector< std::string > & elements) const

Parse the URI and get the unescaped path elements from the URI.

Parameters
elementsan array that will receive the path elements

◆ MAC() [1/2]

opflex::modb::MAC::MAC ( const std::string & mac)
explicit

Construct a MAC using the given string representation.

Parameters
macthe string representation of the mac
Exceptions
std::invalid_argumentif the MAC address is not valid

◆ MAC() [2/2]

opflex::modb::MAC::MAC ( uint8_t mac[6])
explicit

Construct a MAC using an array of 6 bytes, in network byte order.

Parameters
macthe mac represented as an array of 6 bytes

◆ modify()

OF_SHARED_PTR< mointernal::ObjectInstance > & opflex::modb::Mutator::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 specified URI.

Parameters
class_idthe class ID for the object
uriThe URI for the object

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

◆ Mutator() [1/2]

opflex::modb::Mutator::Mutator ( const std::string & owner)

Create a mutator that will work with the default framework instance and owner.

Parameters
ownerthe owner string that will control which fields can be modified.

◆ Mutator() [2/2]

opflex::modb::Mutator::Mutator ( ofcore::OFFramework & framework,
const std::string & owner )

Create a mutator that will work with the provided framework instance and owner.

Parameters
frameworkthe framework instance that will be modified
ownerthe owner string that will control which fields can be modified.

◆ objectUpdated()

virtual void opflex::modb::ObjectListener::objectUpdated ( class_id_t class_id,
const URI & uri )
pure virtual

The specified URI has been added, updated, or deleted.

The listener should queue a task to read the new state and perform appropriate processing. If this function blocks or peforms a long-running operation, then the dispatching of update notifications will be stalled, but there will not be any other deleterious effects.

If multiple changes happen to the same URI, then at least one notification will be delivered but some events may be consolidated.

Parameters
class_idthe class ID for the type associated with the updated object.
urithe URI for the updated object

◆ remove()

void opflex::modb::Mutator::remove ( class_id_t class_id,
const URI & uri )

Delete the child object specified along with its link to its parents.

If the child object has any children that are not removed, then they will be garbage-collected at some later time.

Parameters
class_idthe class ID for the object
urithe URI to remove

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

◆ URIBuilder()

opflex::modb::URIBuilder::URIBuilder ( const URI & uri)

Construct a URI builder that will append URI elements to the specified URI.

Parameters
urithe URI to build from

◆ ~Mutator()

opflex::modb::Mutator::~Mutator ( )

Destroy the Mutator.

Any uncommitted changes will be lost.