Gazebo Rendering

API Reference

9.3.0
RenderPassSystem.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17#ifndef GZ_RENDERING_RENDERPASSSYSTEM_HH_
18#define GZ_RENDERING_RENDERPASSSYSTEM_HH_
19
20#include <map>
21#include <memory>
22#include <string>
23#include <typeinfo>
24
25#include <gz/utils/SuppressWarning.hh>
26
27#include "gz/rendering/config.hh"
28#include "gz/rendering/Export.hh"
31
32namespace gz
33{
34 namespace rendering
35 {
36 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
37 //
38 // forward declaration
39 class RenderPassSystemPrivate;
40
41 /* \class RenderPassFactory RenderPassSystem.hh \
42 * gz/rendering/RenderPassSystem.hh
43 */
45 class GZ_RENDERING_VISIBLE RenderPassFactory
46 {
49 public: virtual RenderPass *New() const = 0;
50 };
51
52 /* \class RenderPassSystem RenderPassSystem.hh \
53 * gz/rendering/RenderPassSystem.hh
54 */
56 class GZ_RENDERING_VISIBLE RenderPassSystem
57 {
60
62 public: virtual ~RenderPassSystem();
63
66 public: template<typename T> RenderPassPtr Create()
67 {
68 return this->CreateImpl(typeid(T).name());
69 }
70
74 public: static void Register(const std::string &_type,
75 RenderPassFactory *_factory);
76
80 private: RenderPassPtr CreateImpl(const std::string &_type);
81
83 GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
86 private: static RenderPassMap &GetRenderPassMap();
87
91 GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
92 };
93
97 #define GZ_RENDERING_REGISTER_RENDER_PASS(classname, interface) \
98 class classname##Factory : public gz::rendering::RenderPassFactory \
99 { \
100 public: classname##Factory() \
101 { \
102 gz::rendering::RenderPassSystem::Register( \
103 typeid(interface).name(), this); \
104 } \
105 public: RenderPass *New() const override \
106 { \
107 return new classname(); \
108 } \
109 }; \
110 static classname##Factory global_##classname##Factory;
111 }
112 }
113}
114#endif