The spica renderer
renderparams.h
1 #ifdef _MSC_VER
2 #pragma once
3 #endif
4 
5 #ifndef _SPICA_RENDER_PARAMETERS_H_
6 #define _SPICA_RENDER_PARAMETERS_H_
7 
8 #include <string>
9 #include <memory>
10 #include <unordered_map>
11 
12 #include "common.h"
13 #include "point2d.h"
14 #include "vector2d.h"
15 #include "bounds2d.h"
16 #include "point3d.h"
17 #include "vector3d.h"
18 #include "bounds3d.h"
19 #include "normal3d.h"
20 #include "spectrum.h"
21 #include "transform.h"
22 
23 namespace spica {
24 
25 class CObject;
26 
27 class SPICA_EXPORTS RenderParams {
28 public:
29  static RenderParams &getInstance();
30 
31  ~RenderParams();
32 
33  RenderParams(RenderParams &&params);
34  RenderParams &operator=(RenderParams &&params);
35 
36  void clear();
37 
38  template <class T>
39  void add(const std::string &name, const T &value);
40 
41  bool getBool(const std::string &name, bool remove = false);
42  bool getBool(const std::string &name, bool value, bool remove = false);
43  int getInt(const std::string &name, bool remove = false);
44  int getInt(const std::string &name, int value, bool remove = false);
45  double getDouble(const std::string &name, bool remove = false);
46  double getDouble(const std::string &name, double value, bool remove = false);
47  std::string getString(const std::string &name, bool remove = false);
48  std::string getString(const std::string &name, const std::string &value, bool remove = false);
49  Point2d getPoint2d(const std::string &name, bool remove = false);
50  Vector2d getVector2d(const std::string &name, bool remove = false);
51  Bounds2d getBounds2d(const std::string &name, bool remove = false);
52  Point3d getPoint3d(const std::string &name, bool remove = false);
53  Point3d getPoint3d(const std::string &name, const Point3d &value, bool remove = false);
54  Vector3d getVector3d(const std::string &name, bool remove = false);
55  Bounds3d getBounds3d(const std::string &name, bool remove = false);
56  Normal3d getNormal3d(const std::string &name, bool remove = false);
57  Spectrum getSpectrum(const std::string &name, bool remove = false);
58  Spectrum getSpectrum(const std::string &name, const Spectrum &value, bool remove = false);
59  Transform getTransform(const std::string &name, bool remove = false);
60  Transform getTransform(const std::string &name, const Transform &value, bool remove = false);
61  std::shared_ptr<CObject> getTexture(const std::string &name, bool remove = false);
62  std::shared_ptr<CObject> getTexture(const std::string &name, const Spectrum &value, bool remove = false);
63  std::shared_ptr<CObject> getObject(const std::string &name, bool remove = false);
64  std::shared_ptr<CObject> getObject(const std::string &name, const std::shared_ptr<CObject> &value, bool remove = false);
65 
66 private:
67  RenderParams();
68  RenderParams(RenderParams &) = delete;
69  RenderParams &operator=(RenderParams &) = delete;
70 
71 private:
72  // Private fields
73  std::unordered_map<std::string, bool> bools;
74  std::unordered_map<std::string, int> ints;
75  std::unordered_map<std::string, double> doubles;
76  std::unordered_map<std::string, Point2d> point2ds;
77  std::unordered_map<std::string, Vector2d> vector2ds;
78  std::unordered_map<std::string, Bounds2d> bounds2ds;
79  std::unordered_map<std::string, Point3d> point3ds;
80  std::unordered_map<std::string, Vector3d> vector3ds;
81  std::unordered_map<std::string, Bounds3d> bounds3ds;
82  std::unordered_map<std::string, Normal3d> normals;
83  std::unordered_map<std::string, Spectrum> spectrums;
84  std::unordered_map<std::string, Transform> transforms;
85  std::unordered_map<std::string, std::string> strings;
86  std::unordered_map<std::string, std::shared_ptr<CObject>> objects;
87 };
88 
89 } // namespace spica
90 
91 #endif // _SPICA_RENDER_PARAMETERS_H_
RGB spectrum.
Definition: spectrum.h:18
Two-dimensional vector.
Definition: core.hpp:50
The transformation operator class.
Definition: transform.h:17
Definition: renderparams.h:27
Definition: bounds2d.h:16
Definition: bounds3d.h:16
Definition: core.hpp:68