OpFlex Framework  1.2.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"
583 
596 namespace opflex {
597 namespace modb {
598 class ObjectStore;
599 class ModelMetadata;
600 namespace mointernal {
601 class MO;
602 }
603 }
604 
605 namespace ofcore {
606 
643 class OFFramework : private boost::noncopyable {
644 public:
648  OFFramework();
649 
653  virtual ~OFFramework();
654 
659  static const std::vector<int>& getVersion();
660 
665  static const std::string& getVersionStr();
666 
670  static OFFramework& defaultInstance();
671 
678  void setModel(const modb::ModelMetadata& model);
679 
688  void setOpflexIdentity(const std::string& name,
689  const std::string& domain);
690 
700  void setOpflexIdentity(const std::string& name,
701  const std::string& domain,
702  const std::string& location);
703 
708  virtual void start();
709 
713  virtual void stop();
714 
721  virtual void dumpMODB(const std::string& file);
722 
729  virtual void dumpMODB(FILE* file);
730 
739  virtual void prettyPrintMODB(std::ostream& output,
740  bool tree = true,
741  bool includeProps = true,
742  bool utf8 = true);
743 
753  virtual void enableSSL(const std::string& caStorePath,
754  bool verifyPeers = true);
755 
763  virtual void enableInspector(const std::string& socketName);
764 
781  virtual void addPeer(const std::string& hostname,
782  int port);
783 
791  virtual void registerPeerStatusListener(PeerStatusListener* listener);
792 
793 private:
801  modb::ObjectStore& getStore();
802 
808  void registerTLMutator(modb::Mutator& mutator);
813  modb::Mutator& getTLMutator();
817  void clearTLMutator();
818 
819  class OFFrameworkImpl;
820  OFFrameworkImpl* pimpl;
821 
822  friend class OFFrameworkImpl;
823  friend class modb::Mutator;
824  friend class modb::mointernal::MO;
825  friend class MockOFFramework;
826 };
827 
835 class MockOFFramework : public OFFramework {
836 public:
837  MockOFFramework() : OFFramework() { }
838  virtual ~MockOFFramework() {};
839 
840  virtual void start();
841  virtual void stop();
842 };
843 
853 } /* namespace ofcore */
854 } /* namespace opflex */
855 
856 #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
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:643
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...
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
A mock framework object that will not attempt to create remote connections or resolve references...
Definition: OFFramework.h:835
Interface definition file for Mutators.
virtual void addPeer(const std::string &hostname, int port)
Add an OpFlex peer.
Interface definition for peer status.