31#ifndef DW_FRAMEWORK_PASS_HPP_
32#define DW_FRAMEWORK_PASS_HPP_
36#include <dwshared/dwfoundation/dw/core/container/StringView.hpp>
37#include <dwshared/dwfoundation/dw/core/container/HashContainer.hpp>
69 const dw::core::StringView&
getName()
const;
72 virtual dwStatus
run() = 0;
77 virtual dw::core::FixedString<MAX_NAME_LEN>
const&
getRunnableId(
bool isSubmitPass)
const = 0;
97 Pass(
const dw::core::StringView& name, dwProcessorType
const processor,
98 std::initializer_list<std::pair<dwStatus, uint32_t>>
const& returnMapping = {});
102 dw::core::StringView m_name;
105 dw::core::HeapHashMap<dwStatus, uint32_t> m_passReturnErrorMapping;
109template <
typename PassFunctionT>
112 static_assert(std::is_convertible<PassFunctionT, std::function<dwStatus()>>::value,
"PassFunctionT must be callable without arguments and return dwStatus");
117 const dw::core::StringView& name,
118 PassFunctionT
const passFunc,
119 dwProcessorType
const processor,
120 std::initializer_list<std::pair<dwStatus, uint32_t>>
const& returnMapping = {})
121 :
Pass(name, processor, returnMapping)
123 , m_functionInt(passFunc)
134 dw::core::Logger::Verbosity::ERROR);
143 throw ExceptionWithStatus(DW_BUFFER_FULL,
"setRunnableId() runnable id exceeds capacity: ", runnableId);
145 m_runnableId = dw::core::FixedString<MAX_NAME_LEN>(runnableId.data(), runnableId.size());
146 m_runnableIdSubmit = dw::core::FixedString<MAX_NAME_LEN>(runnableId.data(), runnableId.size());
148 m_runnableIdSubmit +=
"_submittee";
152 dw::core::FixedString<MAX_NAME_LEN>
const&
getRunnableId(
bool isSubmitPass)
const final
156 return m_runnableIdSubmit;
171 PassFunctionT m_functionInt;
173 dw::core::FixedString<MAX_NAME_LEN> m_runnableId;
175 dw::core::FixedString<MAX_NAME_LEN> m_runnableIdSubmit;
static dwStatus guard(TryBlock const &tryBlock, ::dw::core::Logger::Verbosity verbosity=::dw::core::Logger::Verbosity::ERROR)
PassImpl contains the function to invoke on run().
void setRunnableId(dw::core::StringView const &runnableId) final
Node & getNode() const final
dw::core::FixedString< MAX_NAME_LEN > const & getRunnableId(bool isSubmitPass) const final
PassImpl(Node &node, const dw::core::StringView &name, PassFunctionT const passFunc, dwProcessorType const processor, std::initializer_list< std::pair< dwStatus, uint32_t > > const &returnMapping={})
Constructor with a function running on the given processor type.
Pass is a runnable describes the metadata of a pass.
Pass(Pass const &)=delete
Copy constructor.
virtual Node & getNode() const =0
Get the node this pass belongs to.
cudaStream_t m_cudaStream
The cuda stream to use in case the processor type is GPU.
Pass(Pass &&)=delete
Move constructor.
virtual void setRunnableId(dw::core::StringView const &runnableId)=0
Set the runnable id.
dwProcessorType m_processor
The processor type this pass runs on.
dw::core::HeapHashMap< dwStatus, uint32_t > const & getPassReturnErrorMap()
Get the return status code to error map.
const dw::core::StringView & getName() const
Get the name of the pass.
Pass(const dw::core::StringView &name, dwProcessorType const processor, std::initializer_list< std::pair< dwStatus, uint32_t > > const &returnMapping={})
Constructor.
virtual dwStatus run()=0
Run the pass.
static constexpr const size_t MAX_NAME_LEN
The maximum length of the runnable id.
virtual ~Pass()=default
Destructor.
Pass & operator=(Pass const &) &=delete
Copy assignment operator.
Pass & operator=(Pass &&) &=delete
Move assignment operator.
virtual dw::core::FixedString< MAX_NAME_LEN > const & getRunnableId(bool isSubmitPass) const =0
Get the runnable id.