Blame view

src/PostProcessing/PostProcessingRegistry.hh 1.54 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * 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_ */