RayZaler 0.1
The free opto-mechanical simulation framework
Singleton.h
1//
2// Copyright (c) 2024 Gonzalo José Carracedo Carballal
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Lesser General Public License as
6// published by the Free Software Foundation, either version 3 of the
7// License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public
15// License along with this program. If not, see
16// <http://www.gnu.org/licenses/>
17//
18
19#ifndef _SINGLETON_H
20#define _SINGLETON_H
21
22#include <string>
23#include <list>
24#include <map>
25
26namespace RZ
27{
28 class ElementFactory;
29 class MediumBoundary;
30 class RayTracingHeuristicFactory;
31
32 class FT2Facade;
33
34 class Singleton {
35 std::map<std::string, ElementFactory *> m_elementFactories;
36 std::map<std::string, MediumBoundary *> m_mediumBoundaries;
37 std::map<std::string, RayTracingHeuristicFactory *> m_rayTracingHeuristicFactories;
38 FT2Facade *m_freeType = nullptr;
39
40 static Singleton *m_currInstance;
41
42 Singleton();
43
44 public:
45 static Singleton *instance();
46 bool registerElementFactory(ElementFactory *);
47 ElementFactory *lookupElementFactory(std::string const &) const;
48 std::list<std::string> elementFactories() const;
49
50
51 bool registerMediumBoundary(MediumBoundary *);
52 MediumBoundary *lookupMediumBoundary(std::string const &) const;
53
54 bool registerRayTracingHeuristicFactory(RayTracingHeuristicFactory *);
55 RayTracingHeuristicFactory *lookupRayTracingHeuristicFactory(std::string const &) const;
56 std::list<std::string> rayTracingHeuristicFactories() const;
57
58
59 FT2Facade *freetype() const;
60
61 void logInitMessage();
62 };
63
64 void RZInit();
65}
66
67#endif // _SINGLETON_H
Definition: Element.h:393
Definition: FT2Facade.h:28
Definition: MediumBoundary.h:35
Definition: RayTracingHeuristic.h:49
Definition: Singleton.h:34