PostProcessingRegistry.hh 1.54 KB
/*
 * PostProcessingRegistry.hh
 *
 *  Created on: 27 sept. 2013
 *      Author: CS
 */

#ifndef POSTPROCESSINGREGISTRY_HH_
#define POSTPROCESSINGREGISTRY_HH_

#include <map>
#include <memory>
#include <mutex>
#include <vector>
#include "PostProcessing.hh"

namespace postprocessing {

class PostProcessingRegistry 
{
 public:
  /**
   * Gets singleton instance.
   */
  static PostProcessingRegistry& getInstance() 
  {
    return _Instance;
  }

  virtual ~PostProcessingRegistry();
  
  /**
   * Registers a post-processing.
   */
  std::string addElement(const std::string& pkey, PostProcessing* pp);
  
  /**
   * Gets all registered post-processing.
   */
  std::map<const std::string, PostProcessing*> getAllElements() 
  {
    return getPostProcessingMap();
  }

 protected:

  /**
   * Access the post-processing registry and guaranty it is created at the first access.
   */
  static std::map<const std::string, PostProcessing*>& getPostProcessingMap() {
    static std::map<const std::string, PostProcessing*> _postProcessingMap =
      std::map<const std::string, PostProcessing*>();
    return _postProcessingMap;
  }

 private:

  PostProcessingRegistry();
  
  /**
   * Singleton unique instance
   */
  //static std::unique_ptr<PostProcessingRegistry> _instance;

  static PostProcessingRegistry _Instance;

  /**
   * Flag to guarantee singleton unicity.
   */
  //static std::once_flag _instanceOnceFlag;

};

} /* namespace postprocessing */
#endif /* POSTPROCESSINGREGISTRY_HH_ */