Gazebo Rendering

API Reference

9.0.0~pre2
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
84 private: static std::map<std::string, RenderPassFactory *> renderPassMap;
85
89 GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
90 };
91
95 #define GZ_RENDERING_REGISTER_RENDER_PASS(classname, interface) \
96 class classname##Factory : public gz::rendering::RenderPassFactory \
97 { \
98 public: classname##Factory() \
99 { \
100 gz::rendering::RenderPassSystem::Register( \
101 typeid(interface).name(), this); \
102 } \
103 public: RenderPass *New() const override \
104 { \
105 return new classname(); \
106 } \
107 }; \
108 static classname##Factory global_##classname##Factory;
109 }
110 }
111}
112#endif