Accessing resources at run time with generated C++ code
You can access resources at run time with generated C++ code.
Procedure
To access the resource, add a
#include
directive
for the C++ header.Example
<%SPL::CodeGen::implementationPrologue($model);%>
#include "MyResource.h"
// Constructor
MY_OPERATOR::MY_OPERATOR() : _i(0)
{
}
// Tuple processing for non-mutating ports
void MY_OPERATOR::process(Tuple const & tuple, uint32_t port)
{
const IPort0Type & t = static_cast<const IPort0Type &>(tuple);
SPL::rstring r = MY_TOOLKIT_MESSAGE_1(++_i, t.get_i());
OPort0Type otuple(r);
submit(otuple, 0); // submit to output port 0
}
<%SPL::CodeGen::implementationEpilogue($model);%>
This
example includes both an #include
directive for MyResource.h,
and a macro MY_TOOLKIT_MESSAGE_1
to get the formatted
string. The formatted string can now be used as wanted.