OpFlex Framework  1.3.0
opflex::ofcore::OFFramework Class Reference

Main interface to the OpFlex framework. More...

#include <opflex/ofcore/OFFramework.h>

Inheritance diagram for opflex::ofcore::OFFramework:
opflex::ofcore::MockOFFramework

Public Member Functions

 OFFramework ()
 Create a new framework instance.
 
virtual ~OFFramework ()
 Destroy the framework instance.
 
void setModel (const modb::ModelMetadata &model)
 Add the given model metadata to the managed object database. More...
 
void setOpflexIdentity (const std::string &name, const std::string &domain)
 Set the opflex identity information for this framework instance. More...
 
void setOpflexIdentity (const std::string &name, const std::string &domain, const std::string &location)
 Set the opflex identity information for this framework instance. More...
 
virtual void start ()
 Start the framework. More...
 
virtual void stop ()
 Cleanly stop the framework.
 
virtual MainLoopAdaptorstartSync ()
 Start the framework in synchronous mode using a main loop adaptor. More...
 
virtual void dumpMODB (const std::string &file)
 Dump the managed object database to the file specified as a JSON blob. More...
 
virtual void dumpMODB (FILE *file)
 Dump the managed object database to the file specified as a JSON blob. More...
 
virtual void prettyPrintMODB (std::ostream &output, bool tree=true, bool includeProps=true, bool utf8=true)
 Pretty print the current MODB to the provided output stream. More...
 
virtual void enableSSL (const std::string &caStorePath, bool verifyPeers=true)
 Enable SSL for connections to opflex peers. More...
 
virtual void enableInspector (const std::string &socketName)
 Enable the MODB inspector service. More...
 
virtual void addPeer (const std::string &hostname, int port)
 Add an OpFlex peer. More...
 
virtual void registerPeerStatusListener (PeerStatusListener *listener)
 Register the given peer status listener to get updates on the health of the connection pool and on individual connections. More...
 

Static Public Member Functions

static const std::vector< int > & getVersion ()
 Get the library version as an vector of three version numbers: major, minor, and release.
 
static const std::string & getVersionStr ()
 Get the library version as a string of the format [major]. More...
 
static OFFrameworkdefaultInstance ()
 Get the static default instance of the framework.
 

Friends

class OFFrameworkImpl
 
class modb::Mutator
 
class modb::mointernal::MO
 
class MockOFFramework
 

Detailed Description

Main interface to the OpFlex framework.

This class manages configuration and lifecycle for the framework, and provides the primary interface point into the framework. You can create your own instance, or rely on the static default instance.

You must first initialize the framework by calling setModel() with your model and then calling start():

You can shut down the framework by calling stop():

Once the framework is initialized, you can interact with the model using the generated model classes, which include static methods for resolving objects from the managed object store.

Member Function Documentation

virtual void opflex::ofcore::OFFramework::addPeer ( const std::string &  hostname,
int  port 
)
virtual

Add an OpFlex peer.

If the framework is started, this will immediately initiate a new connection asynchronously.

When connecting to the peer, that peer may provide an additional list of peers to connect to, which will be automatically added as peers. If the peer does not include itself in the list, then the framework will disconnect from that peer and add the peers in the list. In this way, it is possible to automatically bootstrap the correct set of peers using a known hostname or IP address or a known, fixed anycast IP address.

Parameters
hostnamethe hostname or IP address to connect to
portthe TCP port to connect on
virtual void opflex::ofcore::OFFramework::dumpMODB ( const std::string &  file)
virtual

Dump the managed object database to the file specified as a JSON blob.

Parameters
filethe file to write to.
virtual void opflex::ofcore::OFFramework::dumpMODB ( FILE *  file)
virtual

Dump the managed object database to the file specified as a JSON blob.

Parameters
filethe file to write to.
virtual void opflex::ofcore::OFFramework::enableInspector ( const std::string &  socketName)
virtual

Enable the MODB inspector service.

The service will listen on the specified UNIX domain socket for connections from the inspector client.

Parameters
socketNameA path to the UNIX domain socket
virtual void opflex::ofcore::OFFramework::enableSSL ( const std::string &  caStorePath,
bool  verifyPeers = true 
)
virtual

Enable SSL for connections to opflex peers.

Parameters
caStorePaththe filesystem path to a directory containing CA certificates, or to a file containing a specific CA certificate.
verifyPeersset to true to verify that peer certificates properly chain to a trusted root
static const std::string& opflex::ofcore::OFFramework::getVersionStr ( )
static

Get the library version as a string of the format [major].

[minor].[release]-[build]

virtual void opflex::ofcore::OFFramework::prettyPrintMODB ( std::ostream &  output,
bool  tree = true,
bool  includeProps = true,
bool  utf8 = true 
)
virtual

Pretty print the current MODB to the provided output stream.

Parameters
outputthe output stream to write to
treeprint in a tree format
includePropsinclude the object properties
utf8output tree using UTF-8 box drawing
virtual void opflex::ofcore::OFFramework::registerPeerStatusListener ( PeerStatusListener listener)
virtual

Register the given peer status listener to get updates on the health of the connection pool and on individual connections.

Must be called before calling start() on the framework.

Parameters
listenerthe listener to register
void opflex::ofcore::OFFramework::setModel ( const modb::ModelMetadata model)

Add the given model metadata to the managed object database.

Must be called before start()

Parameters
modelthe model metadata to add to the object database
void opflex::ofcore::OFFramework::setOpflexIdentity ( const std::string &  name,
const std::string &  domain 
)

Set the opflex identity information for this framework instance.

Parameters
namethe unique name for this opflex component within the policy domain
domainthe globally unique name for this policy domain
void opflex::ofcore::OFFramework::setOpflexIdentity ( const std::string &  name,
const std::string &  domain,
const std::string &  location 
)

Set the opflex identity information for this framework instance.

Parameters
namethe unique name for this opflex component within the policy domain
domainthe globally unique name for this policy domain
locationthe location string for this policy element.
virtual void opflex::ofcore::OFFramework::start ( )
virtual

Start the framework.

This will start all the framework threads and attempt to connect to configured OpFlex peers.

Reimplemented in opflex::ofcore::MockOFFramework.

virtual MainLoopAdaptor* opflex::ofcore::OFFramework::startSync ( )
virtual

Start the framework in synchronous mode using a main loop adaptor.

You will be responsible for calling MainLoopAdaptor::runOnce in each iteration of your main loop so libopflex can make progress.

Returns
the MainLoopAdaptor you will need to call. The memory is owned by the framework and the pointer will become invalid when stop() is called.

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