OpFlex Framework  1.7.0
OFFramework.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 
572 #pragma once
573 #ifndef OPFLEX_CORE_OFFRAMEWORK_H
574 #define OPFLEX_CORE_OFFRAMEWORK_H
575 
576 #include <vector>
577 #include <string>
578 
579 #include <boost/noncopyable.hpp>
580 
581 #include "opflex/modb/Mutator.h"
584 
597 namespace opflex {
598 namespace modb {
599 class ObjectStore;
600 class ModelMetadata;
601 namespace mointernal {
602 class MO;
603 }
604 }
605 
606 namespace ofcore {
607 
644 class OFFramework : private boost::noncopyable {
645 public:
649  OFFramework();
650 
654  virtual ~OFFramework();
655 
660  static const std::vector<int>& getVersion();
661 
666  static const std::string& getVersionStr();
667 
671  static OFFramework& defaultInstance();
672 
679  void setModel(const modb::ModelMetadata& model);
680 
689  void setOpflexIdentity(const std::string& name,
690  const std::string& domain);
691 
701  void setOpflexIdentity(const std::string& name,
702  const std::string& domain,
703  const std::string& location);
704 
709  virtual void start();
710 
714  virtual void stop();
715 
726  virtual MainLoopAdaptor* startSync();
727 
734  virtual void dumpMODB(const std::string& file);
735 
742  virtual void dumpMODB(FILE* file);
743 
754  virtual void prettyPrintMODB(std::ostream& output,
755  bool tree = true,
756  bool includeProps = true,
757  bool utf8 = true,
758  size_t truncate = 0);
759 
769  virtual void enableSSL(const std::string& caStorePath,
770  bool verifyPeers = true);
771 
785  virtual void enableSSL(const std::string& caStorePath,
786  const std::string& keyAndCertFilePath,
787  const std::string& passphrase,
788  bool verifyPeers = true);
789 
797  virtual void enableInspector(const std::string& socketName);
798 
815  virtual void addPeer(const std::string& hostname,
816  int port);
817 
825  virtual void registerPeerStatusListener(PeerStatusListener* listener);
826 
827 private:
835  modb::ObjectStore& getStore();
836 
842  void registerTLMutator(modb::Mutator& mutator);
847  modb::Mutator& getTLMutator();
851  void clearTLMutator();
852 
853  class OFFrameworkImpl;
854  OFFrameworkImpl* pimpl;
855 
856  friend class OFFrameworkImpl;
857  friend class modb::Mutator;
858  friend class modb::mointernal::MO;
859  friend class MockOFFramework;
860 };
861 
869 class MockOFFramework : public OFFramework {
870 public:
871  MockOFFramework() : OFFramework() { }
872  virtual ~MockOFFramework() {};
873 
874  virtual void start();
875  virtual void stop();
876 };
877 
887 } /* namespace ofcore */
888 } /* namespace opflex */
889 
890 #endif /* OPFLEX_CORE_OFFRAMEWORK_H */
virtual ~OFFramework()
Destroy the framework instance.
static OFFramework & defaultInstance()
Get the static default instance of the framework.
This is the base class for all managed objects, which are the primary point of interface with data st...
Definition: MO.h:48
virtual void prettyPrintMODB(std::ostream &output, bool tree=true, bool includeProps=true, bool utf8=true, size_t truncate=0)
Pretty print the current MODB to the provided output stream.
A mutator represents a set of changes to apply to the data store.
Definition: Mutator.h:61
virtual MainLoopAdaptor * startSync()
Start the framework in synchronous mode using a main loop adaptor.
static const std::vector< int > & getVersion()
Get the library version as an vector of three version numbers: major, minor, and release.
OFFramework()
Create a new framework instance.
virtual void enableInspector(const std::string &socketName)
Enable the MODB inspector service.
Main interface to the OpFlex framework.
Definition: OFFramework.h:644
static const std::string & getVersionStr()
Get the library version as a string of the format [major].
virtual void registerPeerStatusListener(PeerStatusListener *listener)
Register the given peer status listener to get updates on the health of the connection pool and on in...
Interface definition for main loop adaptor.
virtual void stop()
Cleanly stop the framework.
virtual void dumpMODB(const std::string &file)
Dump the managed object database to the file specified as a JSON blob.
void setOpflexIdentity(const std::string &name, const std::string &domain)
Set the opflex identity information for this framework instance.
virtual void stop()
Cleanly stop the framework.
virtual void enableSSL(const std::string &caStorePath, bool verifyPeers=true)
Enable SSL for connections to opflex peers.
void setModel(const modb::ModelMetadata &model)
Add the given model metadata to the managed object database.
An interface for a listener that will get status update events for peer connection state...
Definition: PeerStatusListener.h:30
virtual void start()
Start the framework.
virtual void start()
Start the framework.
Model metadata encapsulated all the metadata for a given model.
Definition: ModelMetadata.h:47
An adaptor that allows integrating libopflex with an external main loop.
Definition: MainLoopAdaptor.h:31
A mock framework object that will not attempt to create remote connections or resolve references...
Definition: OFFramework.h:869
Interface definition file for Mutators.
virtual void addPeer(const std::string &hostname, int port)
Add an OpFlex peer.
Interface definition for peer status.