Lluvia
PortDescriptor.h
Go to the documentation of this file.
1 
8 #ifndef LLUVIA_CORE_NODE_PORT_DESCRIPTOR_H_
9 #define LLUVIA_CORE_NODE_PORT_DESCRIPTOR_H_
10 
14 
15 #include <cstdint>
16 #include <memory>
17 #include <optional>
18 #include <string>
19 #include <vector>
20 
21 namespace ll {
22 
23 class Object;
24 class Buffer;
25 class ImageView;
26 
28 
29 public:
30  PortDescriptor() = default;
31  PortDescriptor(const PortDescriptor& descriptor) = default;
32  PortDescriptor(PortDescriptor&& descriptor) = default;
33 
34  ~PortDescriptor() = default;
35 
36  PortDescriptor(uint32_t binding,
37  const std::string& name,
38  ll::PortDirection direction,
39  ll::PortType portType);
40 
41  PortDescriptor& operator=(const PortDescriptor& descriptor) = default;
42  PortDescriptor& operator=(PortDescriptor&& descriptor) = default;
43 
44  uint32_t getBinding() const noexcept;
45  const std::string& getName() const noexcept;
46  ll::PortDirection getDirection() const noexcept;
47  ll::PortType getPortType() const noexcept;
48 
49  // optional checks
52  PortDescriptor& checkImageChannelTypeIsAnyOf(std::vector<ll::ChannelType> channelTypes) noexcept;
53  PortDescriptor& checkImageViewNormalizedCoordinatesIs(bool normalizedCoordinates) noexcept;
61  std::pair<bool, std::string> isValid(const std::shared_ptr<ll::Object>& port) const noexcept;
62 
63 private:
64  // at the moment there is nothing to validate for a Buffer type port
65  std::pair<bool, std::string> validateBuffer(const std::shared_ptr<ll::Buffer>& port) const noexcept;
66  std::pair<bool, std::string> validateImageView(const std::shared_ptr<ll::ImageView>& port) const noexcept;
67 
68  std::string toString() const noexcept;
69 
73  uint32_t m_binding {0};
74  std::string m_name {};
77 
78  // optional checks
79  std::optional<ll::ChannelCount> m_checkImageChannelCount {};
80  std::optional<std::vector<ll::ChannelType>> m_checkImageChannelType {};
81  std::optional<bool> m_checkImageViewNormalizedCoordinates {};
82 };
83 
84 } // namespace ll
85 
86 #endif // LLUVIA_CORE_NODE_PORT_DESCRIPTOR_H_
ImageDescriptor class and related enumerations.
PortDirection enum.
PortType enum.
Objects to manage raw portions of allocated memory.
Definition: Buffer.h:57
Represents portions of a ll::Image to be sent as parameter to a GLSL shader.
Definition: ImageView.h:149
Base class for all types that can be used in computer shaders.
Definition: Object.h:94
Definition: PortDescriptor.h:27
~PortDescriptor()=default
PortDescriptor(PortDescriptor &&descriptor)=default
PortDescriptor & checkImageChannelCountIs(ll::ChannelCount channelCount) noexcept
PortDescriptor()=default
ll::PortDirection getDirection() const noexcept
PortDescriptor & checkImageChannelTypeIsAnyOf(std::vector< ll::ChannelType > channelTypes) noexcept
PortDescriptor & checkImageChannelTypeIs(ll::ChannelType channelType) noexcept
PortDescriptor(const PortDescriptor &descriptor)=default
const std::string & getName() const noexcept
PortDescriptor & operator=(PortDescriptor &&descriptor)=default
PortDescriptor & checkImageViewNormalizedCoordinatesIs(bool normalizedCoordinates) noexcept
PortDescriptor(uint32_t binding, const std::string &name, ll::PortDirection direction, ll::PortType portType)
ll::PortType getPortType() const noexcept
uint32_t getBinding() const noexcept
PortDescriptor & operator=(const PortDescriptor &descriptor)=default
std::pair< bool, std::string > isValid(const std::shared_ptr< ll::Object > &port) const noexcept
Checks whether or not a given Object is a valid port.
Definition: Buffer.h:28
PortDirection
Class for port direction.
Definition: PortDirection.h:19
ChannelType
Supported image channel types.
Definition: ImageDescriptor.h:33
PortType
Port types.
Definition: PortType.h:21
ChannelCount
Supported image channel count.
Definition: ImageDescriptor.h:53