OpFlex Framework  1.3.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 
752  virtual void prettyPrintMODB(std::ostream& output,
753  bool tree = true,
754  bool includeProps = true,
755  bool utf8 = true);
756 
766  virtual void enableSSL(const std::string& caStorePath,
767  bool verifyPeers = true);
768 
776  virtual void enableInspector(const std::string& socketName);
777 
794  virtual void addPeer(const std::string& hostname,
795  int port);
796 
804  virtual void registerPeerStatusListener(PeerStatusListener* listener);
805 
806 private:
814  modb::ObjectStore& getStore();
815 
821  void registerTLMutator(modb::Mutator& mutator);
826  modb::Mutator& getTLMutator();
830  void clearTLMutator();
831 
832  class OFFrameworkImpl;
833  OFFrameworkImpl* pimpl;
834 
835  friend class OFFrameworkImpl;
836  friend class modb::Mutator;
837  friend class modb::mointernal::MO;
838  friend class MockOFFramework;
839 };
840 
848 class MockOFFramework : public OFFramework {
849 public:
850  MockOFFramework() : OFFramework() { }
851  virtual ~MockOFFramework() {};
852 
853  virtual void start();
854  virtual void stop();
855 };
856 
866 } /* namespace ofcore */
867 } /* namespace opflex */
868 
869 #endif /* OPFLEX_CORE_OFFRAMEWORK_H */
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.
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:49
A mutator represents a set of changes to apply to the data store.
Definition: Mutator.h:60
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:848
Interface definition file for Mutators.
virtual void addPeer(const std::string &hostname, int port)
Add an OpFlex peer.
Interface definition for peer status.